mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-12-01 16:51:13 +00:00
Fix native language issue. (zh_Hant)
This commit is contained in:
parent
d0aeb96d7b
commit
e15b65d4ec
2 changed files with 21 additions and 6 deletions
|
@ -1,5 +1,4 @@
|
||||||
import { Component, linkEvent } from "inferno";
|
import { Component, linkEvent } from "inferno";
|
||||||
import ISO6391 from "iso-639-1";
|
|
||||||
import {
|
import {
|
||||||
BlockCommunity,
|
BlockCommunity,
|
||||||
BlockCommunityResponse,
|
BlockCommunityResponse,
|
||||||
|
@ -32,6 +31,7 @@ import {
|
||||||
fetchCommunities,
|
fetchCommunities,
|
||||||
fetchUsers,
|
fetchUsers,
|
||||||
getLanguage,
|
getLanguage,
|
||||||
|
getNativeLanguageName,
|
||||||
isBrowser,
|
isBrowser,
|
||||||
languages,
|
languages,
|
||||||
personSelectName,
|
personSelectName,
|
||||||
|
@ -523,9 +523,11 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
<option disabled aria-hidden="true">
|
<option disabled aria-hidden="true">
|
||||||
──
|
──
|
||||||
</option>
|
</option>
|
||||||
{languages.sort().map(lang => (
|
{languages
|
||||||
|
.sort((a, b) => a.code.localeCompare(b.code))
|
||||||
|
.map(lang => (
|
||||||
<option value={lang.code}>
|
<option value={lang.code}>
|
||||||
{ISO6391.getNativeName(lang.code) || lang.code}
|
{getNativeLanguageName(lang.code)}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import emojiShortName from "emoji-short-name";
|
import emojiShortName from "emoji-short-name";
|
||||||
|
import ISO6391 from "iso-639-1";
|
||||||
import {
|
import {
|
||||||
BlockCommunityResponse,
|
BlockCommunityResponse,
|
||||||
BlockPersonResponse,
|
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
|
// TODO
|
||||||
export function getLanguage(override?: string): string {
|
export function getLanguage(override?: string): string {
|
||||||
let myUserInfo = UserService.Instance.myUserInfo;
|
let myUserInfo = UserService.Instance.myUserInfo;
|
||||||
|
|
Loading…
Reference in a new issue