Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix language names #580

Merged
merged 4 commits into from
Feb 18, 2022
Merged

Fix language names #580

merged 4 commits into from
Feb 18, 2022

Conversation

Nutomic
Copy link
Member

@Nutomic Nutomic commented Feb 15, 2022

As described in LemmyNet/joinlemmy-site#76 (comment)

There is still a problem in that all language names are rendered left to right, even those which should be rtl (like Arabic).

@Nutomic Nutomic requested a review from dessalines as a code owner February 15, 2022 12:49
return allowedLangs[0];
}

export function getMomentLanguage(): string {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is not necessary at all, as momentjs does it much smarter on its own.

https://momentjs.com/docs/#/i18n/changing-locale/

{ resource: vi, code: "vi", name: "Tiếng Việt" },
{ resource: zh, code: "zh", name: "中文" },
{ resource: zh_Hant, code: "zh_Hant", name: "文言" },
];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge the different language lists in a single place for simplicity, also sort alphabetically.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much better.

} else {
return lang;
return [lang];
}
}
Copy link
Member Author

@Nutomic Nutomic Feb 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes more sense to return a list of preferred languages here, momentjs uses this. Unfortunately i18next doesnt, it can only set a single language. So if a word isnt translated into the browser language, it will always fallback to English, even if the browser specifies another fallback language.

{ resource: vi, code: "vi", name: "Tiếng Việt" },
{ resource: zh, code: "zh", name: "中文" },
{ resource: zh_Hant, code: "zh_Hant", name: "文言" },
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much better.

@@ -527,7 +525,7 @@ export class Settings extends Component<any, SettingsState> {
.sort((a, b) => a.code.localeCompare(b.code))
.map(lang => (
<option value={lang.code}>
{getNativeLanguageName(lang.code)}
{getLanguages(lang.code)[0]}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the language name here, and I'm not sure why this needed to call getLanguages again.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, i changed this before merging the language lists.

@dessalines dessalines enabled auto-merge (squash) February 18, 2022 19:32
@dessalines dessalines merged commit 2663e19 into main Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants