diff --git a/lemmy-translations b/lemmy-translations index ddf0d3a4..a241fe12 160000 --- a/lemmy-translations +++ b/lemmy-translations @@ -1 +1 @@ -Subproject commit ddf0d3a4dcfba5eddbcdb702db2470b52abb3815 +Subproject commit a241fe1255a6363c7ae1ec5a09520c066745e6ce diff --git a/package.json b/package.json index ba05f995..1055d853 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lemmy-ui", - "version": "0.18.0-rc.4", + "version": "0.18.0-rc.5", "description": "An isomorphic UI for lemmy", "repository": "https://github.com/LemmyNet/lemmy-ui", "license": "AGPL-3.0", @@ -66,7 +66,7 @@ "inferno-server": "^8.1.1", "isomorphic-cookie": "^1.2.4", "jwt-decode": "^3.1.2", - "lemmy-js-client": "0.18.0-rc.1", + "lemmy-js-client": "0.18.0-rc.2", "lodash": "^4.17.21", "markdown-it": "^13.0.1", "markdown-it-container": "^3.0.0", diff --git a/src/client/index.tsx b/src/client/index.tsx index 860c0756..eb2bb80f 100644 --- a/src/client/index.tsx +++ b/src/client/index.tsx @@ -1,8 +1,8 @@ +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 { initializeSite } from "../shared/utils"; +import { HistoryService } from "../shared/services"; import "bootstrap/js/dist/collapse"; import "bootstrap/js/dist/dropdown"; diff --git a/src/server/handlers/catch-all-handler.tsx b/src/server/handlers/catch-all-handler.tsx index eb847dc7..b9ff13bf 100644 --- a/src/server/handlers/catch-all-handler.tsx +++ b/src/server/handlers/catch-all-handler.tsx @@ -1,3 +1,5 @@ +import { initializeSite, isAuthPath } from "@utils/app"; +import { ErrorPageData } from "@utils/types"; import type { Request, Response } from "express"; import { StaticRouter, matchPath } from "inferno-router"; import { renderToString } from "inferno-server"; @@ -15,7 +17,6 @@ import { FailedRequestState, wrapClient, } from "../../shared/services/HttpService"; -import { ErrorPageData, initializeSite, isAuthPath } from "../../shared/utils"; import { createSsrHtml } from "../utils/create-ssr-html"; import { getErrorPageData } from "../utils/get-error-page-data"; import { setForwardedHeaders } from "../utils/set-forwarded-headers"; @@ -28,7 +29,9 @@ export default async (req: Request, res: Response) => { const getSiteForm: GetSite = { auth }; const headers = setForwardedHeaders(req.headers); - const client = wrapClient(new LemmyHttp(getHttpBaseInternal(), headers)); + const client = wrapClient( + new LemmyHttp(getHttpBaseInternal(), { fetchFunction: fetch, headers }) + ); const { path, url, query } = req; diff --git a/src/server/handlers/manifest-handler.ts b/src/server/handlers/manifest-handler.ts index bdaed3f9..6858cffd 100644 --- a/src/server/handlers/manifest-handler.ts +++ b/src/server/handlers/manifest-handler.ts @@ -1,6 +1,6 @@ import type { Request, Response } from "express"; import { LemmyHttp } from "lemmy-js-client"; -import { getHttpBaseInternal } from "../../shared/env"; +import { getHttpBaseExternal, getHttpBaseInternal } from "../../shared/env"; import { wrapClient } from "../../shared/services/HttpService"; import generateManifestJson from "../utils/generate-manifest-json"; import { setForwardedHeaders } from "../utils/set-forwarded-headers"; @@ -9,9 +9,11 @@ let manifest: Awaited> | undefined = undefined; export default async (req: Request, res: Response) => { - if (!manifest) { + if (!manifest || manifest.start_url !== getHttpBaseExternal()) { const headers = setForwardedHeaders(req.headers); - const client = wrapClient(new LemmyHttp(getHttpBaseInternal(), headers)); + const client = wrapClient( + new LemmyHttp(getHttpBaseInternal(), { fetchFunction: fetch, headers }) + ); const site = await client.getSite({}); if (site.state === "success") { diff --git a/src/server/index.tsx b/src/server/index.tsx index 144b596e..b65506b0 100644 --- a/src/server/index.tsx +++ b/src/server/index.tsx @@ -25,7 +25,7 @@ if (!process.env["LEMMY_UI_DISABLE_CSP"] && !process.env["LEMMY_UI_DEBUG"]) { server.get("/robots.txt", RobotsHandler); server.get("/service-worker.js", ServiceWorkerHandler); -server.get("/manifest", ManifestHandler); +server.get("/manifest.webmanifest", ManifestHandler); server.get("/css/themes/:name", ThemeHandler); server.get("/css/themelist", ThemesListHandler); server.get("/*", CatchAllHandler); diff --git a/src/server/utils/create-ssr-html.tsx b/src/server/utils/create-ssr-html.tsx index 2c35aa29..ae766b3a 100644 --- a/src/server/utils/create-ssr-html.tsx +++ b/src/server/utils/create-ssr-html.tsx @@ -2,8 +2,8 @@ import { Helmet } from "inferno-helmet"; import { renderToString } from "inferno-server"; import serialize from "serialize-javascript"; import sharp from "sharp"; +import { favIconPngUrl, favIconUrl } from "../../shared/config"; import { ILemmyConfig, IsoDataOptionalSite } from "../../shared/interfaces"; -import { favIconPngUrl, favIconUrl } from "../../shared/utils"; import { fetchIconPng } from "./fetch-icon-png"; const customHtmlHeader = process.env["LEMMY_UI_CUSTOM_HTML_HEADER"] || ""; @@ -77,7 +77,7 @@ export async function createSsrHtml( /> - + diff --git a/src/server/utils/get-error-page-data.ts b/src/server/utils/get-error-page-data.ts index 3c82372f..fc37ccac 100644 --- a/src/server/utils/get-error-page-data.ts +++ b/src/server/utils/get-error-page-data.ts @@ -1,5 +1,5 @@ +import { ErrorPageData } from "@utils/types"; import { GetSiteResponse } from "lemmy-js-client"; -import { ErrorPageData } from "../../shared/utils"; export function getErrorPageData(error: Error, site?: GetSiteResponse) { const errorPageData: ErrorPageData = {}; diff --git a/src/shared/components/app/app.tsx b/src/shared/components/app/app.tsx index 79aa77eb..e50a7070 100644 --- a/src/shared/components/app/app.tsx +++ b/src/shared/components/app/app.tsx @@ -1,10 +1,10 @@ -import { Component, createRef, linkEvent, RefObject } from "inferno"; +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 { isAuthPath, setIsoData } from "../../utils"; +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 191c322b..ec352d42 100644 --- a/src/shared/components/app/error-page.tsx +++ b/src/shared/components/app/error-page.tsx @@ -1,9 +1,9 @@ +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 { setIsoData } from "../../utils"; +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 8ea647c6..6409ef35 100644 --- a/src/shared/components/app/footer.tsx +++ b/src/shared/components/app/footer.tsx @@ -1,8 +1,8 @@ import { Component } from "inferno"; import { NavLink } from "inferno-router"; import { GetSiteResponse } from "lemmy-js-client"; -import { i18n } from "../../i18next"; -import { docsUrl, joinLemmyUrl, repoUrl } from "../../utils"; +import { docsUrl, joinLemmyUrl, repoUrl } from "../../config"; +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 5fa7580c..2ede00e1 100644 --- a/src/shared/components/app/navbar.tsx +++ b/src/shared/components/app/navbar.tsx @@ -1,5 +1,6 @@ +import { myAuth, showAvatars } from "@utils/app"; import { isBrowser } from "@utils/browser"; -import { poll } from "@utils/helpers"; +import { numToSI, poll } from "@utils/helpers"; import { amAdmin, canCreateCommunity } from "@utils/roles"; import { Component, createRef, linkEvent } from "inferno"; import { NavLink } from "inferno-router"; @@ -9,17 +10,10 @@ import { GetUnreadCountResponse, GetUnreadRegistrationApplicationCountResponse, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; -import { UserService } from "../../services"; +import { donateLemmyUrl, updateUnreadCountsInterval } from "../../config"; +import { I18NextService, UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; -import { - donateLemmyUrl, - myAuth, - numToSI, - showAvatars, - toast, - updateUnreadCountsInterval, -} from "../../utils"; +import { toast } from "../../toast"; import { Icon } from "../common/icon"; import { PictrsImage } from "../common/pictrs-image"; @@ -107,7 +101,7 @@ export class Navbar extends Component { { { @@ -167,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" @@ -186,10 +183,10 @@ export class Navbar extends Component { - {i18n.t("communities")} + {I18NextService.i18n.t("communities")}
  • @@ -203,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) && ( @@ -214,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")}
  • @@ -239,12 +236,12 @@ export class Navbar extends Component { - {i18n.t("search")} + {I18NextService.i18n.t("search")} @@ -253,12 +250,12 @@ export class Navbar extends Component { - {i18n.t("admin_settings")} + {I18NextService.i18n.t("admin_settings")} @@ -269,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), })} @@ -294,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), })} @@ -320,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 && ( @@ -362,22 +367,22 @@ export class Navbar extends Component { - {i18n.t("profile")} + {I18NextService.i18n.t("profile")}
  • - {i18n.t("settings")} + {I18NextService.i18n.t("settings")}
  • @@ -389,7 +394,7 @@ export class Navbar extends Component { onClick={linkEvent(this, handleLogOut)} > - {i18n.t("logout")} + {I18NextService.i18n.t("logout")}
  • @@ -402,20 +407,20 @@ export class Navbar extends Component { - {i18n.t("login")} + {I18NextService.i18n.t("login")}
  • - {i18n.t("sign_up")} + {I18NextService.i18n.t("sign_up")}
  • @@ -509,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 2638a40f..294960a8 100644 --- a/src/shared/components/comment/comment-form.tsx +++ b/src/shared/components/comment/comment-form.tsx @@ -1,11 +1,11 @@ +import { myAuthRequired } from "@utils/app"; +import { capitalizeFirstLetter } from "@utils/helpers"; 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 { capitalizeFirstLetter, myAuthRequired } from "../../utils"; +import { I18NextService, UserService } from "../../services"; import { Icon } from "../common/icon"; import { MarkdownTextArea } from "../common/markdown-textarea"; @@ -57,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} /> @@ -78,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 15c68f75..b558d142 100644 --- a/src/shared/components/comment/comment-node.tsx +++ b/src/shared/components/comment/comment-node.tsx @@ -1,3 +1,12 @@ +import { + colorList, + getCommentParentId, + myAuth, + myAuthRequired, + newVote, + showScores, +} from "@utils/app"; +import { futureDaysToUnixTime, numToSI } from "@utils/helpers"; import { amCommunityCreator, canAdmin, @@ -38,7 +47,7 @@ import { TransferCommunity, } from "lemmy-js-client"; import moment from "moment"; -import { i18n } from "../../i18next"; +import { commentTreeMaxDepth } from "../../config"; import { BanType, CommentNodeI, @@ -46,21 +55,9 @@ import { PurgeType, VoteType, } from "../../interfaces"; -import { UserService } from "../../services"; -import { - colorList, - commentTreeMaxDepth, - futureDaysToUnixTime, - getCommentParentId, - mdToHtml, - mdToHtmlNoImages, - myAuth, - myAuthRequired, - newVote, - numToSI, - setupTippy, - showScores, -} from "../../utils"; +import { mdToHtml, mdToHtmlNoImages } from "../../markdown"; +import { I18NextService, UserService } from "../../services"; +import { setupTippy } from "../../tippy"; import { Icon, PurgeWarning, Spinner } from "../common/icon"; import { MomentTime } from "../common/moment-time"; import { CommunityLink } from "../community/community-link"; @@ -243,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, @@ -316,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")} @@ -368,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 ? ( @@ -458,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 ? ( @@ -485,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 ? ( @@ -508,8 +505,8 @@ export class CommentNode extends Component { @@ -517,8 +514,8 @@ export class CommentNode extends Component { @@ -529,7 +526,9 @@ export class CommentNode extends Component { @@ -539,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")} > @@ -552,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 ? ( @@ -567,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 ? ( @@ -587,8 +594,10 @@ export class CommentNode extends Component { @@ -615,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 ? ( @@ -645,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")} ) : ( )} @@ -707,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" + )} ) : ( ))} @@ -737,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")} ) : ( <> ))} @@ -792,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")} ) : ( <> ))} @@ -842,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) ? ( @@ -864,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")} ) : ( )} @@ -897,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" + )} ) : ( <> ))} @@ -963,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 @@ -985,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")} )} @@ -1013,23 +1050,23 @@ export class CommentNode extends Component { className="visually-hidden" htmlFor={`report-reason-${cv.comment.id}`} > - {i18n.t("reason")} + {I18NextService.i18n.t("reason")} )} @@ -1040,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")} @@ -1054,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")} @@ -1076,9 +1113,9 @@ export class CommentNode extends Component {
    @@ -1086,19 +1123,19 @@ export class CommentNode extends Component { {/* TODO hold off on expires until later */} {/*
    */} {/* */} - {/* */} + {/* */} {/*
    */}
    @@ -1110,13 +1147,13 @@ export class CommentNode extends Component {
    @@ -1211,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; @@ -1257,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), }); @@ -1276,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-nodes.tsx b/src/shared/components/comment/comment-nodes.tsx index 8c0a236e..02e621b7 100644 --- a/src/shared/components/comment/comment-nodes.tsx +++ b/src/shared/components/comment/comment-nodes.tsx @@ -1,3 +1,4 @@ +import { colorList } from "@utils/app"; import classNames from "classnames"; import { Component } from "inferno"; import { @@ -26,7 +27,6 @@ import { TransferCommunity, } from "lemmy-js-client"; import { CommentNodeI, CommentViewType } from "../../interfaces"; -import { colorList } from "../../utils"; import { CommentNode } from "./comment-node"; interface CommentNodesProps { diff --git a/src/shared/components/comment/comment-report.tsx b/src/shared/components/comment/comment-report.tsx index 2f765e03..3b328f67 100644 --- a/src/shared/components/comment/comment-report.tsx +++ b/src/shared/components/comment/comment-report.tsx @@ -1,3 +1,4 @@ +import { myAuthRequired } from "@utils/app"; import { Component, InfernoNode, linkEvent } from "inferno"; import { T } from "inferno-i18next-dess"; import { @@ -5,9 +6,8 @@ import { CommentView, ResolveCommentReport, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; import { CommentNodeI, CommentViewType } from "../../interfaces"; -import { myAuthRequired } from "../../utils"; +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 17ae53fb..c1eeed46 100644 --- a/src/shared/components/common/badges.tsx +++ b/src/shared/components/common/badges.tsx @@ -1,11 +1,11 @@ +import { numToSI } from "@utils/helpers"; import { Link } from "inferno-router"; import { CommunityAggregates, CommunityId, SiteAggregates, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; -import { numToSI } from "../../utils"; +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 e9885afa..ad4eebfe 100644 --- a/src/shared/components/common/comment-sort-select.tsx +++ b/src/shared/components/common/comment-sort-select.tsx @@ -1,7 +1,8 @@ +import { randomStr } from "@utils/helpers"; import { Component, linkEvent } from "inferno"; import { CommentSortType } from "lemmy-js-client"; -import { i18n } from "../../i18next"; -import { randomStr, relTags, sortingHelpUrl } from "../../utils"; +import { relTags, sortingHelpUrl } from "../../config"; +import { I18NextService } from "../../services"; import { Icon } from "./icon"; interface CommentSortSelectProps { @@ -41,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-mart.tsx b/src/shared/components/common/emoji-mart.tsx index dff8c3ac..6ee3aa83 100644 --- a/src/shared/components/common/emoji-mart.tsx +++ b/src/shared/components/common/emoji-mart.tsx @@ -1,5 +1,5 @@ import { Component } from "inferno"; -import { getEmojiMart } from "../../utils"; +import { getEmojiMart } from "../../markdown"; interface EmojiMartProps { onEmojiClick?(val: any): any; diff --git a/src/shared/components/common/emoji-picker.tsx b/src/shared/components/common/emoji-picker.tsx index a7fc7d4f..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 && ( @@ -304,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")} )}
    @@ -336,8 +335,8 @@ export class MarkdownTextArea extends Component< return (
    ); diff --git a/src/shared/components/common/progress-bar.tsx b/src/shared/components/common/progress-bar.tsx index 88aee7ed..f9cde3ea 100644 --- a/src/shared/components/common/progress-bar.tsx +++ b/src/shared/components/common/progress-bar.tsx @@ -1,5 +1,5 @@ +import { ThemeColor } from "@utils/types"; import classNames from "classnames"; -import { ThemeColor } from "../../utils"; interface ProgressBarProps { className?: string; diff --git a/src/shared/components/common/registration-application.tsx b/src/shared/components/common/registration-application.tsx index d81af3b6..3857c49e 100644 --- a/src/shared/components/common/registration-application.tsx +++ b/src/shared/components/common/registration-application.tsx @@ -1,11 +1,12 @@ +import { myAuthRequired } from "@utils/app"; import { Component, InfernoNode, linkEvent } from "inferno"; import { T } from "inferno-i18next-dess"; import { ApproveRegistrationApplication, RegistrationApplicationView, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; -import { mdToHtml, myAuthRequired } from "../../utils"; +import { mdToHtml } from "../../markdown"; +import { I18NextService } from "../../services"; import { PersonListing } from "../person/person-listing"; import { Spinner } from "./icon"; import { MarkdownTextArea } from "./markdown-textarea"; @@ -60,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 && ( @@ -83,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 1d98de3d..a29fe160 100644 --- a/src/shared/components/common/searchable-select.tsx +++ b/src/shared/components/common/searchable-select.tsx @@ -1,3 +1,4 @@ +import { Choice } from "@utils/types"; import classNames from "classnames"; import { ChangeEvent, @@ -6,8 +7,7 @@ import { linkEvent, RefObject, } from "inferno"; -import { i18n } from "../../i18next"; -import { Choice } from "../../utils"; +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 7b275718..90515d56 100644 --- a/src/shared/components/common/sort-select.tsx +++ b/src/shared/components/common/sort-select.tsx @@ -1,7 +1,8 @@ +import { randomStr } from "@utils/helpers"; import { Component, linkEvent } from "inferno"; import { SortType } from "lemmy-js-client"; -import { i18n } from "../../i18next"; -import { randomStr, relTags, sortingHelpUrl } from "../../utils"; +import { relTags, sortingHelpUrl } from "../../config"; +import { I18NextService } from "../../services"; import { Icon } from "./icon"; interface SortSelectProps { @@ -40,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 bf897823..a84ec055 100644 --- a/src/shared/components/community/communities.tsx +++ b/src/shared/components/community/communities.tsx @@ -1,5 +1,18 @@ -import { getQueryParams, getQueryString } from "@utils/helpers"; +import { + editCommunity, + myAuth, + myAuthRequired, + setIsoData, + showLocal, +} from "@utils/app"; +import { + getPageFromString, + getQueryParams, + getQueryString, + numToSI, +} from "@utils/helpers"; import type { QueryParams } from "@utils/types"; +import { RouteDataResponse } from "@utils/types"; import { Component, linkEvent } from "inferno"; import { CommunityResponse, @@ -8,20 +21,9 @@ 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 { - RouteDataResponse, - editCommunity, - getPageFromString, - myAuth, - myAuthRequired, - numToSI, - setIsoData, - showLocal, -} from "../../utils"; import { HtmlTags } from "../common/html-tags"; import { Spinner } from "../common/icon"; import { ListingTypeSelect } from "../common/listing-type-select"; @@ -83,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 }`; } @@ -100,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")} @@ -166,7 +173,7 @@ export class Communities extends Component { this.handleFollow )} > - {i18n.t("unsubscribe")} + {I18NextService.i18n.t("unsubscribe")} )} {cv.subscribed === "NotSubscribed" && ( @@ -181,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")}
    )} @@ -227,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} @@ -235,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 655a0752..6e2eba5a 100644 --- a/src/shared/components/community/community-form.tsx +++ b/src/shared/components/community/community-form.tsx @@ -1,3 +1,5 @@ +import { myAuthRequired } from "@utils/app"; +import { capitalizeFirstLetter, randomStr } from "@utils/helpers"; import { Component, linkEvent } from "inferno"; import { CommunityView, @@ -5,8 +7,7 @@ import { EditCommunity, Language, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; -import { capitalizeFirstLetter, myAuthRequired, randomStr } from "../../utils"; +import { I18NextService } from "../../services"; import { Icon, Spinner } from "../common/icon"; import { ImageUploadForm } from "../common/image-upload-form"; import { LanguageSelect } from "../common/language-select"; @@ -106,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")} @@ -124,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")} />
    @@ -134,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")} @@ -157,11 +158,11 @@ export class CommunityForm extends Component<
    - {i18n.t("nsfw")} + {I18NextService.i18n.t("nsfw")}
    @@ -218,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")}
    @@ -253,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 && ( @@ -264,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-link.tsx b/src/shared/components/community/community-link.tsx index 4f45a2b5..95833333 100644 --- a/src/shared/components/community/community-link.tsx +++ b/src/shared/components/community/community-link.tsx @@ -1,7 +1,9 @@ +import { showAvatars } from "@utils/app"; +import { hostname } from "@utils/helpers"; import { Component } from "inferno"; import { Link } from "inferno-router"; import { Community } from "lemmy-js-client"; -import { hostname, relTags, showAvatars } from "../../utils"; +import { relTags } from "../../config"; import { PictrsImage } from "../common/pictrs-image"; interface CommunityLinkProps { diff --git a/src/shared/components/community/community.tsx b/src/shared/components/community/community.tsx index e03b6990..7eefe0eb 100644 --- a/src/shared/components/community/community.tsx +++ b/src/shared/components/community/community.tsx @@ -1,5 +1,28 @@ -import { getQueryParams, getQueryString } from "@utils/helpers"; +import { + commentsToFlatNodes, + communityRSSUrl, + editComment, + editPost, + editWith, + enableDownvotes, + enableNsfw, + getCommentParentId, + getDataTypeString, + myAuth, + postToCommentSortType, + setIsoData, + showLocal, + updateCommunityBlock, + updatePersonBlock, +} from "@utils/app"; +import { restoreScrollPosition, saveScrollPosition } from "@utils/browser"; +import { + getPageFromString, + getQueryParams, + getQueryString, +} from "@utils/helpers"; import type { QueryParams } from "@utils/types"; +import { RouteDataResponse } from "@utils/types"; import { Component, linkEvent } from "inferno"; import { RouteComponentProps } from "inferno-router/dist/Route"; import { @@ -54,40 +77,16 @@ import { SortType, TransferCommunity, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; +import { fetchLimit, relTags } from "../../config"; 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 { - RouteDataResponse, - commentsToFlatNodes, - communityRSSUrl, - editComment, - editPost, - editWith, - enableDownvotes, - enableNsfw, - fetchLimit, - getCommentParentId, - getDataTypeString, - getPageFromString, - myAuth, - postToCommentSortType, - relTags, - restoreScrollPosition, - saveScrollPosition, - setIsoData, - setupTippy, - showLocal, - toast, - updateCommunityBlock, - updatePersonBlock, -} from "../../utils"; +import { setupTippy } from "../../tippy"; +import { toast } from "../../toast"; import { CommentNodes } from "../comment/comment-nodes"; import { BannerIconHeader } from "../common/banner-icon-header"; import { DataTypeSelect } from "../common/data-type-select"; @@ -330,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 a061ff0d..2ce5af5a 100644 --- a/src/shared/components/community/create-community.tsx +++ b/src/shared/components/community/create-community.tsx @@ -1,11 +1,10 @@ +import { enableNsfw, setIsoData } from "@utils/app"; import { Component } from "inferno"; import { CreateCommunity as CreateCommunityI, GetSiteResponse, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; -import { HttpService } from "../../services/HttpService"; -import { enableNsfw, setIsoData } from "../../utils"; +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")} )} @@ -198,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")} )} @@ -232,7 +233,7 @@ export class Sidebar extends Component { mods() { return (
      -
    • {i18n.t("mods")}:
    • +
    • {I18NextService.i18n.t("mods")}:
    • {this.props.moderators.map(mod => (
    • @@ -251,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")} ); } @@ -268,7 +269,7 @@ export class Sidebar extends Component { {this.state.followCommunityLoading ? ( ) : ( - i18n.t("subscribe") + I18NextService.i18n.t("subscribe") )} )} @@ -286,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" + )} )} @@ -313,8 +316,8 @@ export class Sidebar extends Component { @@ -329,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")}
    • @@ -353,7 +356,7 @@ export class Sidebar extends Component { this.handleCancelLeaveModTeamClick )} > - {i18n.t("no")} + {I18NextService.i18n.t("no")}
    • @@ -365,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 ? ( @@ -396,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")} ) : ( )} )} @@ -424,13 +427,13 @@ export class Sidebar extends Component {
      @@ -438,14 +441,14 @@ export class Sidebar extends Component { {/* TODO hold off on expires for now */} {/*
      */} {/* */} - {/* */} + {/* */} {/*
      */}
      @@ -458,13 +461,13 @@ export class Sidebar extends Component {
      @@ -476,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 23454ab9..7ac69fed 100644 --- a/src/shared/components/home/admin-settings.tsx +++ b/src/shared/components/home/admin-settings.tsx @@ -1,3 +1,11 @@ +import { + fetchThemeList, + myAuthRequired, + setIsoData, + showLocal, +} from "@utils/app"; +import { capitalizeFirstLetter } from "@utils/helpers"; +import { RouteDataResponse } from "@utils/types"; import classNames from "classnames"; import { Component, linkEvent } from "inferno"; import { @@ -10,21 +18,11 @@ import { GetSiteResponse, PersonView, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; import { InitialFetchRequest } from "../../interfaces"; -import { FirstLoadService } from "../../services/FirstLoadService"; +import { removeFromEmojiDataModel, updateEmojiDataModel } from "../../markdown"; +import { FirstLoadService, I18NextService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; -import { - RouteDataResponse, - capitalizeFirstLetter, - fetchThemeList, - myAuthRequired, - removeFromEmojiDataModel, - setIsoData, - showLocal, - toast, - updateEmojiDataModel, -} from "../../utils"; +import { toast } from "../../toast"; import { HtmlTags } from "../common/html-tags"; import { Spinner } from "../common/icon"; import Tabs from "../common/tabs"; @@ -109,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 }`; } @@ -130,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 => (
      • @@ -276,7 +274,7 @@ export class AdminSettings extends Component { {this.state.leaveAdminTeamRes.state == "loading" ? ( ) : ( - i18n.t("leave_admin_team") + I18NextService.i18n.t("leave_admin_team") )} ); @@ -294,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 => (
        • @@ -320,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 }); @@ -341,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 ac07ba11..8428a54f 100644 --- a/src/shared/components/home/emojis-form.tsx +++ b/src/shared/components/home/emojis-form.tsx @@ -1,3 +1,4 @@ +import { myAuthRequired, setIsoData } from "@utils/app"; import { Component, linkEvent } from "inferno"; import { CreateCustomEmoji, @@ -5,15 +6,9 @@ import { EditCustomEmoji, GetSiteResponse, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; -import { HttpService } from "../../services/HttpService"; -import { - customEmojisLookup, - myAuthRequired, - pictrsDeleteToast, - setIsoData, - toast, -} from "../../utils"; +import { customEmojisLookup } from "../../markdown"; +import { HttpService, I18NextService } from "../../services"; +import { pictrsDeleteToast, toast } from "../../toast"; import { EmojiMart } from "../common/emoji-mart"; import { HtmlTags } from "../common/html-tags"; import { Icon } from "../common/icon"; @@ -70,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() { @@ -80,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 && (
          { - - - - + + + + - @@ -219,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) || @@ -240,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")} @@ -284,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 4270bd0b..0d91bdbc 100644 --- a/src/shared/components/home/home.tsx +++ b/src/shared/components/home/home.tsx @@ -1,6 +1,28 @@ -import { getQueryParams, getQueryString } from "@utils/helpers"; +import { + commentsToFlatNodes, + editComment, + editPost, + editWith, + enableDownvotes, + enableNsfw, + getCommentParentId, + getDataTypeString, + myAuth, + postToCommentSortType, + setIsoData, + showLocal, + updatePersonBlock, +} from "@utils/app"; +import { restoreScrollPosition, saveScrollPosition } from "@utils/browser"; +import { + getPageFromString, + getQueryParams, + getQueryString, + getRandomFromList, +} from "@utils/helpers"; import { canCreateCommunity } from "@utils/roles"; import type { QueryParams } from "@utils/types"; +import { RouteDataResponse } from "@utils/types"; import { NoOptionI18nKeys } from "i18next"; import { Component, MouseEventHandler, linkEvent } from "inferno"; import { T } from "inferno-i18next-dess"; @@ -50,41 +72,17 @@ import { SortType, TransferCommunity, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; +import { fetchLimit, relTags, trendingFetchLimit } from "../../config"; import { CommentViewType, DataType, InitialFetchRequest, } from "../../interfaces"; -import { UserService } from "../../services"; -import { FirstLoadService } from "../../services/FirstLoadService"; +import { mdToHtml } from "../../markdown"; +import { FirstLoadService, I18NextService, UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; -import { - RouteDataResponse, - commentsToFlatNodes, - editComment, - editPost, - editWith, - enableDownvotes, - enableNsfw, - fetchLimit, - getCommentParentId, - getDataTypeString, - getPageFromString, - getRandomFromList, - mdToHtml, - myAuth, - postToCommentSortType, - relTags, - restoreScrollPosition, - saveScrollPosition, - setIsoData, - setupTippy, - showLocal, - toast, - trendingFetchLimit, - updatePersonBlock, -} from "../../utils"; +import { setupTippy } from "../../tippy"; +import { toast } from "../../toast"; import { CommentNodes } from "../comment/comment-nodes"; import { DataTypeSelect } from "../common/data-type-select"; import { HtmlTags } from "../common/html-tags"; @@ -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 2d8d8d5d..b54c96af 100644 --- a/src/shared/components/home/instances.tsx +++ b/src/shared/components/home/instances.tsx @@ -1,14 +1,15 @@ +import { setIsoData } from "@utils/app"; +import { RouteDataResponse } from "@utils/types"; import { Component } from "inferno"; import { GetFederatedInstancesResponse, GetSiteResponse, Instance, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; +import { relTags } from "../../config"; import { InitialFetchRequest } from "../../interfaces"; -import { FirstLoadService } from "../../services/FirstLoadService"; +import { FirstLoadService, I18NextService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; -import { RouteDataResponse, relTags, setIsoData } from "../../utils"; import { HtmlTags } from "../common/html-tags"; import { Spinner } from "../common/icon"; @@ -68,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() { @@ -84,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)}
          )} @@ -125,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")}
          - - - + + + @@ -146,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 be11fd75..85a413eb 100644 --- a/src/shared/components/home/legal.tsx +++ b/src/shared/components/home/legal.tsx @@ -1,7 +1,8 @@ +import { setIsoData } from "@utils/app"; import { Component } from "inferno"; import { GetSiteResponse } from "lemmy-js-client"; -import { i18n } from "../../i18next"; -import { mdToHtml, setIsoData } from "../../utils"; +import { mdToHtml } from "../../markdown"; +import { I18NextService } from "../../services"; import { HtmlTags } from "../common/html-tags"; interface LegalState { @@ -19,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 1601750e..1853a82b 100644 --- a/src/shared/components/home/login.tsx +++ b/src/shared/components/home/login.tsx @@ -1,10 +1,11 @@ +import { myAuth, setIsoData } from "@utils/app"; 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 { myAuth, setIsoData, toast, validEmail } from "../../utils"; +import { toast } from "../../toast"; import { HtmlTags } from "../common/html-tags"; import { Spinner } from "../common/icon"; @@ -41,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 { @@ -66,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")}
          @@ -122,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") )}
          @@ -170,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 } }); @@ -218,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 11c1a8e8..9003962a 100644 --- a/src/shared/components/home/rate-limit-form.tsx +++ b/src/shared/components/home/rate-limit-form.tsx @@ -1,8 +1,9 @@ +import { myAuthRequired } from "@utils/app"; +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 { capitalizeFirstLetter, myAuthRequired } from "../../utils"; +import { I18NextService } from "../../services"; import { Spinner } from "../common/icon"; import Tabs from "../common/tabs"; @@ -56,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 3b71047d..bed12620 100644 --- a/src/shared/components/home/setup.tsx +++ b/src/shared/components/home/setup.tsx @@ -1,3 +1,4 @@ +import { fetchThemeList, setIsoData } from "@utils/app"; import { Component, linkEvent } from "inferno"; import { Helmet } from "inferno-helmet"; import { @@ -6,10 +7,8 @@ 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 { fetchThemeList, setIsoData } from "../../utils"; 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 7d504184..a2d960dc 100644 --- a/src/shared/components/home/signup.tsx +++ b/src/shared/components/home/signup.tsx @@ -1,4 +1,6 @@ +import { myAuth, setIsoData } from "@utils/app"; import { isBrowser } from "@utils/browser"; +import { validEmail } from "@utils/helpers"; import { Options, passwordStrength } from "check-password-strength"; import { NoOptionI18nKeys } from "i18next"; import { Component, linkEvent } from "inferno"; @@ -10,17 +12,11 @@ import { LoginResponse, SiteView, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; -import { UserService } from "../../services"; +import { joinLemmyUrl } from "../../config"; +import { mdToHtml } from "../../markdown"; +import { I18NextService, UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; -import { - joinLemmyUrl, - mdToHtml, - myAuth, - setIsoData, - toast, - validEmail, -} from "../../utils"; +import { toast } from "../../toast"; import { HtmlTags } from "../common/html-tags"; import { Icon, Spinner } from "../common/icon"; import { MarkdownTextArea } from "../common/markdown-textarea"; @@ -116,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" ); } @@ -162,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")}
          @@ -175,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" @@ -205,7 +201,7 @@ export class Signup extends Component { !validEmail(this.state.form.email) && (
          - {i18n.t("no_password_reset")} + {I18NextService.i18n.t("no_password_reset")}
          )}
          @@ -216,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 + )}
          )}
          @@ -243,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)} />
          @@ -348,12 +346,14 @@ export class Signup extends Component { return (
          @@ -263,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")}
          @@ -334,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")}
          @@ -356,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")}
          @@ -375,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")}
          @@ -386,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")}
          @@ -540,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")}
          @@ -550,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")}
      @@ -594,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")}
      @@ -619,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")) )}
    @@ -637,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 dfd13514..c79d9554 100644 --- a/src/shared/components/home/tagline-form.tsx +++ b/src/shared/components/home/tagline-form.tsx @@ -1,7 +1,8 @@ +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 { capitalizeFirstLetter, myAuthRequired } from "../../utils"; +import { I18NextService } from "../../services"; import { HtmlTags } from "../common/html-tags"; import { Icon, Spinner } from "../common/icon"; import { MarkdownTextArea } from "../common/markdown-textarea"; @@ -26,7 +27,7 @@ export class TaglineForm extends Component { super(props, context); } get documentTitle(): string { - return i18n.t("taglines"); + return I18NextService.i18n.t("taglines"); } render() { @@ -36,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")}
      @@ -67,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")} > @@ -79,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")} > @@ -95,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")} @@ -110,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 91da558f..e705bac8 100644 --- a/src/shared/components/modlog.tsx +++ b/src/shared/components/modlog.tsx @@ -1,6 +1,20 @@ -import { debounce, getQueryParams, getQueryString } from "@utils/helpers"; +import { + fetchUsers, + getUpdatedSearchId, + myAuth, + personToChoice, + setIsoData, +} from "@utils/app"; +import { + debounce, + getIdFromString, + getPageFromString, + getQueryParams, + getQueryString, +} from "@utils/helpers"; import { amAdmin, amMod } from "@utils/roles"; import type { QueryParams } from "@utils/types"; +import { Choice, RouteDataResponse } from "@utils/types"; import { NoOptionI18nKeys } from "i18next"; import { Component, linkEvent } from "inferno"; import { T } from "inferno-i18next-dess"; @@ -31,22 +45,10 @@ import { Person, } from "lemmy-js-client"; import moment from "moment"; -import { i18n } from "../i18next"; +import { fetchLimit } from "../config"; import { InitialFetchRequest } from "../interfaces"; -import { FirstLoadService } from "../services/FirstLoadService"; +import { FirstLoadService, I18NextService } from "../services"; import { HttpService, RequestState } from "../services/HttpService"; -import { - Choice, - RouteDataResponse, - fetchLimit, - fetchUsers, - getIdFromString, - getPageFromString, - getUpdatedSearchId, - myAuth, - personToChoice, - setIsoData, -} from "../utils"; import { HtmlTags } from "./common/html-tags"; import { Icon, Spinner } from "./common/icon"; import { MomentTime } from "./common/moment-time"; @@ -583,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 { @@ -767,7 +769,7 @@ export class Modlog extends Component< > /c/{this.state.communityRes.data.community_view.community.name}{" "} - {i18n.t("modlog")} + {I18NextService.i18n.t("modlog")} )}
      @@ -779,9 +781,9 @@ export class Modlog extends Component< aria-label="action" > - + @@ -845,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 415c3e3f..062fc01c 100644 --- a/src/shared/components/person/inbox.tsx +++ b/src/shared/components/person/inbox.tsx @@ -1,3 +1,17 @@ +import { + commentsToFlatNodes, + editCommentReply, + editMention, + editPrivateMessage, + editWith, + enableDownvotes, + getCommentParentId, + myAuth, + myAuthRequired, + setIsoData, + updatePersonBlock, +} from "@utils/app"; +import { RouteDataResponse } from "@utils/types"; import { Component, linkEvent } from "inferno"; import { AddAdmin, @@ -44,28 +58,11 @@ import { SaveComment, TransferCommunity, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; +import { fetchLimit, relTags } from "../../config"; 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 { - RouteDataResponse, - commentsToFlatNodes, - editCommentReply, - editMention, - editPrivateMessage, - editWith, - enableDownvotes, - fetchLimit, - getCommentParentId, - myAuth, - myAuthRequired, - relTags, - setIsoData, - toast, - updatePersonBlock, -} from "../../utils"; +import { toast } from "../../toast"; import { CommentNodes } from "../comment/comment-nodes"; import { CommentSortSelect } from "../common/comment-sort-select"; import { HtmlTags } from "../common/html-tags"; @@ -188,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}` : ""; } @@ -224,7 +221,7 @@ export class Inbox extends Component { path={this.context.router.route.match.url} />
      - {i18n.t("inbox")} + {I18NextService.i18n.t("inbox")} {inboxRss && ( @@ -246,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") )} )} @@ -297,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")} ); @@ -332,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")} ); @@ -827,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); } @@ -838,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"); @@ -850,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); } } @@ -858,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); } } @@ -893,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) { @@ -1005,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(`/`); } } @@ -1014,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 3977feb4..dd85e05b 100644 --- a/src/shared/components/person/password-change.tsx +++ b/src/shared/components/person/password-change.tsx @@ -1,9 +1,9 @@ +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 { capitalizeFirstLetter, myAuth, setIsoData } from "../../utils"; import { HtmlTags } from "../common/html-tags"; import { Spinner } from "../common/icon"; @@ -33,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 }`; } @@ -47,7 +47,7 @@ export class PasswordChange extends Component { />
      -
      {i18n.t("password_change")}
      +
      {I18NextService.i18n.t("password_change")}
      {this.passwordChangeForm()}
      @@ -60,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/person-details.tsx b/src/shared/components/person/person-details.tsx index 6efebaa1..3771b844 100644 --- a/src/shared/components/person/person-details.tsx +++ b/src/shared/components/person/person-details.tsx @@ -1,3 +1,4 @@ +import { commentsToFlatNodes } from "@utils/app"; import { Component } from "inferno"; import { AddAdmin, @@ -37,7 +38,7 @@ import { TransferCommunity, } from "lemmy-js-client"; import { CommentViewType, PersonDetailsView } from "../../interfaces"; -import { commentsToFlatNodes, setupTippy } from "../../utils"; +import { setupTippy } from "../../tippy"; import { CommentNodes } from "../comment/comment-nodes"; import { Paginator } from "../common/paginator"; import { PostListing } from "../post/post-listing"; diff --git a/src/shared/components/person/person-listing.tsx b/src/shared/components/person/person-listing.tsx index cf3802c4..6631a8ea 100644 --- a/src/shared/components/person/person-listing.tsx +++ b/src/shared/components/person/person-listing.tsx @@ -1,8 +1,10 @@ +import { showAvatars } from "@utils/app"; +import { hostname, isCakeDay } from "@utils/helpers"; import classNames from "classnames"; import { Component } from "inferno"; import { Link } from "inferno-router"; import { Person } from "lemmy-js-client"; -import { hostname, isCakeDay, relTags, showAvatars } from "../../utils"; +import { relTags } from "../../config"; import { PictrsImage } from "../common/pictrs-image"; import { CakeDay } from "./cake-day"; diff --git a/src/shared/components/person/profile.tsx b/src/shared/components/person/profile.tsx index 6f6ede3e..d0003687 100644 --- a/src/shared/components/person/profile.tsx +++ b/src/shared/components/person/profile.tsx @@ -1,6 +1,27 @@ -import { getQueryParams, getQueryString } from "@utils/helpers"; +import { + editComment, + editPost, + editWith, + enableDownvotes, + enableNsfw, + getCommentParentId, + myAuth, + myAuthRequired, + setIsoData, + updatePersonBlock, +} from "@utils/app"; +import { restoreScrollPosition, saveScrollPosition } from "@utils/browser"; +import { + capitalizeFirstLetter, + futureDaysToUnixTime, + getPageFromString, + getQueryParams, + getQueryString, + numToSI, +} from "@utils/helpers"; import { canMod, isAdmin, isBanned } from "@utils/roles"; import type { QueryParams } from "@utils/types"; +import { RouteDataResponse } from "@utils/types"; import classNames from "classnames"; import { NoOptionI18nKeys } from "i18next"; import { Component, linkEvent } from "inferno"; @@ -50,35 +71,13 @@ import { TransferCommunity, } from "lemmy-js-client"; import moment from "moment"; -import { i18n } from "../../i18next"; +import { fetchLimit, relTags } from "../../config"; import { InitialFetchRequest, PersonDetailsView } from "../../interfaces"; -import { UserService } from "../../services"; -import { FirstLoadService } from "../../services/FirstLoadService"; +import { mdToHtml } from "../../markdown"; +import { FirstLoadService, I18NextService, UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; -import { - RouteDataResponse, - capitalizeFirstLetter, - editComment, - editPost, - editWith, - enableDownvotes, - enableNsfw, - fetchLimit, - futureDaysToUnixTime, - getCommentParentId, - getPageFromString, - mdToHtml, - myAuth, - myAuthRequired, - numToSI, - relTags, - restoreScrollPosition, - saveScrollPosition, - setIsoData, - setupTippy, - toast, - updatePersonBlock, -} from "../../utils"; +import { setupTippy } from "../../tippy"; +import { toast } from "../../toast"; import { BannerIconHeader } from "../common/banner-icon-header"; import { HtmlTags } from "../common/html-tags"; import { Icon, Spinner } from "../common/icon"; @@ -136,7 +135,7 @@ const getCommunitiesListing = ( communityViews.length > 0 && (
      -
      {i18n.t(translationKey)}
      +
      {I18NextService.i18n.t(translationKey)}
        {communityViews.map(({ community }) => (
      • @@ -421,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)} ); } @@ -484,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()}
      • )}
      @@ -515,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 ? ( ) : ( )} @@ -562,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"))} ) : ( ))}
      @@ -589,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), })} @@ -603,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() @@ -622,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")}
      )}
      @@ -640,24 +639,24 @@ export class Profile extends Component<
      @@ -673,9 +672,9 @@ export class Profile extends Component<
      @@ -683,23 +682,23 @@ export class Profile extends Component< {/* TODO hold off on expires until later */} {/*
      */} {/* */} - {/* */} + {/* */} {/*
      */}
      @@ -903,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")); } } @@ -934,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) { @@ -998,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 23b27b37..d9eb6ad0 100644 --- a/src/shared/components/person/registration-applications.tsx +++ b/src/shared/components/person/registration-applications.tsx @@ -1,3 +1,9 @@ +import { + editRegistrationApplication, + myAuthRequired, + setIsoData, +} from "@utils/app"; +import { RouteDataResponse } from "@utils/types"; import { Component, linkEvent } from "inferno"; import { ApproveRegistrationApplication, @@ -5,19 +11,11 @@ import { ListRegistrationApplicationsResponse, RegistrationApplicationView, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; +import { fetchLimit } from "../../config"; 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 { - RouteDataResponse, - editRegistrationApplication, - fetchLimit, - myAuthRequired, - setIsoData, - setupTippy, -} from "../../utils"; +import { setupTippy } from "../../tippy"; import { HtmlTags } from "../common/html-tags"; import { Spinner } from "../common/icon"; import { Paginator } from "../common/paginator"; @@ -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 e3d100c7..8f5eaf36 100644 --- a/src/shared/components/person/reports.tsx +++ b/src/shared/components/person/reports.tsx @@ -1,4 +1,12 @@ +import { + editCommentReport, + editPostReport, + editPrivateMessageReport, + myAuthRequired, + setIsoData, +} from "@utils/app"; import { amAdmin } from "@utils/roles"; +import { RouteDataResponse } from "@utils/types"; import { Component, linkEvent } from "inferno"; import { CommentReportResponse, @@ -18,20 +26,15 @@ import { ResolvePostReport, ResolvePrivateMessageReport, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; +import { fetchLimit } from "../../config"; import { InitialFetchRequest } from "../../interfaces"; -import { HttpService, UserService } from "../../services"; -import { FirstLoadService } from "../../services/FirstLoadService"; -import { RequestState } from "../../services/HttpService"; import { - RouteDataResponse, - editCommentReport, - editPostReport, - editPrivateMessageReport, - fetchLimit, - myAuthRequired, - setIsoData, -} from "../../utils"; + FirstLoadService, + HttpService, + I18NextService, + UserService, +} from "../../services"; +import { RequestState } from "../../services/HttpService"; import { CommentReport } from "../comment/comment-report"; import { HtmlTags } from "../common/html-tags"; import { Spinner } from "../common/icon"; @@ -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 9acba57a..dc542e72 100644 --- a/src/shared/components/person/settings.tsx +++ b/src/shared/components/person/settings.tsx @@ -1,4 +1,19 @@ -import { debounce } from "@utils/helpers"; +import { + communityToChoice, + fetchCommunities, + fetchThemeList, + fetchUsers, + myAuth, + myAuthRequired, + personToChoice, + setIsoData, + setTheme, + showLocal, + updateCommunityBlock, + updatePersonBlock, +} from "@utils/app"; +import { capitalizeFirstLetter, debounce } from "@utils/helpers"; +import { Choice } from "@utils/types"; import classNames from "classnames"; import { NoOptionI18nKeys } from "i18next"; import { Component, linkEvent } from "inferno"; @@ -13,30 +28,12 @@ import { PersonBlockView, SortType, } from "lemmy-js-client"; -import { i18n, languages } from "../../i18next"; +import { elementUrl, emDash, relTags } from "../../config"; import { UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; -import { - Choice, - capitalizeFirstLetter, - communityToChoice, - elementUrl, - emDash, - fetchCommunities, - fetchThemeList, - fetchUsers, - myAuth, - myAuthRequired, - personToChoice, - relTags, - setIsoData, - setTheme, - setupTippy, - showLocal, - toast, - updateCommunityBlock, - updatePersonBlock, -} from "../../utils"; +import { I18NextService, languages } from "../../services/I18NextService"; +import { setupTippy } from "../../tippy"; +import { toast } from "../../toast"; import { HtmlTags } from "../common/html-tags"; import { Icon, Spinner } from "../common/icon"; import { ImageUploadForm } from "../common/image-upload-form"; @@ -116,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() { @@ -252,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, }, ]} @@ -319,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")) )}
      @@ -412,7 +409,7 @@ export class Settings extends Component { blockedUsersList() { return ( <> -
      {i18n.t("blocked_users")}
      +
      {I18NextService.i18n.t("blocked_users")}
        {this.state.personBlocks.map(pb => (
      • @@ -424,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")} > @@ -456,7 +453,7 @@ export class Settings extends Component { blockedCommunitiesList() { return ( <> -
        {i18n.t("blocked_communities")}
        +
        {I18NextService.i18n.t("blocked_communities")}
          {this.state.communityBlocks.map(cb => (
        • @@ -468,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" + )} > @@ -485,18 +484,18 @@ export class Settings extends Component { return ( <> -
          {i18n.t("settings")}
          +
          {I18NextService.i18n.t("settings")}
          {
          {
          {
          @@ -555,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)} />
          @@ -691,7 +696,7 @@ export class Settings extends Component { onChange={linkEvent(this, this.handleShowScoresChange)} />
          @@ -705,7 +710,7 @@ export class Settings extends Component { onChange={linkEvent(this, this.handleShowAvatarsChange)} />
          @@ -719,7 +724,7 @@ export class Settings extends Component { onChange={linkEvent(this, this.handleBotAccount)} />
          @@ -736,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")}
      @@ -753,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")}
      @@ -770,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")}
      @@ -793,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")} @@ -803,7 +808,7 @@ export class Settings extends Component { {this.state.saveRes.state === "loading" ? ( ) : ( - capitalizeFirstLetter(i18n.t("save")) + capitalizeFirstLetter(I18NextService.i18n.t("save")) )} @@ -816,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")) )} )} @@ -879,7 +884,7 @@ export class Settings extends Component { onChange={linkEvent(this, this.handleGenerateTotp)} /> @@ -889,7 +894,7 @@ export class Settings extends Component { <>
      @@ -904,7 +909,7 @@ export class Settings extends Component { onChange={linkEvent(this, this.handleRemoveTotp)} />
      @@ -1053,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)); } @@ -1081,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) @@ -1171,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); } @@ -1194,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 c4687c00..1800c3f2 100644 --- a/src/shared/components/person/verify-email.tsx +++ b/src/shared/components/person/verify-email.tsx @@ -1,8 +1,9 @@ +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 { setIsoData, toast } from "../../utils"; +import { toast } from "../../toast"; import { HtmlTags } from "../common/html-tags"; import { Spinner } from "../common/icon"; @@ -35,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"); } } @@ -45,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 }`; } @@ -59,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 5a9a1673..fe941830 100644 --- a/src/shared/components/post/create-post.tsx +++ b/src/shared/components/post/create-post.tsx @@ -1,5 +1,7 @@ -import { getQueryParams } from "@utils/helpers"; +import { enableDownvotes, enableNsfw, myAuth, setIsoData } from "@utils/app"; +import { getIdFromString, getQueryParams } from "@utils/helpers"; import type { QueryParams } from "@utils/types"; +import { Choice, RouteDataResponse } from "@utils/types"; import { Component } from "inferno"; import { RouteComponentProps } from "inferno-router/dist/Route"; import { @@ -9,23 +11,13 @@ 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, WrappedLemmyHttp, } from "../../services/HttpService"; -import { - Choice, - RouteDataResponse, - enableDownvotes, - enableNsfw, - getIdFromString, - myAuth, - setIsoData, -} from "../../utils"; import { HtmlTags } from "../common/html-tags"; import { Spinner } from "../common/icon"; import { PostForm } from "./post-form"; @@ -150,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 }`; } @@ -178,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")} )}
      @@ -75,10 +75,14 @@ export class MetadataCard extends Component<
      )} {this.state.expanded && post.embed_video_url && ( - +
      + +
      )} ); diff --git a/src/shared/components/post/post-form.tsx b/src/shared/components/post/post-form.tsx index 2475d49d..d2793fa2 100644 --- a/src/shared/components/post/post-form.tsx +++ b/src/shared/components/post/post-form.tsx @@ -1,4 +1,18 @@ -import { debounce } from "@utils/helpers"; +import { + communityToChoice, + fetchCommunities, + myAuth, + myAuthRequired, +} from "@utils/app"; +import { + capitalizeFirstLetter, + debounce, + getIdFromString, + validTitle, + validURL, +} from "@utils/helpers"; +import { isImage } from "@utils/media"; +import { Choice } from "@utils/types"; import autosize from "autosize"; import { Component, InfernoNode, linkEvent } from "inferno"; import { @@ -10,29 +24,18 @@ import { PostView, SearchResponse, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; -import { PostFormParams } from "../../interfaces"; -import { UserService } from "../../services"; -import { HttpService, RequestState } from "../../services/HttpService"; import { - Choice, archiveTodayUrl, - capitalizeFirstLetter, - communityToChoice, - fetchCommunities, - getIdFromString, ghostArchiveUrl, - isImage, - myAuth, - myAuthRequired, relTags, - setupTippy, - toast, trendingFetchLimit, - validTitle, - validURL, webArchiveUrl, -} from "../../utils"; +} from "../../config"; +import { PostFormParams } from "../../interfaces"; +import { I18NextService, UserService } from "../../services"; +import { HttpService, RequestState } from "../../services/HttpService"; +import { setupTippy } from "../../tippy"; +import { toast } from "../../toast"; import { Icon, Spinner } from "../common/icon"; import { LanguageSelect } from "../common/language-select"; import { MarkdownTextArea } from "../common/markdown-textarea"; @@ -338,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")} > @@ -377,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")}
      )} @@ -407,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")}