mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-26 14:21:13 +00:00
fix: Fix up some interface language logic and design
This commit is contained in:
parent
35d20491ea
commit
8184e33c9f
4 changed files with 8 additions and 22 deletions
|
@ -41,12 +41,7 @@ export class CommentForm extends Component<CommentFormProps, any> {
|
|||
: undefined
|
||||
: undefined;
|
||||
|
||||
const userInterfaceLangId = !UserService.Instance.myUserInfo
|
||||
? 0
|
||||
: getUserInterfaceLangId({
|
||||
myUserInfo: UserService.Instance.myUserInfo,
|
||||
allLanguages: this.props.allLanguages,
|
||||
});
|
||||
const userInterfaceLangId = getUserInterfaceLangId(this.props.allLanguages);
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
|
@ -49,7 +49,7 @@ export class LanguageSelect extends Component<LanguageSelectProps, any> {
|
|||
return this.props.iconVersion ? (
|
||||
this.selectBtn
|
||||
) : (
|
||||
<div className="language-select mb-3">
|
||||
<div className="language-select row mb-3">
|
||||
<label
|
||||
className={classNames(
|
||||
"col-form-label",
|
||||
|
|
|
@ -326,12 +326,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
|||
render() {
|
||||
const url = this.state.form.url;
|
||||
|
||||
const userInterfaceLangId = !UserService.Instance.myUserInfo
|
||||
? 0
|
||||
: getUserInterfaceLangId({
|
||||
myUserInfo: UserService.Instance.myUserInfo,
|
||||
allLanguages: this.props.allLanguages,
|
||||
});
|
||||
const userInterfaceLangId = getUserInterfaceLangId(this.props.allLanguages);
|
||||
|
||||
return (
|
||||
<form className="post-form" onSubmit={linkEvent(this, handlePostSubmit)}>
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
import { Language, MyUserInfo } from "lemmy-js-client";
|
||||
import { Language } from "lemmy-js-client";
|
||||
import { I18NextService } from "../../services/I18NextService";
|
||||
|
||||
export default function getUserInterfaceLanguageId({
|
||||
myUserInfo,
|
||||
allLanguages,
|
||||
}: {
|
||||
myUserInfo: MyUserInfo;
|
||||
allLanguages: Language[];
|
||||
}): number {
|
||||
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;
|
||||
|
||||
|
@ -18,5 +14,5 @@ export default function getUserInterfaceLanguageId({
|
|||
});
|
||||
|
||||
// Return the ID of that language object, or "0" for Undetermined
|
||||
return userLang.id || 0;
|
||||
return userLang?.id || 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue