import { myAuthRequired } from "@utils/app";
-import getUserInterfaceLangId from "@utils/app/user-interface-language";
import { capitalizeFirstLetter } from "@utils/helpers";
import { Component } from "inferno";
import { T } from "inferno-i18next-dess";
: undefined
: undefined;
- const userInterfaceLangId = getUserInterfaceLangId(this.props.allLanguages);
-
return (
<div
className={["comment-form", "mb-3", this.props.containerClass].join(
{UserService.Instance.myUserInfo ? (
<MarkdownTextArea
initialContent={initialContent}
- initialLanguageId={userInterfaceLangId}
showLanguage
buttonTitle={this.buttonTitle}
finished={this.props.finished}
return this.props.iconVersion ? (
this.selectBtn
) : (
- <div className="language-select row mb-3">
+ <div className="language-select mb-3">
<label
className={classNames(
"col-form-label",
<LanguageSelect
iconVersion
allLanguages={this.props.allLanguages}
- // Only set the selected language ID if it exists as an option
- // in the dropdown; otherwise, set it to 0 (Undetermined)
selectedLanguageIds={
- languageId && this.props.siteLanguages.includes(languageId)
- ? [languageId]
- : [0]
+ languageId ? Array.of(languageId) : undefined
}
siteLanguages={this.props.siteLanguages}
onChange={this.handleLanguageChange}
myAuth,
myAuthRequired,
} from "@utils/app";
-import getUserInterfaceLangId from "@utils/app/user-interface-language";
import {
capitalizeFirstLetter,
debounce,
}
render() {
- const url = this.state.form.url;
+ const firstLang = this.state.form.language_id;
+ const selectedLangs = firstLang ? Array.of(firstLang) : undefined;
- const userInterfaceLangId = getUserInterfaceLangId(this.props.allLanguages);
+ const url = this.state.form.url;
return (
<form className="post-form" onSubmit={linkEvent(this, handlePostSubmit)}>
</div>
<LanguageSelect
allLanguages={this.props.allLanguages}
- selectedLanguageIds={[userInterfaceLangId]}
siteLanguages={this.props.siteLanguages}
+ selectedLanguageIds={selectedLangs}
multiple={false}
onChange={this.handleLanguageChange}
/>
import siteBannerCss from "./site-banner-css";
import updateCommunityBlock from "./update-community-block";
import updatePersonBlock from "./update-person-block";
-import getUserInterfaceLangId from "./user-interface-language";
export {
buildCommentsTree,
getRecipientIdFromProps,
getRoleLabelPill,
getUpdatedSearchId,
- getUserInterfaceLangId,
initializeSite,
insertCommentIntoTree,
isAuthPath,
+++ /dev/null
-import { Language } from "lemmy-js-client";
-import { I18NextService } from "../../services/I18NextService";
-
-export default function getUserInterfaceLangId(
- allLanguages: Language[]
-): number {
- // Get the string of the browser- or user-defined language, like en-US
- const i18nLang = I18NextService.i18n.language;
-
- // Find the Language object with a code that matches the initial characters of
- // this string
- const userLang = allLanguages.find(lang => {
- return i18nLang.indexOf(lang.code) === 0;
- });
-
- // Return the ID of that language object, or "0" for Undetermined
- return userLang?.id || 0;
-}