Skip to content

Commit 2c12843

Browse files
committed
Merge branch 'main' of github.com:devforth/adminforth into main
2 parents 9907c5d + 697128c commit 2c12843

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed
3.63 KB
Loading
3.86 KB
Loading

adminforth/plugins/i18n/index.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import path from 'path';
66
import fs from 'fs-extra';
77
import chokidar from 'chokidar';
88
import { AsyncQueue } from '@sapphire/async-queue';
9-
10-
119
console.log = (...args) => {
1210
process.stdout.write(args.join(" ") + "\n");
1311
};
@@ -28,6 +26,22 @@ const SLAVIC_PLURAL_EXAMPLES = {
2826
ru: 'яблок | яблоко | яблока | яблок', // zero | singular | 2-4 | 5+
2927
};
3028

29+
const countryISO31661ByLangISO6391 = {
30+
en: 'us', // English → United States
31+
zh: 'cn', // Chinese → China
32+
hi: 'in', // Hindi → India
33+
ar: 'sa', // Arabic → Saudi Arabia
34+
ko: 'kr', // Korean → South Korea
35+
ja: 'jp', // Japanese → Japan
36+
uk: 'ua', // Ukrainian → Ukraine
37+
ur: 'pk', // Urdu → Pakistan
38+
};
39+
40+
function getCountryCodeFromLangCode(langCode) {
41+
return countryISO31661ByLangISO6391[langCode] || langCode;
42+
}
43+
44+
3145
interface ICachingAdapter {
3246
get(key: string): Promise<any>;
3347
set(key: string, value: any): Promise<void>;
@@ -809,7 +823,7 @@ JSON.stringify(strings.reduce((acc: object, s: { en_string: string }): object =>
809823
code: lang as LanguageCode,
810824
nameOnNative: iso6391.getNativeName(lang),
811825
nameEnglish: iso6391.getName(lang),
812-
emojiFlag: lang.toUpperCase().replace(/./g, char => String.fromCodePoint(char.charCodeAt(0) + 127397)),
826+
emojiFlag: getCountryCodeFromLangCode(lang).toUpperCase().replace(/./g, char => String.fromCodePoint(char.charCodeAt(0) + 127397)),
813827
};
814828
});
815829
}

0 commit comments

Comments
 (0)