From eae099044268591d6c526635088558b48ee5f163 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Wed, 21 Jun 2023 20:54:35 -0400 Subject: [PATCH 1/2] Fix I18 next circular reference --- src/client/index.tsx | 2 +- src/shared/components/app/app.tsx | 6 +- src/shared/components/app/error-page.tsx | 12 +- src/shared/components/app/footer.tsx | 14 +- src/shared/components/app/navbar.tsx | 96 ++++--- .../components/comment/comment-form.tsx | 11 +- .../components/comment/comment-node.tsx | 265 ++++++++++-------- .../components/comment/comment-report.tsx | 9 +- src/shared/components/common/badges.tsx | 78 ++++-- .../components/common/comment-sort-select.tsx | 16 +- .../components/common/data-type-select.tsx | 6 +- src/shared/components/common/emoji-picker.tsx | 6 +- src/shared/components/common/html-tags.tsx | 4 +- src/shared/components/common/icon.tsx | 4 +- .../components/common/image-upload-form.tsx | 5 +- .../components/common/language-select.tsx | 13 +- .../components/common/listing-type-select.tsx | 15 +- .../components/common/markdown-textarea.tsx | 35 +-- src/shared/components/common/moment-time.tsx | 16 +- .../components/common/navigation-prompt.tsx | 4 +- src/shared/components/common/paginator.tsx | 6 +- .../common/registration-application.tsx | 30 +- .../components/common/searchable-select.tsx | 6 +- src/shared/components/common/sort-select.tsx | 32 ++- .../components/community/communities.tsx | 34 ++- .../components/community/community-form.tsx | 34 +-- src/shared/components/community/community.tsx | 14 +- .../components/community/create-community.tsx | 7 +- src/shared/components/community/sidebar.tsx | 67 ++--- src/shared/components/home/admin-settings.tsx | 21 +- src/shared/components/home/emojis-form.tsx | 43 +-- src/shared/components/home/home.tsx | 24 +- src/shared/components/home/instances.tsx | 21 +- src/shared/components/home/legal.tsx | 4 +- src/shared/components/home/login.tsx | 25 +- .../components/home/rate-limit-form.tsx | 16 +- src/shared/components/home/setup.tsx | 21 +- src/shared/components/home/signup.tsx | 45 +-- src/shared/components/home/site-form.tsx | 96 ++++--- src/shared/components/home/site-sidebar.tsx | 12 +- src/shared/components/home/tagline-form.tsx | 18 +- src/shared/components/modlog.tsx | 23 +- src/shared/components/person/cake-day.tsx | 6 +- src/shared/components/person/inbox.tsx | 40 ++- .../components/person/password-change.tsx | 13 +- src/shared/components/person/profile.tsx | 72 +++-- .../person/registration-applications.tsx | 14 +- src/shared/components/person/reports.tsx | 29 +- src/shared/components/person/settings.tsx | 116 ++++---- src/shared/components/person/verify-email.tsx | 8 +- src/shared/components/post/create-post.tsx | 7 +- src/shared/components/post/metadata-card.tsx | 4 +- src/shared/components/post/post-form.tsx | 48 ++-- src/shared/components/post/post-listing.tsx | 247 +++++++++------- src/shared/components/post/post-listings.tsx | 4 +- src/shared/components/post/post-report.tsx | 9 +- src/shared/components/post/post.tsx | 26 +- .../create-private-message.tsx | 9 +- .../private_message/private-message-form.tsx | 20 +- .../private-message-report.tsx | 13 +- .../private_message/private-message.tsx | 55 ++-- src/shared/components/search.tsx | 29 +- src/shared/services/HttpService.ts | 4 +- .../I18NextService.ts} | 104 ++++--- src/shared/services/UserService.ts | 6 +- src/shared/services/index.ts | 3 + src/shared/toast.ts | 13 +- src/shared/utils/app/initialize-site.ts | 5 +- .../utils/app/update-community-block.ts | 15 +- src/shared/utils/app/update-person-block.ts | 11 +- 70 files changed, 1171 insertions(+), 975 deletions(-) rename src/shared/{i18next.ts => services/I18NextService.ts} (53%) diff --git a/src/client/index.tsx b/src/client/index.tsx index 4ff794ec..eb2bb80f 100644 --- a/src/client/index.tsx +++ b/src/client/index.tsx @@ -2,7 +2,7 @@ import { initializeSite } from "@utils/app"; import { hydrate } from "inferno-hydrate"; import { Router } from "inferno-router"; import { App } from "../shared/components/app/app"; -import { HistoryService } from "../shared/services/HistoryService"; +import { HistoryService } from "../shared/services"; import "bootstrap/js/dist/collapse"; import "bootstrap/js/dist/dropdown"; diff --git a/src/shared/components/app/app.tsx b/src/shared/components/app/app.tsx index e615bb3a..e50a7070 100644 --- a/src/shared/components/app/app.tsx +++ b/src/shared/components/app/app.tsx @@ -2,9 +2,9 @@ import { isAuthPath, setIsoData } from "@utils/app"; import { Component, RefObject, createRef, linkEvent } from "inferno"; import { Provider } from "inferno-i18next-dess"; import { Route, Switch } from "inferno-router"; -import { i18n } from "../../i18next"; import { IsoDataOptionalSite } from "../../interfaces"; import { routes } from "../../routes"; +import { I18NextService } from "../../services"; import AuthGuard from "../common/auth-guard"; import ErrorGuard from "../common/error-guard"; import { ErrorPage } from "./error-page"; @@ -31,13 +31,13 @@ export class App extends Component { return ( <> - +
- ${i18n.t("jump_to_content", "Jump to content")} + ${I18NextService.i18n.t("jump_to_content", "Jump to content")} {siteView && ( diff --git a/src/shared/components/app/error-page.tsx b/src/shared/components/app/error-page.tsx index 7d4e2970..ec352d42 100644 --- a/src/shared/components/app/error-page.tsx +++ b/src/shared/components/app/error-page.tsx @@ -2,8 +2,8 @@ import { setIsoData } from "@utils/app"; import { Component } from "inferno"; import { T } from "inferno-i18next-dess"; import { Link } from "inferno-router"; -import { i18n } from "../../i18next"; import { IsoDataOptionalSite } from "../../interfaces"; +import { I18NextService } from "../../services"; export class ErrorPage extends Component { private isoData: IsoDataOptionalSite = setIsoData(this.context); @@ -19,8 +19,8 @@ export class ErrorPage extends Component {

{errorPageData - ? i18n.t("error_page_title") - : i18n.t("not_found_page_title")} + ? I18NextService.i18n.t("error_page_title") + : I18NextService.i18n.t("not_found_page_title")}

{errorPageData ? ( @@ -28,18 +28,18 @@ export class ErrorPage extends Component { ## ) : ( -

{i18n.t("not_found_page_message")}

+

{I18NextService.i18n.t("not_found_page_message")}

)} {!errorPageData && ( - {i18n.t("not_found_return_home_button")} + {I18NextService.i18n.t("not_found_return_home_button")} )} {errorPageData?.adminMatrixIds && errorPageData.adminMatrixIds.length > 0 && ( <>
- {i18n.t("error_page_admin_matrix", { + {I18NextService.i18n.t("error_page_admin_matrix", { instance: this.isoData.site_res?.site_view.site.name ?? "this instance", diff --git a/src/shared/components/app/footer.tsx b/src/shared/components/app/footer.tsx index 601045a4..6409ef35 100644 --- a/src/shared/components/app/footer.tsx +++ b/src/shared/components/app/footer.tsx @@ -2,7 +2,7 @@ import { Component } from "inferno"; import { NavLink } from "inferno-router"; import { GetSiteResponse } from "lemmy-js-client"; import { docsUrl, joinLemmyUrl, repoUrl } from "../../config"; -import { i18n } from "../../i18next"; +import { I18NextService } from "../../services"; import { VERSION } from "../../version"; interface FooterProps { @@ -29,36 +29,36 @@ export class Footer extends Component {
  • - {i18n.t("modlog")} + {I18NextService.i18n.t("modlog")}
  • {this.props.site?.site_view.local_site.legal_information && (
  • - {i18n.t("legal_information")} + {I18NextService.i18n.t("legal_information")}
  • )} {this.props.site?.site_view.local_site.federation_enabled && (
  • - {i18n.t("instances")} + {I18NextService.i18n.t("instances")}
  • )}
  • - {i18n.t("docs")} + {I18NextService.i18n.t("docs")}
  • - {i18n.t("code")} + {I18NextService.i18n.t("code")}
  • - {i18n.t("join_lemmy")} + {I18NextService.i18n.t("join_lemmy")}
  • diff --git a/src/shared/components/app/navbar.tsx b/src/shared/components/app/navbar.tsx index 12ca05db..2ede00e1 100644 --- a/src/shared/components/app/navbar.tsx +++ b/src/shared/components/app/navbar.tsx @@ -11,8 +11,7 @@ import { GetUnreadRegistrationApplicationCountResponse, } from "lemmy-js-client"; import { donateLemmyUrl, updateUnreadCountsInterval } from "../../config"; -import { i18n } from "../../i18next"; -import { UserService } from "../../services"; +import { I18NextService, UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; import { toast } from "../../toast"; import { Icon } from "../common/icon"; @@ -102,7 +101,7 @@ export class Navbar extends Component { { { @@ -162,7 +164,7 @@ export class Navbar extends Component { className="navbar-toggler border-0 p-1" type="button" aria-label="menu" - data-tippy-content={i18n.t("expand_here")} + data-tippy-content={I18NextService.i18n.t("expand_here")} data-bs-toggle="collapse" data-bs-target="#navbarDropdown" aria-controls="navbarDropdown" @@ -181,10 +183,10 @@ export class Navbar extends Component { - {i18n.t("communities")} + {I18NextService.i18n.t("communities")}
  • @@ -198,10 +200,10 @@ export class Navbar extends Component { state: { prevPath: this.currentLocation }, }} className="nav-link" - title={i18n.t("create_post")} + title={I18NextService.i18n.t("create_post")} onMouseUp={linkEvent(this, handleCollapseClick)} > - {i18n.t("create_post")} + {I18NextService.i18n.t("create_post")}
  • {this.props.siteRes && canCreateCommunity(this.props.siteRes) && ( @@ -209,22 +211,22 @@ export class Navbar extends Component { - {i18n.t("create_community")} + {I18NextService.i18n.t("create_community")} )}
  • - {i18n.t("support_lemmy")} + {I18NextService.i18n.t("support_lemmy")}
  • @@ -234,12 +236,12 @@ export class Navbar extends Component { - {i18n.t("search")} + {I18NextService.i18n.t("search")} @@ -248,12 +250,12 @@ export class Navbar extends Component { - {i18n.t("admin_settings")} + {I18NextService.i18n.t("admin_settings")} @@ -264,7 +266,7 @@ export class Navbar extends Component { { > - {i18n.t("unread_messages", { + {I18NextService.i18n.t("unread_messages", { count: Number(this.unreadInboxCount), formattedCount: numToSI(this.unreadInboxCount), })} @@ -289,7 +291,7 @@ export class Navbar extends Component { { > - {i18n.t("unread_reports", { + {I18NextService.i18n.t("unread_reports", { count: Number(this.unreadReportCount), formattedCount: numToSI(this.unreadReportCount), })} @@ -315,18 +317,26 @@ export class Navbar extends Component { - {i18n.t("unread_registration_applications", { - count: Number(this.unreadApplicationCount), - formattedCount: numToSI(this.unreadApplicationCount), - })} + {I18NextService.i18n.t( + "unread_registration_applications", + { + count: Number(this.unreadApplicationCount), + formattedCount: numToSI( + this.unreadApplicationCount + ), + } + )} {this.unreadApplicationCount > 0 && ( @@ -357,22 +367,22 @@ export class Navbar extends Component { - {i18n.t("profile")} + {I18NextService.i18n.t("profile")}
  • - {i18n.t("settings")} + {I18NextService.i18n.t("settings")}
  • @@ -384,7 +394,7 @@ export class Navbar extends Component { onClick={linkEvent(this, handleLogOut)} > - {i18n.t("logout")} + {I18NextService.i18n.t("logout")}
  • @@ -397,20 +407,20 @@ export class Navbar extends Component { - {i18n.t("login")} + {I18NextService.i18n.t("login")}
  • - {i18n.t("sign_up")} + {I18NextService.i18n.t("sign_up")}
  • @@ -504,7 +514,7 @@ export class Navbar extends Component { if (UserService.Instance.myUserInfo) { document.addEventListener("DOMContentLoaded", function () { if (!Notification) { - toast(i18n.t("notifications_error"), "danger"); + toast(I18NextService.i18n.t("notifications_error"), "danger"); return; } diff --git a/src/shared/components/comment/comment-form.tsx b/src/shared/components/comment/comment-form.tsx index c399fb06..294960a8 100644 --- a/src/shared/components/comment/comment-form.tsx +++ b/src/shared/components/comment/comment-form.tsx @@ -4,9 +4,8 @@ import { Component } from "inferno"; import { T } from "inferno-i18next-dess"; import { Link } from "inferno-router"; import { CreateComment, EditComment, Language } from "lemmy-js-client"; -import { i18n } from "../../i18next"; import { CommentNodeI } from "../../interfaces"; -import { UserService } from "../../services"; +import { I18NextService, UserService } from "../../services"; import { Icon } from "../common/icon"; import { MarkdownTextArea } from "../common/markdown-textarea"; @@ -58,7 +57,7 @@ export class CommentForm extends Component { disabled={this.props.disabled} onSubmit={this.handleCommentSubmit} onReplyCancel={this.props.onReplyCancel} - placeholder={i18n.t("comment_here")} + placeholder={I18NextService.i18n.t("comment_here") ?? undefined} allLanguages={this.props.allLanguages} siteLanguages={this.props.siteLanguages} /> @@ -79,10 +78,10 @@ export class CommentForm extends Component { get buttonTitle(): string { return typeof this.props.node === "number" - ? capitalizeFirstLetter(i18n.t("post")) + ? capitalizeFirstLetter(I18NextService.i18n.t("post")) : this.props.edit - ? capitalizeFirstLetter(i18n.t("save")) - : capitalizeFirstLetter(i18n.t("reply")); + ? capitalizeFirstLetter(I18NextService.i18n.t("save")) + : capitalizeFirstLetter(I18NextService.i18n.t("reply")); } handleCommentSubmit(content: string, form_id: string, language_id?: number) { diff --git a/src/shared/components/comment/comment-node.tsx b/src/shared/components/comment/comment-node.tsx index f6cb4b22..b558d142 100644 --- a/src/shared/components/comment/comment-node.tsx +++ b/src/shared/components/comment/comment-node.tsx @@ -48,7 +48,6 @@ import { } from "lemmy-js-client"; import moment from "moment"; import { commentTreeMaxDepth } from "../../config"; -import { i18n } from "../../i18next"; import { BanType, CommentNodeI, @@ -57,7 +56,7 @@ import { VoteType, } from "../../interfaces"; import { mdToHtml, mdToHtmlNoImages } from "../../markdown"; -import { UserService } from "../../services"; +import { I18NextService, UserService } from "../../services"; import { setupTippy } from "../../tippy"; import { Icon, PurgeWarning, Spinner } from "../common/icon"; import { MomentTime } from "../common/moment-time"; @@ -241,8 +240,8 @@ export class CommentNode extends Component { const purgeTypeText = this.state.purgeType == PurgeType.Comment - ? i18n.t("purge_comment") - : `${i18n.t("purge")} ${cv.creator.name}`; + ? I18NextService.i18n.t("purge_comment") + : `${I18NextService.i18n.t("purge")} ${cv.creator.name}`; const canMod_ = canMod( cv.creator.id, @@ -314,27 +313,27 @@ export class CommentNode extends Component { )} {this.isPostCreator && (
    - {i18n.t("creator")} + {I18NextService.i18n.t("creator")}
    )} {isMod_ && (
    - {i18n.t("mod")} + {I18NextService.i18n.t("mod")}
    )} {isAdmin_ && (
    - {i18n.t("admin")} + {I18NextService.i18n.t("admin")}
    )} {cv.creator.bot_account && (
    - {i18n.t("bot_account").toLowerCase()} + {I18NextService.i18n.t("bot_account").toLowerCase()}
    )} {this.props.showCommunity && ( <> - {i18n.t("to")} + {I18NextService.i18n.t("to")} @@ -366,7 +365,7 @@ export class CommentNode extends Component { ) : ( { onClick={linkEvent(this, this.handleMarkAsRead)} data-tippy-content={ this.commentReplyOrMentionRead - ? i18n.t("mark_as_unread") - : i18n.t("mark_as_read") + ? I18NextService.i18n.t("mark_as_unread") + : I18NextService.i18n.t("mark_as_read") } aria-label={ this.commentReplyOrMentionRead - ? i18n.t("mark_as_unread") - : i18n.t("mark_as_read") + ? I18NextService.i18n.t("mark_as_unread") + : I18NextService.i18n.t("mark_as_read") } > {this.state.readLoading ? ( @@ -456,8 +455,8 @@ export class CommentNode extends Component { : "text-muted" }`} onClick={linkEvent(this, this.handleUpvote)} - data-tippy-content={i18n.t("upvote")} - aria-label={i18n.t("upvote")} + data-tippy-content={I18NextService.i18n.t("upvote")} + aria-label={I18NextService.i18n.t("upvote")} aria-pressed={this.commentView.my_vote === 1} > {this.state.upvoteLoading ? ( @@ -483,8 +482,8 @@ export class CommentNode extends Component { : "text-muted" }`} onClick={linkEvent(this, this.handleDownvote)} - data-tippy-content={i18n.t("downvote")} - aria-label={i18n.t("downvote")} + data-tippy-content={I18NextService.i18n.t("downvote")} + aria-label={I18NextService.i18n.t("downvote")} aria-pressed={this.commentView.my_vote === -1} > {this.state.downvoteLoading ? ( @@ -506,8 +505,8 @@ export class CommentNode extends Component { @@ -515,8 +514,8 @@ export class CommentNode extends Component { @@ -527,7 +526,9 @@ export class CommentNode extends Component { @@ -537,10 +538,12 @@ export class CommentNode extends Component { this, this.handleShowReportDialog )} - data-tippy-content={i18n.t( + data-tippy-content={I18NextService.i18n.t( + "show_report_dialog" + )} + aria-label={I18NextService.i18n.t( "show_report_dialog" )} - aria-label={i18n.t("show_report_dialog")} > @@ -550,8 +553,10 @@ export class CommentNode extends Component { this, this.handleBlockPerson )} - data-tippy-content={i18n.t("block_user")} - aria-label={i18n.t("block_user")} + data-tippy-content={I18NextService.i18n.t( + "block_user" + )} + aria-label={I18NextService.i18n.t("block_user")} > {this.state.blockPersonLoading ? ( @@ -565,10 +570,14 @@ export class CommentNode extends Component { className="btn btn-link btn-animate text-muted" onClick={linkEvent(this, this.handleSaveComment)} data-tippy-content={ - cv.saved ? i18n.t("unsave") : i18n.t("save") + cv.saved + ? I18NextService.i18n.t("unsave") + : I18NextService.i18n.t("save") } aria-label={ - cv.saved ? i18n.t("unsave") : i18n.t("save") + cv.saved + ? I18NextService.i18n.t("unsave") + : I18NextService.i18n.t("save") } > {this.state.saveLoading ? ( @@ -585,8 +594,10 @@ export class CommentNode extends Component { @@ -613,13 +626,13 @@ export class CommentNode extends Component { )} data-tippy-content={ !cv.comment.deleted - ? i18n.t("delete") - : i18n.t("restore") + ? I18NextService.i18n.t("delete") + : I18NextService.i18n.t("restore") } aria-label={ !cv.comment.deleted - ? i18n.t("delete") - : i18n.t("restore") + ? I18NextService.i18n.t("delete") + : I18NextService.i18n.t("restore") } > {this.state.deleteLoading ? ( @@ -643,13 +656,13 @@ export class CommentNode extends Component { )} data-tippy-content={ !cv.comment.distinguished - ? i18n.t("distinguish") - : i18n.t("undistinguish") + ? I18NextService.i18n.t("distinguish") + : I18NextService.i18n.t("undistinguish") } aria-label={ !cv.comment.distinguished - ? i18n.t("distinguish") - : i18n.t("undistinguish") + ? I18NextService.i18n.t("distinguish") + : I18NextService.i18n.t("undistinguish") } > { this, this.handleModRemoveShow )} - aria-label={i18n.t("remove")} + aria-label={I18NextService.i18n.t("remove")} > - {i18n.t("remove")} + {I18NextService.i18n.t("remove")} ) : ( )} @@ -705,9 +718,13 @@ export class CommentNode extends Component { this, this.handleModBanFromCommunityShow )} - aria-label={i18n.t("ban_from_community")} + aria-label={I18NextService.i18n.t( + "ban_from_community" + )} > - {i18n.t("ban_from_community")} + {I18NextService.i18n.t( + "ban_from_community" + )} ) : ( ))} @@ -735,21 +752,25 @@ export class CommentNode extends Component { )} aria-label={ isMod_ - ? i18n.t("remove_as_mod") - : i18n.t("appoint_as_mod") + ? I18NextService.i18n.t("remove_as_mod") + : I18NextService.i18n.t( + "appoint_as_mod" + ) } > {isMod_ - ? i18n.t("remove_as_mod") - : i18n.t("appoint_as_mod")} + ? I18NextService.i18n.t("remove_as_mod") + : I18NextService.i18n.t("appoint_as_mod")} ) : ( <> ))} @@ -790,17 +811,21 @@ export class CommentNode extends Component { this, this.handleShowConfirmTransferCommunity )} - aria-label={i18n.t("transfer_community")} + aria-label={I18NextService.i18n.t( + "transfer_community" + )} > - {i18n.t("transfer_community")} + {I18NextService.i18n.t("transfer_community")} ) : ( <> ))} @@ -840,9 +865,11 @@ export class CommentNode extends Component { this, this.handlePurgePersonShow )} - aria-label={i18n.t("purge_user")} + aria-label={I18NextService.i18n.t( + "purge_user" + )} > - {i18n.t("purge_user")} + {I18NextService.i18n.t("purge_user")} {!isBanned(cv.creator) ? ( @@ -862,9 +891,11 @@ export class CommentNode extends Component { this, this.handleModBanShow )} - aria-label={i18n.t("ban_from_site")} + aria-label={I18NextService.i18n.t( + "ban_from_site" + )} > - {i18n.t("ban_from_site")} + {I18NextService.i18n.t("ban_from_site")} ) : ( )} @@ -895,18 +928,24 @@ export class CommentNode extends Component { )} aria-label={ isAdmin_ - ? i18n.t("remove_as_admin") - : i18n.t("appoint_as_admin") + ? I18NextService.i18n.t( + "remove_as_admin" + ) + : I18NextService.i18n.t( + "appoint_as_admin" + ) } > {isAdmin_ - ? i18n.t("remove_as_admin") - : i18n.t("appoint_as_admin")} + ? I18NextService.i18n.t("remove_as_admin") + : I18NextService.i18n.t( + "appoint_as_admin" + )} ) : ( <> ))} @@ -961,7 +1000,7 @@ export class CommentNode extends Component { ) : ( <> - {i18n.t("x_more_replies", { + {I18NextService.i18n.t("x_more_replies", { count: node.comment_view.counts.child_count, formattedCount: numToSI( node.comment_view.counts.child_count @@ -983,22 +1022,22 @@ export class CommentNode extends Component { className="visually-hidden" htmlFor={`mod-remove-reason-${cv.comment.id}`} > - {i18n.t("reason")} + {I18NextService.i18n.t("reason")} )} @@ -1011,23 +1050,23 @@ export class CommentNode extends Component { className="visually-hidden" htmlFor={`report-reason-${cv.comment.id}`} > - {i18n.t("reason")} + {I18NextService.i18n.t("reason")} )} @@ -1038,13 +1077,13 @@ export class CommentNode extends Component { className="col-form-label" htmlFor={`mod-ban-reason-${cv.comment.id}`} > - {i18n.t("reason")} + {I18NextService.i18n.t("reason")} @@ -1052,13 +1091,13 @@ export class CommentNode extends Component { className="col-form-label" htmlFor={`mod-ban-expires-${cv.comment.id}`} > - {i18n.t("expires")} + {I18NextService.i18n.t("expires")} @@ -1074,9 +1113,9 @@ export class CommentNode extends Component {
    @@ -1084,19 +1123,19 @@ export class CommentNode extends Component { {/* TODO hold off on expires until later */} {/*
    */} {/* */} - {/* */} + {/* */} {/*
    */}
    @@ -1108,13 +1147,13 @@ export class CommentNode extends Component {
    @@ -1209,8 +1248,8 @@ export class CommentNode extends Component { }); const title = this.props.showContext - ? i18n.t("show_context") - : i18n.t("link"); + ? I18NextService.i18n.t("show_context") + : I18NextService.i18n.t("link"); // The context button should show the parent comment by default const parentCommentId = getCommentParentId(cv.comment) ?? cv.comment.id; @@ -1255,17 +1294,17 @@ export class CommentNode extends Component { } get pointsTippy(): string { - const points = i18n.t("number_of_points", { + const points = I18NextService.i18n.t("number_of_points", { count: Number(this.commentView.counts.score), formattedCount: numToSI(this.commentView.counts.score), }); - const upvotes = i18n.t("number_of_upvotes", { + const upvotes = I18NextService.i18n.t("number_of_upvotes", { count: Number(this.commentView.counts.upvotes), formattedCount: numToSI(this.commentView.counts.upvotes), }); - const downvotes = i18n.t("number_of_downvotes", { + const downvotes = I18NextService.i18n.t("number_of_downvotes", { count: Number(this.commentView.counts.downvotes), formattedCount: numToSI(this.commentView.counts.downvotes), }); @@ -1274,15 +1313,17 @@ export class CommentNode extends Component { } get expandText(): string { - return this.state.collapsed ? i18n.t("expand") : i18n.t("collapse"); + return this.state.collapsed + ? I18NextService.i18n.t("expand") + : I18NextService.i18n.t("collapse"); } get commentUnlessRemoved(): string { const comment = this.commentView.comment; return comment.removed - ? `*${i18n.t("removed")}*` + ? `*${I18NextService.i18n.t("removed")}*` : comment.deleted - ? `*${i18n.t("deleted")}*` + ? `*${I18NextService.i18n.t("deleted")}*` : comment.content; } diff --git a/src/shared/components/comment/comment-report.tsx b/src/shared/components/comment/comment-report.tsx index b3630096..3b328f67 100644 --- a/src/shared/components/comment/comment-report.tsx +++ b/src/shared/components/comment/comment-report.tsx @@ -6,8 +6,8 @@ import { CommentView, ResolveCommentReport, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; import { CommentNodeI, CommentViewType } from "../../interfaces"; +import { I18NextService } from "../../services"; import { Icon, Spinner } from "../common/icon"; import { PersonListing } from "../person/person-listing"; import { CommentNode } from "./comment-node"; @@ -43,7 +43,7 @@ export class CommentReport extends Component< render() { const r = this.props.report; const comment = r.comment; - const tippyContent = i18n.t( + const tippyContent = I18NextService.i18n.t( r.comment_report.resolved ? "unresolve_report" : "resolve_report" ); @@ -102,10 +102,11 @@ export class CommentReport extends Component< onEditComment={() => Promise.resolve({ state: "empty" })} />
    - {i18n.t("reporter")}: + {I18NextService.i18n.t("reporter")}:{" "} +
    - {i18n.t("reason")}: {r.comment_report.reason} + {I18NextService.i18n.t("reason")}: {r.comment_report.reason}
    {r.resolver && (
    diff --git a/src/shared/components/common/badges.tsx b/src/shared/components/common/badges.tsx index ed9aecf8..c1eeed46 100644 --- a/src/shared/components/common/badges.tsx +++ b/src/shared/components/common/badges.tsx @@ -5,7 +5,7 @@ import { CommunityId, SiteAggregates, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; +import { I18NextService } from "../../services"; interface BadgesProps { counts: CommunityAggregates | SiteAggregates; @@ -29,66 +29,82 @@ export const Badges = ({ counts, communityId }: BadgesProps) => {
    • - {i18n.t("number_of_users", { + {I18NextService.i18n.t("number_of_users", { count: Number(counts.users_active_day), formattedCount: numToSI(counts.users_active_day), })}{" "} - / {i18n.t("day")} + / {I18NextService.i18n.t("day")}
    • - {i18n.t("number_of_users", { + {I18NextService.i18n.t("number_of_users", { count: Number(counts.users_active_week), formattedCount: numToSI(counts.users_active_week), })}{" "} - / {i18n.t("week")} + / {I18NextService.i18n.t("week")}
    • - {i18n.t("number_of_users", { + {I18NextService.i18n.t("number_of_users", { count: Number(counts.users_active_month), formattedCount: numToSI(counts.users_active_month), })}{" "} - / {i18n.t("month")} + / {I18NextService.i18n.t("month")}
    • - {i18n.t("number_of_users", { + {I18NextService.i18n.t("number_of_users", { count: Number(counts.users_active_half_year), formattedCount: numToSI(counts.users_active_half_year), })}{" "} - / {i18n.t("number_of_months", { count: 6, formattedCount: 6 })} + /{" "} + {I18NextService.i18n.t("number_of_months", { + count: 6, + formattedCount: 6, + })}
    • {isSiteAggregates(counts) && ( <>
    • - {i18n.t("number_of_users", { + {I18NextService.i18n.t("number_of_users", { count: Number(counts.users), formattedCount: numToSI(counts.users), })}
    • - {i18n.t("number_of_communities", { + {I18NextService.i18n.t("number_of_communities", { count: Number(counts.communities), formattedCount: numToSI(counts.communities), })} @@ -97,20 +113,20 @@ export const Badges = ({ counts, communityId }: BadgesProps) => { )} {isCommunityAggregates(counts) && (
    • - {i18n.t("number_of_subscribers", { + {I18NextService.i18n.t("number_of_subscribers", { count: Number(counts.subscribers), formattedCount: numToSI(counts.subscribers), })}
    • )}
    • - {i18n.t("number_of_posts", { + {I18NextService.i18n.t("number_of_posts", { count: Number(counts.posts), formattedCount: numToSI(counts.posts), })}
    • - {i18n.t("number_of_comments", { + {I18NextService.i18n.t("number_of_comments", { count: Number(counts.comments), formattedCount: numToSI(counts.comments), })} @@ -120,7 +136,7 @@ export const Badges = ({ counts, communityId }: BadgesProps) => { className="badge text-bg-primary" to={`/modlog${communityId ? `/${communityId}` : ""}`} > - {i18n.t("modlog")} + {I18NextService.i18n.t("modlog")}
    diff --git a/src/shared/components/common/comment-sort-select.tsx b/src/shared/components/common/comment-sort-select.tsx index 18eaed2a..ad4eebfe 100644 --- a/src/shared/components/common/comment-sort-select.tsx +++ b/src/shared/components/common/comment-sort-select.tsx @@ -2,7 +2,7 @@ import { randomStr } from "@utils/helpers"; import { Component, linkEvent } from "inferno"; import { CommentSortType } from "lemmy-js-client"; import { relTags, sortingHelpUrl } from "../../config"; -import { i18n } from "../../i18next"; +import { I18NextService } from "../../services"; import { Icon } from "./icon"; interface CommentSortSelectProps { @@ -42,21 +42,21 @@ export class CommentSortSelect extends Component< value={this.state.sort} onChange={linkEvent(this, this.handleSortChange)} className="sort-select form-select d-inline-block w-auto me-2 mb-2" - aria-label={i18n.t("sort_type")} + aria-label={I18NextService.i18n.t("sort_type")} > - , - , - - + , + , + + diff --git a/src/shared/components/common/data-type-select.tsx b/src/shared/components/common/data-type-select.tsx index b61d6840..6bf0666c 100644 --- a/src/shared/components/common/data-type-select.tsx +++ b/src/shared/components/common/data-type-select.tsx @@ -1,6 +1,6 @@ import { Component, linkEvent } from "inferno"; -import { i18n } from "../../i18next"; import { DataType } from "../../interfaces"; +import { I18NextService } from "../../services"; interface DataTypeSelectProps { type_: DataType; @@ -44,7 +44,7 @@ export class DataTypeSelect extends Component< checked={this.state.type_ == DataType.Post} onChange={linkEvent(this, this.handleTypeChange)} /> - {i18n.t("posts")} + {I18NextService.i18n.t("posts")}
    ); diff --git a/src/shared/components/common/emoji-picker.tsx b/src/shared/components/common/emoji-picker.tsx index 6c603754..ba36d755 100644 --- a/src/shared/components/common/emoji-picker.tsx +++ b/src/shared/components/common/emoji-picker.tsx @@ -1,5 +1,5 @@ import { Component, linkEvent } from "inferno"; -import { i18n } from "../../i18next"; +import { I18NextService } from "../../services"; import { EmojiMart } from "./emoji-mart"; import { Icon } from "./icon"; @@ -28,8 +28,8 @@ export class EmojiPicker extends Component { )} {this.state.content && ( @@ -300,7 +301,9 @@ export class MarkdownTextArea extends Component< }`} onClick={linkEvent(this, this.handlePreviewToggle)} > - {this.state.previewMode ? i18n.t("edit") : i18n.t("preview")} + {this.state.previewMode + ? I18NextService.i18n.t("edit") + : I18NextService.i18n.t("preview")} )}
    @@ -332,8 +335,8 @@ export class MarkdownTextArea extends Component< return (
    ); diff --git a/src/shared/components/common/registration-application.tsx b/src/shared/components/common/registration-application.tsx index 6e6914b3..3857c49e 100644 --- a/src/shared/components/common/registration-application.tsx +++ b/src/shared/components/common/registration-application.tsx @@ -5,8 +5,8 @@ import { ApproveRegistrationApplication, RegistrationApplicationView, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; import { mdToHtml } from "../../markdown"; +import { I18NextService } from "../../services"; import { PersonListing } from "../person/person-listing"; import { Spinner } from "./icon"; import { MarkdownTextArea } from "./markdown-textarea"; @@ -61,12 +61,14 @@ export class RegistrationApplication extends Component< return (
    - {i18n.t("applicant")}: + {I18NextService.i18n.t("applicant")}:{" "} +
    - {i18n.t("created")}: + {I18NextService.i18n.t("created")}:{" "} +
    -
    {i18n.t("answer")}:
    +
    {I18NextService.i18n.t("answer")}:
    {a.admin && ( @@ -84,7 +86,7 @@ export class RegistrationApplication extends Component< {ra.deny_reason && (
    - {i18n.t("deny_reason")}:{" "} + {I18NextService.i18n.t("deny_reason")}:{" "}
    - {this.state.approveLoading ? : i18n.t("approve")} + {this.state.approveLoading ? ( + + ) : ( + I18NextService.i18n.t("approve") + )} )} {(!ra.admin_id || (ra.admin_id && accepted)) && ( )}
    diff --git a/src/shared/components/common/searchable-select.tsx b/src/shared/components/common/searchable-select.tsx index cf3a0f62..a29fe160 100644 --- a/src/shared/components/common/searchable-select.tsx +++ b/src/shared/components/common/searchable-select.tsx @@ -7,7 +7,7 @@ import { linkEvent, RefObject, } from "inferno"; -import { i18n } from "../../i18next"; +import { I18NextService } from "../../services"; import { Icon, Spinner } from "./icon"; interface SearchableSelectProps { @@ -113,7 +113,7 @@ export class SearchableSelect extends Component< ref={this.toggleButtonRef} > {loading - ? `${i18n.t("loading")}${loadingEllipses}` + ? `${I18NextService.i18n.t("loading")}${loadingEllipses}` : options[selectedIndex].label}
    {!loading && diff --git a/src/shared/components/common/sort-select.tsx b/src/shared/components/common/sort-select.tsx index 546b3aec..90515d56 100644 --- a/src/shared/components/common/sort-select.tsx +++ b/src/shared/components/common/sort-select.tsx @@ -2,7 +2,7 @@ import { randomStr } from "@utils/helpers"; import { Component, linkEvent } from "inferno"; import { SortType } from "lemmy-js-client"; import { relTags, sortingHelpUrl } from "../../config"; -import { i18n } from "../../i18next"; +import { I18NextService } from "../../services"; import { Icon } from "./icon"; interface SortSelectProps { @@ -41,43 +41,45 @@ export class SortSelect extends Component { value={this.state.sort} onChange={linkEvent(this, this.handleSortChange)} className="sort-select form-select d-inline-block w-auto me-2" - aria-label={i18n.t("sort_type")} + aria-label={I18NextService.i18n.t("sort_type")} > {!this.props.hideHot && [ , , ]} - - + + {!this.props.hideMostComments && [ , , ]} - - - - - + + + + +
    diff --git a/src/shared/components/community/communities.tsx b/src/shared/components/community/communities.tsx index 9a4e836a..a84ec055 100644 --- a/src/shared/components/community/communities.tsx +++ b/src/shared/components/community/communities.tsx @@ -21,9 +21,8 @@ import { ListCommunitiesResponse, ListingType, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; import { InitialFetchRequest } from "../../interfaces"; -import { FirstLoadService } from "../../services/FirstLoadService"; +import { FirstLoadService, I18NextService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; import { HtmlTags } from "../common/html-tags"; import { Spinner } from "../common/icon"; @@ -86,7 +85,7 @@ export class Communities extends Component { } get documentTitle(): string { - return `${i18n.t("communities")} - ${ + return `${I18NextService.i18n.t("communities")} - ${ this.state.siteRes.site_view.site.name }`; } @@ -103,7 +102,9 @@ export class Communities extends Component { const { listingType, page } = this.getCommunitiesQueryParams(); return (
    -

    {i18n.t("list_of_communities")}

    +

    + {I18NextService.i18n.t("list_of_communities")} +

    { > - {i18n.t("name")} - {i18n.t("subscribers")} + {I18NextService.i18n.t("name")} - {i18n.t("users")} / {i18n.t("month")} + {I18NextService.i18n.t("subscribers")} + + + {I18NextService.i18n.t("users")} /{" "} + {I18NextService.i18n.t("month")} - {i18n.t("posts")} + {I18NextService.i18n.t("posts")} - {i18n.t("comments")} + {I18NextService.i18n.t("comments")} @@ -169,7 +173,7 @@ export class Communities extends Component { this.handleFollow )} > - {i18n.t("unsubscribe")} + {I18NextService.i18n.t("unsubscribe")} )} {cv.subscribed === "NotSubscribed" && ( @@ -184,12 +188,12 @@ export class Communities extends Component { this.handleFollow )} > - {i18n.t("subscribe")} + {I18NextService.i18n.t("subscribe")} )} {cv.subscribed === "Pending" && (
    - {i18n.t("subscribe_pending")} + {I18NextService.i18n.t("subscribe_pending")}
    )} @@ -230,7 +234,7 @@ export class Communities extends Component { id="communities-search" className="form-control" value={this.state.searchText} - placeholder={`${i18n.t("search")}...`} + placeholder={`${I18NextService.i18n.t("search")}...`} onInput={linkEvent(this, this.handleSearchChange)} required minLength={3} @@ -238,10 +242,10 @@ export class Communities extends Component {
    diff --git a/src/shared/components/community/community-form.tsx b/src/shared/components/community/community-form.tsx index ab19da82..6e2eba5a 100644 --- a/src/shared/components/community/community-form.tsx +++ b/src/shared/components/community/community-form.tsx @@ -7,7 +7,7 @@ import { EditCommunity, Language, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; +import { I18NextService } from "../../services"; import { Icon, Spinner } from "../common/icon"; import { ImageUploadForm } from "../common/image-upload-form"; import { LanguageSelect } from "../common/language-select"; @@ -107,10 +107,10 @@ export class CommunityForm extends Component< className="col-12 col-sm-2 col-form-label" htmlFor="community-name" > - {i18n.t("name")} + {I18NextService.i18n.t("name")} @@ -125,7 +125,7 @@ export class CommunityForm extends Component< required minLength={3} pattern="[a-z0-9_]+" - title={i18n.t("community_reqs")} + title={I18NextService.i18n.t("community_reqs")} />
    @@ -135,10 +135,10 @@ export class CommunityForm extends Component< className="col-12 col-sm-2 col-form-label" htmlFor="community-title" > - {i18n.t("display_name")} + {I18NextService.i18n.t("display_name")} @@ -158,11 +158,11 @@ export class CommunityForm extends Component<
    - {i18n.t("nsfw")} + {I18NextService.i18n.t("nsfw")}
    @@ -219,7 +219,7 @@ export class CommunityForm extends Component< )}
    - {i18n.t("only_mods_can_post_in_community")} + {I18NextService.i18n.t("only_mods_can_post_in_community")}
    @@ -254,9 +254,9 @@ export class CommunityForm extends Component< {this.props.loading ? ( ) : this.props.community_view ? ( - capitalizeFirstLetter(i18n.t("save")) + capitalizeFirstLetter(I18NextService.i18n.t("save")) ) : ( - capitalizeFirstLetter(i18n.t("create")) + capitalizeFirstLetter(I18NextService.i18n.t("create")) )} {this.props.community_view && ( @@ -265,7 +265,7 @@ export class CommunityForm extends Component< className="btn btn-secondary" onClick={linkEvent(this, this.handleCancel)} > - {i18n.t("cancel")} + {I18NextService.i18n.t("cancel")} )}
    diff --git a/src/shared/components/community/community.tsx b/src/shared/components/community/community.tsx index 195ff687..7eefe0eb 100644 --- a/src/shared/components/community/community.tsx +++ b/src/shared/components/community/community.tsx @@ -78,14 +78,12 @@ import { TransferCommunity, } from "lemmy-js-client"; import { fetchLimit, relTags } from "../../config"; -import { i18n } from "../../i18next"; import { CommentViewType, DataType, InitialFetchRequest, } from "../../interfaces"; -import { UserService } from "../../services"; -import { FirstLoadService } from "../../services/FirstLoadService"; +import { FirstLoadService, I18NextService, UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; import { setupTippy } from "../../tippy"; import { toast } from "../../toast"; @@ -331,7 +329,7 @@ export class Community extends Component< className="btn btn-secondary d-inline-block mb-2 me-3" onClick={linkEvent(this, this.handleShowSidebarMobile)} > - {i18n.t("sidebar")}{" "} + {I18NextService.i18n.t("sidebar")}{" "} ) { if (purgeRes.state == "success") { - toast(i18n.t("purge_success")); + toast(I18NextService.i18n.t("purge_success")); this.context.router.history.push(`/`); } } diff --git a/src/shared/components/community/create-community.tsx b/src/shared/components/community/create-community.tsx index 8a3b1985..2ce5af5a 100644 --- a/src/shared/components/community/create-community.tsx +++ b/src/shared/components/community/create-community.tsx @@ -4,8 +4,7 @@ import { CreateCommunity as CreateCommunityI, GetSiteResponse, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; -import { HttpService } from "../../services/HttpService"; +import { HttpService, I18NextService } from "../../services"; import { HtmlTags } from "../common/html-tags"; import { CommunityForm } from "./community-form"; @@ -26,7 +25,7 @@ export class CreateCommunity extends Component { } get documentTitle(): string { - return `${i18n.t("create_community")} - ${ + return `${I18NextService.i18n.t("create_community")} - ${ this.state.siteRes.site_view.site.name }`; } @@ -40,7 +39,7 @@ export class CreateCommunity extends Component { />
    -
    {i18n.t("create_community")}
    +
    {I18NextService.i18n.t("create_community")}
    { ) : ( <> - {i18n.t("joined")} + {I18NextService.i18n.t("joined")} )} @@ -200,23 +199,23 @@ export class Sidebar extends Component { {this.state.followCommunityLoading ? ( ) : ( - i18n.t("subscribe_pending") + I18NextService.i18n.t("subscribe_pending") )} )} {community.removed && ( - {i18n.t("removed")} + {I18NextService.i18n.t("removed")} )} {community.deleted && ( - {i18n.t("deleted")} + {I18NextService.i18n.t("deleted")} )} {community.nsfw && ( - {i18n.t("nsfw")} + {I18NextService.i18n.t("nsfw")} )} @@ -234,7 +233,7 @@ export class Sidebar extends Component { mods() { return (
      -
    • {i18n.t("mods")}:
    • +
    • {I18NextService.i18n.t("mods")}:
    • {this.props.moderators.map(mod => (
    • @@ -253,7 +252,7 @@ export class Sidebar extends Component { }`} to={`/create_post?communityId=${cv.community.id}`} > - {i18n.t("create_a_post")} + {I18NextService.i18n.t("create_a_post")} ); } @@ -270,7 +269,7 @@ export class Sidebar extends Component { {this.state.followCommunityLoading ? ( ) : ( - i18n.t("subscribe") + I18NextService.i18n.t("subscribe") )} )} @@ -288,7 +287,9 @@ export class Sidebar extends Component { className="btn btn-danger d-block mb-2 w-100" onClick={linkEvent(this, this.handleBlockCommunity)} > - {i18n.t(blocked ? "unblock_community" : "block_community")} + {I18NextService.i18n.t( + blocked ? "unblock_community" : "block_community" + )} )} @@ -315,8 +316,8 @@ export class Sidebar extends Component { @@ -331,20 +332,20 @@ export class Sidebar extends Component { this.handleShowConfirmLeaveModTeamClick )} > - {i18n.t("leave_mod_team")} + {I18NextService.i18n.t("leave_mod_team")}
    • ) : ( <>
    • - {i18n.t("are_you_sure")} + {I18NextService.i18n.t("are_you_sure")}
    • @@ -355,7 +356,7 @@ export class Sidebar extends Component { this.handleCancelLeaveModTeamClick )} > - {i18n.t("no")} + {I18NextService.i18n.t("no")}
    • @@ -367,13 +368,13 @@ export class Sidebar extends Component { onClick={linkEvent(this, this.handleDeleteCommunity)} data-tippy-content={ !community_view.community.deleted - ? i18n.t("delete") - : i18n.t("restore") + ? I18NextService.i18n.t("delete") + : I18NextService.i18n.t("restore") } aria-label={ !community_view.community.deleted - ? i18n.t("delete") - : i18n.t("restore") + ? I18NextService.i18n.t("delete") + : I18NextService.i18n.t("restore") } > {this.state.deleteCommunityLoading ? ( @@ -398,7 +399,7 @@ export class Sidebar extends Component { className="btn btn-link text-muted d-inline-block" onClick={linkEvent(this, this.handleModRemoveShow)} > - {i18n.t("remove")} + {I18NextService.i18n.t("remove")} ) : ( )} )} @@ -426,13 +427,13 @@ export class Sidebar extends Component {
      @@ -440,14 +441,14 @@ export class Sidebar extends Component { {/* TODO hold off on expires for now */} {/*
      */} {/* */} - {/* */} + {/* */} {/*
      */}
      @@ -460,13 +461,13 @@ export class Sidebar extends Component {
      @@ -478,9 +479,9 @@ export class Sidebar extends Component { )}
      diff --git a/src/shared/components/home/admin-settings.tsx b/src/shared/components/home/admin-settings.tsx index 9b14310c..7ac69fed 100644 --- a/src/shared/components/home/admin-settings.tsx +++ b/src/shared/components/home/admin-settings.tsx @@ -18,10 +18,9 @@ import { GetSiteResponse, PersonView, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; import { InitialFetchRequest } from "../../interfaces"; import { removeFromEmojiDataModel, updateEmojiDataModel } from "../../markdown"; -import { FirstLoadService } from "../../services/FirstLoadService"; +import { FirstLoadService, I18NextService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; import { toast } from "../../toast"; import { HtmlTags } from "../common/html-tags"; @@ -108,7 +107,7 @@ export class AdminSettings extends Component { } get documentTitle(): string { - return `${i18n.t("admin_settings")} - ${ + return `${I18NextService.i18n.t("admin_settings")} - ${ this.state.siteRes.site_view.site.name }`; } @@ -129,7 +128,7 @@ export class AdminSettings extends Component { tabs={[ { key: "site", - label: i18n.t("site"), + label: I18NextService.i18n.t("site"), getNode: isSelected => (
      { }, { key: "taglines", - label: i18n.t("taglines"), + label: I18NextService.i18n.t("taglines"), getNode: isSelected => (
      { }, { key: "emojis", - label: i18n.t("emojis"), + label: I18NextService.i18n.t("emojis"), getNode: isSelected => (
      { admins() { return ( <> -
      {capitalizeFirstLetter(i18n.t("admins"))}
      +
      {capitalizeFirstLetter(I18NextService.i18n.t("admins"))}
        {this.state.siteRes.admins.map(admin => (
      • @@ -275,7 +274,7 @@ export class AdminSettings extends Component { {this.state.leaveAdminTeamRes.state == "loading" ? ( ) : ( - i18n.t("leave_admin_team") + I18NextService.i18n.t("leave_admin_team") )} ); @@ -293,7 +292,7 @@ export class AdminSettings extends Component { const bans = this.state.bannedRes.data.banned; return ( <> -
        {i18n.t("banned_users")}
        +
        {I18NextService.i18n.t("banned_users")}
          {bans.map(banned => (
        • @@ -319,7 +318,7 @@ export class AdminSettings extends Component { s.siteRes.taglines = editRes.data.taglines; return s; }); - toast(i18n.t("site_saved")); + toast(I18NextService.i18n.t("site_saved")); } this.setState({ loading: false }); @@ -340,7 +339,7 @@ export class AdminSettings extends Component { }); if (this.state.leaveAdminTeamRes.state === "success") { - toast(i18n.t("left_admin_team")); + toast(I18NextService.i18n.t("left_admin_team")); this.context.router.history.replace("/"); } } diff --git a/src/shared/components/home/emojis-form.tsx b/src/shared/components/home/emojis-form.tsx index 569abd04..8428a54f 100644 --- a/src/shared/components/home/emojis-form.tsx +++ b/src/shared/components/home/emojis-form.tsx @@ -6,9 +6,8 @@ import { EditCustomEmoji, GetSiteResponse, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; import { customEmojisLookup } from "../../markdown"; -import { HttpService } from "../../services/HttpService"; +import { HttpService, I18NextService } from "../../services"; import { pictrsDeleteToast, toast } from "../../toast"; import { EmojiMart } from "../common/emoji-mart"; import { HtmlTags } from "../common/html-tags"; @@ -66,7 +65,7 @@ export class EmojiForm extends Component { this.handleEmojiClick = this.handleEmojiClick.bind(this); } get documentTitle(): string { - return i18n.t("custom_emojis"); + return I18NextService.i18n.t("custom_emojis"); } render() { @@ -76,7 +75,7 @@ export class EmojiForm extends Component { title={this.documentTitle} path={this.context.router.route.match.url} /> -
          {i18n.t("custom_emojis")}
          +
          {I18NextService.i18n.t("custom_emojis")}
          {customEmojisLookup.size > 0 && (
          { - - - - + + + + - @@ -215,8 +220,8 @@ export class EmojiForm extends Component { { i: this, cv: cv }, this.handleEditEmojiClick )} - data-tippy-content={i18n.t("save")} - aria-label={i18n.t("save")} + data-tippy-content={I18NextService.i18n.t("save")} + aria-label={I18NextService.i18n.t("save")} disabled={ this.props.loading || !this.canEdit(cv) || @@ -236,10 +241,10 @@ export class EmojiForm extends Component { { i: this, index: index, cv: cv }, this.handleDeleteEmojiClick )} - data-tippy-content={i18n.t("delete")} - aria-label={i18n.t("delete")} + data-tippy-content={I18NextService.i18n.t("delete")} + aria-label={I18NextService.i18n.t("delete")} disabled={this.props.loading} - title={i18n.t("delete")} + title={I18NextService.i18n.t("delete")} > { className="btn btn-sm btn-secondary me-2" onClick={linkEvent(this, this.handleAddEmojiClick)} > - {i18n.t("add_custom_emoji")} + {I18NextService.i18n.t("add_custom_emoji")} @@ -280,8 +285,8 @@ export class EmojiForm extends Component { } getEditTooltip(cv: CustomEmojiViewForm) { - if (this.canEdit(cv)) return i18n.t("save"); - else return i18n.t("custom_emoji_save_validation"); + if (this.canEdit(cv)) return I18NextService.i18n.t("save"); + else return I18NextService.i18n.t("custom_emoji_save_validation"); } handlePageChange(page: number) { diff --git a/src/shared/components/home/home.tsx b/src/shared/components/home/home.tsx index a8441380..0d91bdbc 100644 --- a/src/shared/components/home/home.tsx +++ b/src/shared/components/home/home.tsx @@ -73,15 +73,13 @@ import { TransferCommunity, } from "lemmy-js-client"; import { fetchLimit, relTags, trendingFetchLimit } from "../../config"; -import { i18n } from "../../i18next"; import { CommentViewType, DataType, InitialFetchRequest, } from "../../interfaces"; import { mdToHtml } from "../../markdown"; -import { UserService } from "../../services"; -import { FirstLoadService } from "../../services/FirstLoadService"; +import { FirstLoadService, I18NextService, UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; import { setupTippy } from "../../tippy"; import { toast } from "../../toast"; @@ -197,7 +195,7 @@ const MobileButton = ({ className="btn btn-secondary d-inline-block mb-2 me-3" onClick={onClick} > - {i18n.t(textKey)}{" "} + {I18NextService.i18n.t(textKey)}{" "} ); @@ -210,7 +208,7 @@ const LinkButton = ({ translationKey: NoOptionI18nKeys; }) => ( - {i18n.t(translationKey)} + {I18NextService.i18n.t(translationKey)} ); @@ -565,10 +563,14 @@ export class Home extends Component { className="btn btn-sm text-muted" onClick={linkEvent(this, this.handleCollapseSubscribe)} aria-label={ - subscribedCollapsed ? i18n.t("expand") : i18n.t("collapse") + subscribedCollapsed + ? I18NextService.i18n.t("expand") + : I18NextService.i18n.t("collapse") } data-tippy-content={ - subscribedCollapsed ? i18n.t("expand") : i18n.t("collapse") + subscribedCollapsed + ? I18NextService.i18n.t("expand") + : I18NextService.i18n.t("collapse") } aria-expanded="true" aria-controls="sidebarSubscribedBody" @@ -932,14 +934,14 @@ export class Home extends Component { async handleCommentReport(form: CreateCommentReport) { const reportRes = await HttpService.client.createCommentReport(form); if (reportRes.state == "success") { - toast(i18n.t("report_created")); + toast(I18NextService.i18n.t("report_created")); } } async handlePostReport(form: CreatePostReport) { const reportRes = await HttpService.client.createPostReport(form); if (reportRes.state == "success") { - toast(i18n.t("report_created")); + toast(I18NextService.i18n.t("report_created")); } } @@ -963,7 +965,7 @@ export class Home extends Component { async handleTransferCommunity(form: TransferCommunity) { await HttpService.client.transferCommunity(form); - toast(i18n.t("transfer_community")); + toast(I18NextService.i18n.t("transfer_community")); } async handleCommentReplyRead(form: MarkCommentReplyAsRead) { @@ -1030,7 +1032,7 @@ export class Home extends Component { purgeItem(purgeRes: RequestState) { if (purgeRes.state == "success") { - toast(i18n.t("purge_success")); + toast(I18NextService.i18n.t("purge_success")); this.context.router.history.push(`/`); } } diff --git a/src/shared/components/home/instances.tsx b/src/shared/components/home/instances.tsx index aba71099..b54c96af 100644 --- a/src/shared/components/home/instances.tsx +++ b/src/shared/components/home/instances.tsx @@ -7,9 +7,8 @@ import { Instance, } from "lemmy-js-client"; import { relTags } from "../../config"; -import { i18n } from "../../i18next"; import { InitialFetchRequest } from "../../interfaces"; -import { FirstLoadService } from "../../services/FirstLoadService"; +import { FirstLoadService, I18NextService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; import { HtmlTags } from "../common/html-tags"; import { Spinner } from "../common/icon"; @@ -70,7 +69,9 @@ export class Instances extends Component { } get documentTitle(): string { - return `${i18n.t("instances")} - ${this.state.siteRes.site_view.site.name}`; + return `${I18NextService.i18n.t("instances")} - ${ + this.state.siteRes.site_view.site.name + }`; } renderInstances() { @@ -86,18 +87,18 @@ export class Instances extends Component { return instances ? (
          -
          {i18n.t("linked_instances")}
          +
          {I18NextService.i18n.t("linked_instances")}
          {this.itemList(instances.linked)}
          {instances.allowed && instances.allowed.length > 0 && (
          -
          {i18n.t("allowed_instances")}
          +
          {I18NextService.i18n.t("allowed_instances")}
          {this.itemList(instances.allowed)}
          )} {instances.blocked && instances.blocked.length > 0 && (
          -
          {i18n.t("blocked_instances")}
          +
          {I18NextService.i18n.t("blocked_instances")}
          {this.itemList(instances.blocked)}
          )} @@ -127,9 +128,9 @@ export class Instances extends Component {
          {i18n.t("column_emoji")}{i18n.t("column_shortcode")}{i18n.t("column_category")} - {i18n.t("column_imageurl")} + {I18NextService.i18n.t("column_emoji")} + {I18NextService.i18n.t("column_shortcode")} + + {I18NextService.i18n.t("column_category")} + + {I18NextService.i18n.t("column_imageurl")} + + {I18NextService.i18n.t("column_alttext")} {i18n.t("column_alttext")} - {i18n.t("column_keywords")} + {I18NextService.i18n.t("column_keywords")}
          - - - + + + @@ -148,7 +149,7 @@ export class Instances extends Component {
          {i18n.t("name")}{i18n.t("software")}{i18n.t("version")}{I18NextService.i18n.t("name")}{I18NextService.i18n.t("software")}{I18NextService.i18n.t("version")}
          ) : ( -
          {i18n.t("none_found")}
          +
          {I18NextService.i18n.t("none_found")}
          ); } } diff --git a/src/shared/components/home/legal.tsx b/src/shared/components/home/legal.tsx index 90c461a8..85a413eb 100644 --- a/src/shared/components/home/legal.tsx +++ b/src/shared/components/home/legal.tsx @@ -1,8 +1,8 @@ import { setIsoData } from "@utils/app"; import { Component } from "inferno"; import { GetSiteResponse } from "lemmy-js-client"; -import { i18n } from "../../i18next"; import { mdToHtml } from "../../markdown"; +import { I18NextService } from "../../services"; import { HtmlTags } from "../common/html-tags"; interface LegalState { @@ -20,7 +20,7 @@ export class Legal extends Component { } get documentTitle(): string { - return i18n.t("legal_information"); + return I18NextService.i18n.t("legal_information"); } render() { diff --git a/src/shared/components/home/login.tsx b/src/shared/components/home/login.tsx index 3d602f91..1853a82b 100644 --- a/src/shared/components/home/login.tsx +++ b/src/shared/components/home/login.tsx @@ -3,8 +3,7 @@ import { isBrowser } from "@utils/browser"; import { validEmail } from "@utils/helpers"; import { Component, linkEvent } from "inferno"; import { GetSiteResponse, LoginResponse } from "lemmy-js-client"; -import { i18n } from "../../i18next"; -import { UserService } from "../../services"; +import { I18NextService, UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; import { toast } from "../../toast"; import { HtmlTags } from "../common/html-tags"; @@ -43,7 +42,9 @@ export class Login extends Component { } get documentTitle(): string { - return `${i18n.t("login")} - ${this.state.siteRes.site_view.site.name}`; + return `${I18NextService.i18n.t("login")} - ${ + this.state.siteRes.site_view.site.name + }`; } get isLemmyMl(): boolean { @@ -68,13 +69,13 @@ export class Login extends Component { return (
          -
          {i18n.t("login")}
          +
          {I18NextService.i18n.t("login")}
          {
          { !!this.state.form.username_or_email && !validEmail(this.state.form.username_or_email) } - title={i18n.t("no_password_reset")} + title={I18NextService.i18n.t("no_password_reset")} > - {i18n.t("forgot_password")} + {I18NextService.i18n.t("forgot_password")}
          @@ -124,7 +125,7 @@ export class Login extends Component { className="col-sm-6 col-form-label" htmlFor="login-totp-token" > - {i18n.t("two_factor_token")} + {I18NextService.i18n.t("two_factor_token")}
          { {this.state.loginRes.state == "loading" ? ( ) : ( - i18n.t("login") + I18NextService.i18n.t("login") )}
          @@ -172,7 +173,7 @@ export class Login extends Component { case "failed": { if (loginRes.msg === "missing_totp_token") { i.setState({ showTotp: true }); - toast(i18n.t("enter_two_factor_code"), "info"); + toast(I18NextService.i18n.t("enter_two_factor_code"), "info"); } i.setState({ loginRes: { state: "failed", msg: loginRes.msg } }); @@ -220,7 +221,7 @@ export class Login extends Component { if (email) { const res = await HttpService.client.passwordReset({ email }); if (res.state == "success") { - toast(i18n.t("reset_password_mail_sent")); + toast(I18NextService.i18n.t("reset_password_mail_sent")); } } } diff --git a/src/shared/components/home/rate-limit-form.tsx b/src/shared/components/home/rate-limit-form.tsx index 619e70d8..9003962a 100644 --- a/src/shared/components/home/rate-limit-form.tsx +++ b/src/shared/components/home/rate-limit-form.tsx @@ -3,7 +3,7 @@ import { capitalizeFirstLetter } from "@utils/helpers"; import classNames from "classnames"; import { Component, FormEventHandler, linkEvent } from "inferno"; import { EditSite, LocalSiteRateLimit } from "lemmy-js-client"; -import { i18n } from "../../i18next"; +import { I18NextService } from "../../services"; import { Spinner } from "../common/icon"; import Tabs from "../common/tabs"; @@ -57,7 +57,9 @@ function RateLimits({ return (
          - +
          - + -
          {i18n.t("rate_limit_header")}
          +
          {I18NextService.i18n.t("rate_limit_header")}
          ({ key: rateLimitType, - label: i18n.t(`rate_limit_${rateLimitType}`), + label: I18NextService.i18n.t(`rate_limit_${rateLimitType}`), getNode: isSelected => ( ) : ( - capitalizeFirstLetter(i18n.t("save")) + capitalizeFirstLetter(I18NextService.i18n.t("save")) )}
          diff --git a/src/shared/components/home/setup.tsx b/src/shared/components/home/setup.tsx index b595e14d..bed12620 100644 --- a/src/shared/components/home/setup.tsx +++ b/src/shared/components/home/setup.tsx @@ -7,8 +7,7 @@ import { LoginResponse, Register, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; -import { UserService } from "../../services"; +import { I18NextService, UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; import { Spinner } from "../common/icon"; import { SiteForm } from "./site-form"; @@ -55,7 +54,7 @@ export class Setup extends Component { } get documentTitle(): string { - return `${i18n.t("setup")} - Lemmy`; + return `${I18NextService.i18n.t("setup")} - Lemmy`; } render() { @@ -64,7 +63,7 @@ export class Setup extends Component {
          -

          {i18n.t("lemmy_instance_setup")}

          +

          {I18NextService.i18n.t("lemmy_instance_setup")}

          {!this.state.doneRegisteringUser ? ( this.registerUser() ) : ( @@ -85,10 +84,10 @@ export class Setup extends Component { registerUser() { return ( -
          {i18n.t("setup_admin")}
          +
          {I18NextService.i18n.t("setup_admin")}
          {
          @@ -113,7 +112,7 @@ export class Setup extends Component { type="email" id="email" className="form-control" - placeholder={i18n.t("optional")} + placeholder={I18NextService.i18n.t("optional")} value={this.state.form.email} onInput={linkEvent(this, this.handleRegisterEmailChange)} minLength={3} @@ -122,7 +121,7 @@ export class Setup extends Component {
          {
          { {this.state.registerRes.state == "loading" ? ( ) : ( - i18n.t("sign_up") + I18NextService.i18n.t("sign_up") )}
          diff --git a/src/shared/components/home/signup.tsx b/src/shared/components/home/signup.tsx index 817dcf8c..a2d960dc 100644 --- a/src/shared/components/home/signup.tsx +++ b/src/shared/components/home/signup.tsx @@ -13,9 +13,8 @@ import { SiteView, } from "lemmy-js-client"; import { joinLemmyUrl } from "../../config"; -import { i18n } from "../../i18next"; import { mdToHtml } from "../../markdown"; -import { UserService } from "../../services"; +import { I18NextService, UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; import { toast } from "../../toast"; import { HtmlTags } from "../common/html-tags"; @@ -113,7 +112,7 @@ export class Signup extends Component { } titleName(siteView: SiteView): string { - return i18n.t( + return I18NextService.i18n.t( siteView.local_site.private_instance ? "apply_to_join" : "sign_up" ); } @@ -159,7 +158,7 @@ export class Signup extends Component { className="col-sm-2 col-form-label" htmlFor="register-username" > - {i18n.t("username")} + {I18NextService.i18n.t("username")}
          @@ -172,14 +171,14 @@ export class Signup extends Component { required minLength={3} pattern="[a-zA-Z0-9_]+" - title={i18n.t("community_reqs")} + title={I18NextService.i18n.t("community_reqs")} />
          { className="form-control" placeholder={ siteView.local_site.require_email_verification - ? i18n.t("required") - : i18n.t("optional") + ? I18NextService.i18n.t("required") + : I18NextService.i18n.t("optional") } value={this.state.form.email} autoComplete="email" @@ -202,7 +201,7 @@ export class Signup extends Component { !validEmail(this.state.form.email) && (
          - {i18n.t("no_password_reset")} + {I18NextService.i18n.t("no_password_reset")}
          )}
          @@ -213,7 +212,7 @@ export class Signup extends Component { className="col-sm-2 col-form-label" htmlFor="register-password" > - {i18n.t("password")} + {I18NextService.i18n.t("password")}
          { /> {this.state.form.password && (
          - {i18n.t(this.passwordStrength as NoOptionI18nKeys)} + {I18NextService.i18n.t( + this.passwordStrength as NoOptionI18nKeys + )}
          )}
          @@ -240,7 +241,7 @@ export class Signup extends Component { className="col-sm-2 col-form-label" htmlFor="register-verify-password" > - {i18n.t("verify_password")} + {I18NextService.i18n.t("verify_password")}
          {
          - {i18n.t("fill_out_application")} + {I18NextService.i18n.t("fill_out_application")}
          {siteView.local_site.application_question && (
          { className="col-sm-2 col-form-label" htmlFor="application_answer" > - {i18n.t("answer")} + {I18NextService.i18n.t("answer")}
          { onChange={linkEvent(this, this.handleRegisterShowNsfwChange)} />
          @@ -345,12 +346,14 @@ export class Signup extends Component { return (
          @@ -260,7 +266,7 @@ export class SiteForm extends Component { className="form-check-label me-2" htmlFor="create-site-registration-mode" > - {i18n.t("registration_mode")} + {I18NextService.i18n.t("registration_mode")}
          {this.state.siteForm.registration_mode == "RequireApplication" && (
          { className="form-check-label" htmlFor="create-site-community-creation-admin-only" > - {i18n.t("community_creation_admin_only")} + {I18NextService.i18n.t("community_creation_admin_only")}
          @@ -331,7 +341,7 @@ export class SiteForm extends Component { className="form-check-label" htmlFor="create-site-require-email-verification" > - {i18n.t("require_email_verification")} + {I18NextService.i18n.t("require_email_verification")}
          @@ -353,7 +363,7 @@ export class SiteForm extends Component { className="form-check-label" htmlFor="create-site-email-admins" > - {i18n.t("application_email_admins")} + {I18NextService.i18n.t("application_email_admins")}
          @@ -372,7 +382,7 @@ export class SiteForm extends Component { className="form-check-label" htmlFor="create-site-reports-email-admins" > - {i18n.t("reports_email_admins")} + {I18NextService.i18n.t("reports_email_admins")}
          @@ -383,7 +393,7 @@ export class SiteForm extends Component { className="form-check-label me-2" htmlFor="create-site-default-theme" > - {i18n.t("theme")} + {I18NextService.i18n.t("theme")} { className="col-12 col-form-label" htmlFor="create-site-actor-name" > - {i18n.t("actor_name_max_length")} + {I18NextService.i18n.t("actor_name_max_length")}
          { className="form-check-label" htmlFor="create-site-federation-enabled" > - {i18n.t("federation_enabled")} + {I18NextService.i18n.t("federation_enabled")}
          @@ -537,7 +549,7 @@ export class SiteForm extends Component { className="form-check-label" htmlFor="create-site-federation-debug" > - {i18n.t("federation_debug")} + {I18NextService.i18n.t("federation_debug")}
          @@ -547,7 +559,7 @@ export class SiteForm extends Component { className="col-12 col-form-label" htmlFor="create-site-federation-worker-count" > - {i18n.t("federation_worker_count")} + {I18NextService.i18n.t("federation_worker_count")}
          { className="form-check-label" htmlFor="create-site-captcha-enabled" > - {i18n.t("captcha_enabled")} + {I18NextService.i18n.t("captcha_enabled")}
      @@ -591,7 +603,7 @@ export class SiteForm extends Component { className="form-check-label me-2" htmlFor="create-site-captcha-difficulty" > - {i18n.t("captcha_difficulty")} + {I18NextService.i18n.t("captcha_difficulty")}
      @@ -616,9 +630,9 @@ export class SiteForm extends Component { {this.props.loading ? ( ) : siteSetup ? ( - capitalizeFirstLetter(i18n.t("save")) + capitalizeFirstLetter(I18NextService.i18n.t("save")) ) : ( - capitalizeFirstLetter(i18n.t("create")) + capitalizeFirstLetter(I18NextService.i18n.t("create")) )}
    @@ -634,7 +648,7 @@ export class SiteForm extends Component { return (
    { className="btn btn-sm" onClick={linkEvent(this, this.handleCollapseSidebar)} aria-label={ - this.state.collapsed ? i18n.t("expand") : i18n.t("collapse") + this.state.collapsed + ? I18NextService.i18n.t("expand") + : I18NextService.i18n.t("collapse") } data-tippy-content={ - this.state.collapsed ? i18n.t("expand") : i18n.t("collapse") + this.state.collapsed + ? I18NextService.i18n.t("expand") + : I18NextService.i18n.t("collapse") } data-bs-toggle="collapse" data-bs-target="#sidebarInfoBody" @@ -104,7 +108,7 @@ export class SiteSidebar extends Component { admins(admins: PersonView[]) { return (
      -
    • {i18n.t("admins")}:
    • +
    • {I18NextService.i18n.t("admins")}:
    • {admins.map(av => (
    • diff --git a/src/shared/components/home/tagline-form.tsx b/src/shared/components/home/tagline-form.tsx index 60986c55..c79d9554 100644 --- a/src/shared/components/home/tagline-form.tsx +++ b/src/shared/components/home/tagline-form.tsx @@ -2,7 +2,7 @@ import { myAuthRequired } from "@utils/app"; import { capitalizeFirstLetter } from "@utils/helpers"; import { Component, InfernoMouseEvent, linkEvent } from "inferno"; import { EditSite, Tagline } from "lemmy-js-client"; -import { i18n } from "../../i18next"; +import { I18NextService } from "../../services"; import { HtmlTags } from "../common/html-tags"; import { Icon, Spinner } from "../common/icon"; import { MarkdownTextArea } from "../common/markdown-textarea"; @@ -27,7 +27,7 @@ export class TaglineForm extends Component { super(props, context); } get documentTitle(): string { - return i18n.t("taglines"); + return I18NextService.i18n.t("taglines"); } render() { @@ -37,7 +37,7 @@ export class TaglineForm extends Component { title={this.documentTitle} path={this.context.router.route.match.url} /> -
      {i18n.t("taglines")}
      +
      {I18NextService.i18n.t("taglines")}
      @@ -68,8 +68,8 @@ export class TaglineForm extends Component { { i: this, index: index }, this.handleEditTaglineClick )} - data-tippy-content={i18n.t("edit")} - aria-label={i18n.t("edit")} + data-tippy-content={I18NextService.i18n.t("edit")} + aria-label={I18NextService.i18n.t("edit")} > @@ -80,8 +80,8 @@ export class TaglineForm extends Component { { i: this, index: index }, this.handleDeleteTaglineClick )} - data-tippy-content={i18n.t("delete")} - aria-label={i18n.t("delete")} + data-tippy-content={I18NextService.i18n.t("delete")} + aria-label={I18NextService.i18n.t("delete")} > @@ -96,7 +96,7 @@ export class TaglineForm extends Component { className="btn btn-sm btn-secondary me-2" onClick={linkEvent(this, this.handleAddTaglineClick)} > - {i18n.t("add_tagline")} + {I18NextService.i18n.t("add_tagline")} @@ -111,7 +111,7 @@ export class TaglineForm extends Component { {this.props.loading ? ( ) : ( - capitalizeFirstLetter(i18n.t("save")) + capitalizeFirstLetter(I18NextService.i18n.t("save")) )} diff --git a/src/shared/components/modlog.tsx b/src/shared/components/modlog.tsx index edced0f4..e705bac8 100644 --- a/src/shared/components/modlog.tsx +++ b/src/shared/components/modlog.tsx @@ -46,9 +46,8 @@ import { } from "lemmy-js-client"; import moment from "moment"; import { fetchLimit } from "../config"; -import { i18n } from "../i18next"; import { InitialFetchRequest } from "../interfaces"; -import { FirstLoadService } from "../services/FirstLoadService"; +import { FirstLoadService, I18NextService } from "../services"; import { HttpService, RequestState } from "../services/HttpService"; import { HtmlTags } from "./common/html-tags"; import { Icon, Spinner } from "./common/icon"; @@ -586,14 +585,14 @@ const Filter = ({ }) => (
      id === person.id ) - ? i18n.t("admin") - : i18n.t("mod"); + ? I18NextService.i18n.t("admin") + : I18NextService.i18n.t("mod"); } get documentTitle(): string { @@ -770,7 +769,7 @@ export class Modlog extends Component< > /c/{this.state.communityRes.data.community_view.community.name}{" "} - {i18n.t("modlog")} + {I18NextService.i18n.t("modlog")} )}
      @@ -782,9 +781,9 @@ export class Modlog extends Component< aria-label="action" > - + @@ -848,9 +847,9 @@ export class Modlog extends Component<
      - - - + + + {this.combined} diff --git a/src/shared/components/person/cake-day.tsx b/src/shared/components/person/cake-day.tsx index d083f26f..ddb12bea 100644 --- a/src/shared/components/person/cake-day.tsx +++ b/src/shared/components/person/cake-day.tsx @@ -1,5 +1,5 @@ import { Component } from "inferno"; -import { i18n } from "../../i18next"; +import { I18NextService } from "../../services"; import { Icon } from "../common/icon"; interface CakeDayProps { @@ -19,6 +19,8 @@ export class CakeDay extends Component { } cakeDayTippy(): string { - return i18n.t("cake_day_info", { creator_name: this.props.creatorName }); + return I18NextService.i18n.t("cake_day_info", { + creator_name: this.props.creatorName, + }); } } diff --git a/src/shared/components/person/inbox.tsx b/src/shared/components/person/inbox.tsx index 91bbee03..062fc01c 100644 --- a/src/shared/components/person/inbox.tsx +++ b/src/shared/components/person/inbox.tsx @@ -59,10 +59,8 @@ import { TransferCommunity, } from "lemmy-js-client"; import { fetchLimit, relTags } from "../../config"; -import { i18n } from "../../i18next"; import { CommentViewType, InitialFetchRequest } from "../../interfaces"; -import { UserService } from "../../services"; -import { FirstLoadService } from "../../services/FirstLoadService"; +import { FirstLoadService, I18NextService, UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; import { toast } from "../../toast"; import { CommentNodes } from "../comment/comment-nodes"; @@ -187,9 +185,9 @@ export class Inbox extends Component { get documentTitle(): string { const mui = UserService.Instance.myUserInfo; return mui - ? `@${mui.local_user_view.person.name} ${i18n.t("inbox")} - ${ - this.state.siteRes.site_view.site.name - }` + ? `@${mui.local_user_view.person.name} ${I18NextService.i18n.t( + "inbox" + )} - ${this.state.siteRes.site_view.site.name}` : ""; } @@ -223,7 +221,7 @@ export class Inbox extends Component { path={this.context.router.route.match.url} />
      - {i18n.t("inbox")} + {I18NextService.i18n.t("inbox")} {inboxRss && ( @@ -245,7 +243,7 @@ export class Inbox extends Component { {this.state.markAllAsReadRes.state == "loading" ? ( ) : ( - i18n.t("mark_all_as_read") + I18NextService.i18n.t("mark_all_as_read") )} )} @@ -296,7 +294,7 @@ export class Inbox extends Component { checked={this.state.unreadOrAll == UnreadOrAll.Unread} onChange={linkEvent(this, this.handleUnreadOrAllChange)} /> - {i18n.t("unread")} + {I18NextService.i18n.t("unread")} ); @@ -331,7 +329,7 @@ export class Inbox extends Component { checked={this.state.messageType == MessageType.All} onChange={linkEvent(this, this.handleMessageTypeChange)} /> - {i18n.t("all")} + {I18NextService.i18n.t("all")} ); @@ -826,7 +824,7 @@ export class Inbox extends Component { const res = await HttpService.client.createComment(form); if (res.state === "success") { - toast(i18n.t("reply_sent")); + toast(I18NextService.i18n.t("reply_sent")); this.findAndUpdateComment(res); } @@ -837,7 +835,7 @@ export class Inbox extends Component { const res = await HttpService.client.editComment(form); if (res.state === "success") { - toast(i18n.t("edit")); + toast(I18NextService.i18n.t("edit")); this.findAndUpdateComment(res); } else if (res.state === "failed") { toast(res.msg, "danger"); @@ -849,7 +847,7 @@ export class Inbox extends Component { async handleDeleteComment(form: DeleteComment) { const res = await HttpService.client.deleteComment(form); if (res.state == "success") { - toast(i18n.t("deleted")); + toast(I18NextService.i18n.t("deleted")); this.findAndUpdateComment(res); } } @@ -857,7 +855,7 @@ export class Inbox extends Component { async handleRemoveComment(form: RemoveComment) { const res = await HttpService.client.removeComment(form); if (res.state == "success") { - toast(i18n.t("remove_comment")); + toast(I18NextService.i18n.t("remove_comment")); this.findAndUpdateComment(res); } } @@ -892,7 +890,7 @@ export class Inbox extends Component { async handleTransferCommunity(form: TransferCommunity) { await HttpService.client.transferCommunity(form); - toast(i18n.t("transfer_community")); + toast(I18NextService.i18n.t("transfer_community")); } async handleCommentReplyRead(form: MarkCommentReplyAsRead) { @@ -1004,7 +1002,7 @@ export class Inbox extends Component { purgeItem(purgeRes: RequestState) { if (purgeRes.state == "success") { - toast(i18n.t("purge_success")); + toast(I18NextService.i18n.t("purge_success")); this.context.router.history.push(`/`); } } @@ -1013,7 +1011,7 @@ export class Inbox extends Component { res: RequestState ) { if (res.state == "success") { - toast(i18n.t("report_created")); + toast(I18NextService.i18n.t("report_created")); } } diff --git a/src/shared/components/person/password-change.tsx b/src/shared/components/person/password-change.tsx index e20c3138..dd85e05b 100644 --- a/src/shared/components/person/password-change.tsx +++ b/src/shared/components/person/password-change.tsx @@ -2,8 +2,7 @@ import { myAuth, setIsoData } from "@utils/app"; import { capitalizeFirstLetter } from "@utils/helpers"; import { Component, linkEvent } from "inferno"; import { GetSiteResponse, LoginResponse } from "lemmy-js-client"; -import { i18n } from "../../i18next"; -import { HttpService, UserService } from "../../services"; +import { HttpService, I18NextService, UserService } from "../../services"; import { RequestState } from "../../services/HttpService"; import { HtmlTags } from "../common/html-tags"; import { Spinner } from "../common/icon"; @@ -34,7 +33,7 @@ export class PasswordChange extends Component { } get documentTitle(): string { - return `${i18n.t("password_change")} - ${ + return `${I18NextService.i18n.t("password_change")} - ${ this.state.siteRes.site_view.site.name }`; } @@ -48,7 +47,7 @@ export class PasswordChange extends Component { />
      -
      {i18n.t("password_change")}
      +
      {I18NextService.i18n.t("password_change")}
      {this.passwordChangeForm()}
      @@ -61,7 +60,7 @@ export class PasswordChange extends Component {
      {
      { {this.state.passwordChangeRes.state == "loading" ? ( ) : ( - capitalizeFirstLetter(i18n.t("save")) + capitalizeFirstLetter(I18NextService.i18n.t("save")) )}
      diff --git a/src/shared/components/person/profile.tsx b/src/shared/components/person/profile.tsx index 763947e8..d0003687 100644 --- a/src/shared/components/person/profile.tsx +++ b/src/shared/components/person/profile.tsx @@ -72,11 +72,9 @@ import { } from "lemmy-js-client"; import moment from "moment"; import { fetchLimit, relTags } from "../../config"; -import { i18n } from "../../i18next"; import { InitialFetchRequest, PersonDetailsView } from "../../interfaces"; import { mdToHtml } from "../../markdown"; -import { UserService } from "../../services"; -import { FirstLoadService } from "../../services/FirstLoadService"; +import { FirstLoadService, I18NextService, UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; import { setupTippy } from "../../tippy"; import { toast } from "../../toast"; @@ -137,7 +135,7 @@ const getCommunitiesListing = ( communityViews.length > 0 && (
      -
      {i18n.t(translationKey)}
      +
      {I18NextService.i18n.t(translationKey)}
        {communityViews.map(({ community }) => (
      • @@ -422,7 +420,7 @@ export class Profile extends Component< checked={active} onChange={linkEvent(this, this.handleViewChange)} /> - {i18n.t(view.toLowerCase() as NoOptionI18nKeys)} + {I18NextService.i18n.t(view.toLowerCase() as NoOptionI18nKeys)} ); } @@ -485,22 +483,22 @@ export class Profile extends Component<
      • {isBanned(pv.person) && (
      • - {i18n.t("banned")} + {I18NextService.i18n.t("banned")}
      • )} {pv.person.deleted && (
      • - {i18n.t("deleted")} + {I18NextService.i18n.t("deleted")}
      • )} {pv.person.admin && (
      • - {i18n.t("admin")} + {I18NextService.i18n.t("admin")}
      • )} {pv.person.bot_account && (
      • - {i18n.t("bot_account").toLowerCase()} + {I18NextService.i18n.t("bot_account").toLowerCase()}
      • )}
      @@ -516,7 +514,7 @@ export class Profile extends Component< rel={relTags} href={`https://matrix.to/#/${pv.person.matrix_user_id}`} > - {i18n.t("send_secure_message")} + {I18NextService.i18n.t("send_secure_message")}
      - {i18n.t("send_message")} + {I18NextService.i18n.t("send_message")} {personBlocked ? ( ) : ( )} @@ -563,9 +561,9 @@ export class Profile extends Component< "d-flex align-self-start btn btn-secondary me-2" } onClick={linkEvent(this, this.handleModBanShow)} - aria-label={i18n.t("ban")} + aria-label={I18NextService.i18n.t("ban")} > - {capitalizeFirstLetter(i18n.t("ban"))} + {capitalizeFirstLetter(I18NextService.i18n.t("ban"))} ) : ( ))}
      @@ -590,13 +588,13 @@ export class Profile extends Component<
      • - {i18n.t("number_of_posts", { + {I18NextService.i18n.t("number_of_posts", { count: Number(pv.counts.post_count), formattedCount: numToSI(pv.counts.post_count), })}
      • - {i18n.t("number_of_comments", { + {I18NextService.i18n.t("number_of_comments", { count: Number(pv.counts.comment_count), formattedCount: numToSI(pv.counts.comment_count), })} @@ -604,7 +602,7 @@ export class Profile extends Component<
      - {i18n.t("joined")}{" "} + {I18NextService.i18n.t("joined")}{" "} - {i18n.t("cake_day_title")}{" "} + {I18NextService.i18n.t("cake_day_title")}{" "} {moment .utc(pv.person.published) .local() @@ -623,7 +621,7 @@ export class Profile extends Component<
      {!UserService.Instance.myUserInfo && (
      - {i18n.t("profile_not_logged_in_alert")} + {I18NextService.i18n.t("profile_not_logged_in_alert")}
      )}
      @@ -641,24 +639,24 @@ export class Profile extends Component<
      @@ -674,9 +672,9 @@ export class Profile extends Component<
      @@ -684,23 +682,23 @@ export class Profile extends Component< {/* TODO hold off on expires until later */} {/*
      */} {/* */} - {/* */} + {/* */} {/*
      */}
      @@ -904,14 +902,14 @@ export class Profile extends Component< async handleCommentReport(form: CreateCommentReport) { const reportRes = await HttpService.client.createCommentReport(form); if (reportRes.state === "success") { - toast(i18n.t("report_created")); + toast(I18NextService.i18n.t("report_created")); } } async handlePostReport(form: CreatePostReport) { const reportRes = await HttpService.client.createPostReport(form); if (reportRes.state === "success") { - toast(i18n.t("report_created")); + toast(I18NextService.i18n.t("report_created")); } } @@ -935,7 +933,7 @@ export class Profile extends Component< async handleTransferCommunity(form: TransferCommunity) { await HttpService.client.transferCommunity(form); - toast(i18n.t("transfer_community")); + toast(I18NextService.i18n.t("transfer_community")); } async handleCommentReplyRead(form: MarkCommentReplyAsRead) { @@ -999,7 +997,7 @@ export class Profile extends Component< purgeItem(purgeRes: RequestState) { if (purgeRes.state == "success") { - toast(i18n.t("purge_success")); + toast(I18NextService.i18n.t("purge_success")); this.context.router.history.push(`/`); } } diff --git a/src/shared/components/person/registration-applications.tsx b/src/shared/components/person/registration-applications.tsx index 0e636fc7..d9eb6ad0 100644 --- a/src/shared/components/person/registration-applications.tsx +++ b/src/shared/components/person/registration-applications.tsx @@ -12,10 +12,8 @@ import { RegistrationApplicationView, } from "lemmy-js-client"; import { fetchLimit } from "../../config"; -import { i18n } from "../../i18next"; import { InitialFetchRequest } from "../../interfaces"; -import { UserService } from "../../services"; -import { FirstLoadService } from "../../services/FirstLoadService"; +import { FirstLoadService, I18NextService, UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; import { setupTippy } from "../../tippy"; import { HtmlTags } from "../common/html-tags"; @@ -79,7 +77,7 @@ export class RegistrationApplications extends Component< get documentTitle(): string { const mui = UserService.Instance.myUserInfo; return mui - ? `@${mui.local_user_view.person.name} ${i18n.t( + ? `@${mui.local_user_view.person.name} ${I18NextService.i18n.t( "registration_applications" )} - ${this.state.siteRes.site_view.site.name}` : ""; @@ -102,7 +100,9 @@ export class RegistrationApplications extends Component< title={this.documentTitle} path={this.context.router.route.match.url} /> -
      {i18n.t("registration_applications")}
      +
      + {I18NextService.i18n.t("registration_applications")} +
      {this.selects()} {this.applicationList(apps)} - {i18n.t("unread")} + {I18NextService.i18n.t("unread")}
      ); diff --git a/src/shared/components/person/reports.tsx b/src/shared/components/person/reports.tsx index 6fe59f1c..8f5eaf36 100644 --- a/src/shared/components/person/reports.tsx +++ b/src/shared/components/person/reports.tsx @@ -27,10 +27,13 @@ import { ResolvePrivateMessageReport, } from "lemmy-js-client"; import { fetchLimit } from "../../config"; -import { i18n } from "../../i18next"; import { InitialFetchRequest } from "../../interfaces"; -import { HttpService, UserService } from "../../services"; -import { FirstLoadService } from "../../services/FirstLoadService"; +import { + FirstLoadService, + HttpService, + I18NextService, + UserService, +} from "../../services"; import { RequestState } from "../../services/HttpService"; import { CommentReport } from "../comment/comment-report"; import { HtmlTags } from "../common/html-tags"; @@ -134,9 +137,9 @@ export class Reports extends Component { get documentTitle(): string { const mui = UserService.Instance.myUserInfo; return mui - ? `@${mui.local_user_view.person.name} ${i18n.t("reports")} - ${ - this.state.siteRes.site_view.site.name - }` + ? `@${mui.local_user_view.person.name} ${I18NextService.i18n.t( + "reports" + )} - ${this.state.siteRes.site_view.site.name}` : ""; } @@ -149,7 +152,7 @@ export class Reports extends Component { title={this.documentTitle} path={this.context.router.route.match.url} /> -
      {i18n.t("reports")}
      +
      {I18NextService.i18n.t("reports")}
      {this.selects()} {this.section} { checked={this.state.unreadOrAll == UnreadOrAll.Unread} onChange={linkEvent(this, this.handleUnreadOrAllChange)} /> - {i18n.t("unread")} + {I18NextService.i18n.t("unread")} ); @@ -233,7 +236,7 @@ export class Reports extends Component { checked={this.state.messageType == MessageType.All} onChange={linkEvent(this, this.handleMessageTypeChange)} /> - {i18n.t("all")} + {I18NextService.i18n.t("all")} {amAdmin() && ( )} diff --git a/src/shared/components/person/settings.tsx b/src/shared/components/person/settings.tsx index 5f149dfe..dc542e72 100644 --- a/src/shared/components/person/settings.tsx +++ b/src/shared/components/person/settings.tsx @@ -29,9 +29,9 @@ import { SortType, } from "lemmy-js-client"; import { elementUrl, emDash, relTags } from "../../config"; -import { i18n, languages } from "../../i18next"; import { UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; +import { I18NextService, languages } from "../../services/I18NextService"; import { setupTippy } from "../../tippy"; import { toast } from "../../toast"; import { HtmlTags } from "../common/html-tags"; @@ -113,7 +113,7 @@ const Filter = ({ className="col-md-4 col-form-label" htmlFor={`block-${filterType}-filter`} > - {i18n.t(`block_${filterType}` as NoOptionI18nKeys)} + {I18NextService.i18n.t(`block_${filterType}` as NoOptionI18nKeys)}
      { } get documentTitle(): string { - return i18n.t("settings"); + return I18NextService.i18n.t("settings"); } render() { @@ -249,12 +249,12 @@ export class Settings extends Component { tabs={[ { key: "settings", - label: i18n.t("settings"), + label: I18NextService.i18n.t("settings"), getNode: this.userSettings, }, { key: "blocks", - label: i18n.t("blocks"), + label: I18NextService.i18n.t("blocks"), getNode: this.blockCards, }, ]} @@ -316,11 +316,11 @@ export class Settings extends Component { changePasswordHtmlForm() { return ( <> -
      {i18n.t("change_password")}
      +
      {I18NextService.i18n.t("change_password")}
      { className="col-sm-5 col-form-label" htmlFor="user-verify-password" > - {i18n.t("verify_password")} + {I18NextService.i18n.t("verify_password")}
      { className="col-sm-5 col-form-label" htmlFor="user-old-password" > - {i18n.t("old_password")} + {I18NextService.i18n.t("old_password")}
      { {this.state.changePasswordRes.state === "loading" ? ( ) : ( - capitalizeFirstLetter(i18n.t("save")) + capitalizeFirstLetter(I18NextService.i18n.t("save")) )}
      @@ -409,7 +409,7 @@ export class Settings extends Component { blockedUsersList() { return ( <> -
      {i18n.t("blocked_users")}
      +
      {I18NextService.i18n.t("blocked_users")}
        {this.state.personBlocks.map(pb => (
      • @@ -421,7 +421,7 @@ export class Settings extends Component { { ctx: this, recipientId: pb.target.id }, this.handleUnblockPerson )} - data-tippy-content={i18n.t("unblock_user")} + data-tippy-content={I18NextService.i18n.t("unblock_user")} > @@ -453,7 +453,7 @@ export class Settings extends Component { blockedCommunitiesList() { return ( <> -
        {i18n.t("blocked_communities")}
        +
        {I18NextService.i18n.t("blocked_communities")}
          {this.state.communityBlocks.map(cb => (
        • @@ -465,7 +465,9 @@ export class Settings extends Component { { ctx: this, communityId: cb.community.id }, this.handleUnblockCommunity )} - data-tippy-content={i18n.t("unblock_community")} + data-tippy-content={I18NextService.i18n.t( + "unblock_community" + )} > @@ -482,18 +484,18 @@ export class Settings extends Component { return ( <> -
          {i18n.t("settings")}
          +
          {I18NextService.i18n.t("settings")}
          {
          {
          {
          @@ -552,11 +554,11 @@ export class Settings extends Component {
          {
          {
          { className="form-select d-inline-block w-auto" > + - {this.state.themeList.map(theme => (
          - +
          {
          { onChange={linkEvent(this, this.handleShowNsfwChange)} />
          @@ -688,7 +696,7 @@ export class Settings extends Component { onChange={linkEvent(this, this.handleShowScoresChange)} />
          @@ -702,7 +710,7 @@ export class Settings extends Component { onChange={linkEvent(this, this.handleShowAvatarsChange)} />
          @@ -716,7 +724,7 @@ export class Settings extends Component { onChange={linkEvent(this, this.handleBotAccount)} />
          @@ -733,7 +741,7 @@ export class Settings extends Component { className="form-check-label" htmlFor="user-show-bot-accounts" > - {i18n.t("show_bot_accounts")} + {I18NextService.i18n.t("show_bot_accounts")}
      @@ -750,7 +758,7 @@ export class Settings extends Component { className="form-check-label" htmlFor="user-show-read-posts" > - {i18n.t("show_read_posts")} + {I18NextService.i18n.t("show_read_posts")}
      @@ -767,7 +775,7 @@ export class Settings extends Component { className="form-check-label" htmlFor="user-show-new-post-notifs" > - {i18n.t("show_new_post_notifs")} + {I18NextService.i18n.t("show_new_post_notifs")}
      @@ -790,7 +798,7 @@ export class Settings extends Component { className="form-check-label" htmlFor="user-send-notifications-to-email" > - {i18n.t("send_notifications_to_email")} + {I18NextService.i18n.t("send_notifications_to_email")} @@ -800,7 +808,7 @@ export class Settings extends Component { {this.state.saveRes.state === "loading" ? ( ) : ( - capitalizeFirstLetter(i18n.t("save")) + capitalizeFirstLetter(I18NextService.i18n.t("save")) )} @@ -813,12 +821,12 @@ export class Settings extends Component { this.handleDeleteAccountShowConfirmToggle )} > - {i18n.t("delete_account")} + {I18NextService.i18n.t("delete_account")} {this.state.deleteAccountShowConfirm && ( <>
      - {i18n.t("delete_account_confirm")} + {I18NextService.i18n.t("delete_account_confirm")}
      { {this.state.deleteAccountRes.state === "loading" ? ( ) : ( - capitalizeFirstLetter(i18n.t("delete")) + capitalizeFirstLetter(I18NextService.i18n.t("delete")) )} )} @@ -876,7 +884,7 @@ export class Settings extends Component { onChange={linkEvent(this, this.handleGenerateTotp)} /> @@ -886,7 +894,7 @@ export class Settings extends Component { <>
      @@ -901,7 +909,7 @@ export class Settings extends Component { onChange={linkEvent(this, this.handleRemoveTotp)} />
      @@ -1050,7 +1058,7 @@ export class Settings extends Component { // Coerce false to undefined here, so it won't generate it. const checked: boolean | undefined = event.target.checked || undefined; if (checked) { - toast(i18n.t("two_factor_setup_instructions")); + toast(I18NextService.i18n.t("two_factor_setup_instructions")); } i.setState(s => ((s.saveUserSettingsForm.generate_totp_2fa = checked), s)); } @@ -1078,7 +1086,9 @@ export class Settings extends Component { handleInterfaceLangChange(i: Settings, event: any) { const newLang = event.target.value ?? "browser"; - i18n.changeLanguage(newLang === "browser" ? navigator.languages : newLang); + I18NextService.i18n.changeLanguage( + newLang === "browser" ? navigator.languages : newLang + ); i.setState( s => ((s.saveUserSettingsForm.interface_language = event.target.value), s) @@ -1168,7 +1178,7 @@ export class Settings extends Component { if (saveRes.state === "success") { UserService.Instance.login(saveRes.data); location.reload(); - toast(i18n.t("saved")); + toast(I18NextService.i18n.t("saved")); window.scrollTo(0, 0); } @@ -1191,7 +1201,7 @@ export class Settings extends Component { if (changePasswordRes.state === "success") { UserService.Instance.login(changePasswordRes.data); window.scrollTo(0, 0); - toast(i18n.t("password_changed")); + toast(I18NextService.i18n.t("password_changed")); } i.setState({ changePasswordRes }); diff --git a/src/shared/components/person/verify-email.tsx b/src/shared/components/person/verify-email.tsx index 7ef53823..1800c3f2 100644 --- a/src/shared/components/person/verify-email.tsx +++ b/src/shared/components/person/verify-email.tsx @@ -1,7 +1,7 @@ import { setIsoData } from "@utils/app"; import { Component } from "inferno"; import { GetSiteResponse, VerifyEmailResponse } from "lemmy-js-client"; -import { i18n } from "../../i18next"; +import { I18NextService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; import { toast } from "../../toast"; import { HtmlTags } from "../common/html-tags"; @@ -36,7 +36,7 @@ export class VerifyEmail extends Component { }); if (this.state.verifyRes.state == "success") { - toast(i18n.t("email_verified")); + toast(I18NextService.i18n.t("email_verified")); this.props.history.push("/login"); } } @@ -46,7 +46,7 @@ export class VerifyEmail extends Component { } get documentTitle(): string { - return `${i18n.t("verify_email")} - ${ + return `${I18NextService.i18n.t("verify_email")} - ${ this.state.siteRes.site_view.site.name }`; } @@ -60,7 +60,7 @@ export class VerifyEmail extends Component { />
      -
      {i18n.t("verify_email")}
      +
      {I18NextService.i18n.t("verify_email")}
      {this.state.verifyRes.state == "loading" && (
      diff --git a/src/shared/components/post/create-post.tsx b/src/shared/components/post/create-post.tsx index aa690381..fe941830 100644 --- a/src/shared/components/post/create-post.tsx +++ b/src/shared/components/post/create-post.tsx @@ -11,9 +11,8 @@ import { GetSiteResponse, ListCommunitiesResponse, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; import { InitialFetchRequest, PostFormParams } from "../../interfaces"; -import { FirstLoadService } from "../../services/FirstLoadService"; +import { FirstLoadService, I18NextService } from "../../services"; import { HttpService, RequestState, @@ -143,7 +142,7 @@ export class CreatePost extends Component< } get documentTitle(): string { - return `${i18n.t("create_post")} - ${ + return `${I18NextService.i18n.t("create_post")} - ${ this.state.siteRes.site_view.site.name }`; } @@ -171,7 +170,7 @@ export class CreatePost extends Component< id="createPostForm" className="col-12 col-lg-6 offset-lg-3 mb-4" > -

      {i18n.t("create_post")}

      +

      {I18NextService.i18n.t("create_post")}

      - {i18n.t("expand_here")} + {I18NextService.i18n.t("expand_here")} )}
      diff --git a/src/shared/components/post/post-form.tsx b/src/shared/components/post/post-form.tsx index 93851798..d2793fa2 100644 --- a/src/shared/components/post/post-form.tsx +++ b/src/shared/components/post/post-form.tsx @@ -31,9 +31,8 @@ import { trendingFetchLimit, webArchiveUrl, } from "../../config"; -import { i18n } from "../../i18next"; import { PostFormParams } from "../../interfaces"; -import { UserService } from "../../services"; +import { I18NextService, UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; import { setupTippy } from "../../tippy"; import { toast } from "../../toast"; @@ -342,7 +341,7 @@ export class PostForm extends Component { />
      { className={`${ UserService.Instance.myUserInfo && "pointer" } d-inline-block float-right text-muted font-weight-bold`} - data-tippy-content={i18n.t("upload_image")} + data-tippy-content={I18NextService.i18n.t("upload_image")} > @@ -381,7 +380,7 @@ export class PostForm extends Component { className="me-2 d-inline-block float-right text-muted small font-weight-bold" rel={relTags} > - archive.org {i18n.t("archive_link")} + archive.org {I18NextService.i18n.t("archive_link")} { className="me-2 d-inline-block float-right text-muted small font-weight-bold" rel={relTags} > - ghostarchive.org {i18n.t("archive_link")} + ghostarchive.org {I18NextService.i18n.t("archive_link")} { className="me-2 d-inline-block float-right text-muted small font-weight-bold" rel={relTags} > - archive.today {i18n.t("archive_link")} + archive.today {I18NextService.i18n.t("archive_link")}
      )} @@ -411,17 +410,17 @@ export class PostForm extends Component { )} {this.props.crossPosts && this.props.crossPosts.length > 0 && ( <>
      - {i18n.t("cross_posts")} + {I18NextService.i18n.t("cross_posts")}
      {
      {i18n.t("time")}{i18n.t("mod")}{i18n.t("action")} {I18NextService.i18n.t("time")}{I18NextService.i18n.t("mod")}{I18NextService.i18n.t("action")}