Fix native language issue. (zh_Hant) (#513)

This commit is contained in:
Dessalines 2021-12-01 15:50:56 -05:00 committed by GitHub
parent d0aeb96d7b
commit a11cbb29c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 6 deletions

View file

@ -1,5 +1,4 @@
import { Component, linkEvent } from "inferno";
import ISO6391 from "iso-639-1";
import {
BlockCommunity,
BlockCommunityResponse,
@ -32,6 +31,7 @@ import {
fetchCommunities,
fetchUsers,
getLanguage,
getNativeLanguageName,
isBrowser,
languages,
personSelectName,
@ -523,11 +523,13 @@ export class Settings extends Component<any, SettingsState> {
<option disabled aria-hidden="true">
</option>
{languages.sort().map(lang => (
<option value={lang.code}>
{ISO6391.getNativeName(lang.code) || lang.code}
</option>
))}
{languages
.sort((a, b) => a.code.localeCompare(b.code))
.map(lang => (
<option value={lang.code}>
{getNativeLanguageName(lang.code)}
</option>
))}
</select>
</div>
</div>

View file

@ -1,4 +1,5 @@
import emojiShortName from "emoji-short-name";
import ISO6391 from "iso-639-1";
import {
BlockCommunityResponse,
BlockPersonResponse,
@ -414,6 +415,18 @@ export function debounce(func: any, wait = 1000, immediate = false) {
};
}
export function getNativeLanguageName(code: string): string {
let [isoCode, qualifier] = code.split("_");
let native = ISO6391.getNativeName(isoCode) || code;
if (qualifier) {
return `${native}_${qualifier}`;
} else {
return native;
}
}
// TODO
export function getLanguage(override?: string): string {
let myUserInfo = UserService.Instance.myUserInfo;