@adminforth/i18n 1.6.8 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,4 +54,5 @@ steps:
54
54
  status: [success]
55
55
  commands:
56
56
  - . /woodpecker/deploy.vault.env
57
- - /bin/sh ./.woodpecker/buildSlackNotify.sh success
57
+ - /bin/sh ./.woodpecker/buildSlackNotify.sh success
58
+
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ import path from 'path';
14
14
  import fs from 'fs-extra';
15
15
  import chokidar from 'chokidar';
16
16
  import { AsyncQueue } from '@sapphire/async-queue';
17
+ import getFlagEmoji from 'country-flag-svg';
17
18
  const processFrontendMessagesQueue = new AsyncQueue();
18
19
  const SLAVIC_PLURAL_EXAMPLES = {
19
20
  uk: 'яблук | Яблуко | Яблука | Яблук', // zero | singular | 2-4 | 5+
@@ -788,14 +789,18 @@ export default class I18nPlugin extends AdminForthPlugin {
788
789
  }
789
790
  languagesList() {
790
791
  return __awaiter(this, void 0, void 0, function* () {
791
- return this.options.supportedLanguages.map((lang) => {
792
+ return Promise.all(this.options.supportedLanguages.map((lang) => __awaiter(this, void 0, void 0, function* () {
793
+ const flagEmoji = typeof getFlagEmoji === 'function'
794
+ ? getFlagEmoji
795
+ : getFlagEmoji.default;
792
796
  return {
793
797
  code: lang,
794
798
  nameOnNative: iso6391.getNativeName(getPrimaryLanguageCode(lang)),
795
799
  nameEnglish: iso6391.getName(getPrimaryLanguageCode(lang)),
796
800
  emojiFlag: getCountryCodeFromLangCode(lang).toUpperCase().replace(/./g, char => String.fromCodePoint(char.charCodeAt(0) + 127397)),
801
+ svgFlagB64: yield flagEmoji(getCountryCodeFromLangCode(lang)),
797
802
  };
798
- });
803
+ })));
799
804
  });
800
805
  }
801
806
  feedCategoryTranslations(messages, category) {
package/index.ts CHANGED
@@ -7,6 +7,7 @@ import path from 'path';
7
7
  import fs from 'fs-extra';
8
8
  import chokidar from 'chokidar';
9
9
  import { AsyncQueue } from '@sapphire/async-queue';
10
+ import getFlagEmoji from 'country-flag-svg';
10
11
 
11
12
 
12
13
  const processFrontendMessagesQueue = new AsyncQueue();
@@ -922,15 +923,22 @@ export default class I18nPlugin extends AdminForthPlugin {
922
923
  nameOnNative: string;
923
924
  nameEnglish: string;
924
925
  emojiFlag: string;
926
+ svgFlagB64: string;
925
927
  }[]> {
926
- return this.options.supportedLanguages.map((lang) => {
928
+ return Promise.all(this.options.supportedLanguages.map(async (lang) => {
929
+ const flagEmoji =
930
+ typeof getFlagEmoji === 'function'
931
+ ? getFlagEmoji
932
+ : getFlagEmoji.default;
933
+
927
934
  return {
928
935
  code: lang,
929
936
  nameOnNative: iso6391.getNativeName(getPrimaryLanguageCode(lang)),
930
937
  nameEnglish: iso6391.getName(getPrimaryLanguageCode(lang)),
931
938
  emojiFlag: getCountryCodeFromLangCode(lang).toUpperCase().replace(/./g, char => String.fromCodePoint(char.charCodeAt(0) + 127397)),
939
+ svgFlagB64: await flagEmoji(getCountryCodeFromLangCode(lang)),
932
940
  };
933
- });
941
+ }));
934
942
  }
935
943
 
936
944
  async feedCategoryTranslations(messages: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/i18n",
3
- "version": "1.6.8",
3
+ "version": "1.7.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -31,6 +31,7 @@
31
31
  "@aws-sdk/client-ses": "^3.654.0",
32
32
  "@sapphire/async-queue": "^1.5.5",
33
33
  "chokidar": "^4.0.1",
34
+ "country-flag-svg": "^1.0.19",
34
35
  "fs-extra": "^11.3.2",
35
36
  "iso-3166": "^4.3.0",
36
37
  "iso-639-1": "^3.1.3"