@flowgram.ai/i18n-plugin 0.2.9 → 0.2.11
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.
- package/dist/esm/index.js +12 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/esm/index.js
CHANGED
|
@@ -10,10 +10,19 @@ var createI18nPlugin = definePluginCreator({
|
|
|
10
10
|
ctx.playground.toDispose.push(I18n.onLanguageChange(_opts.onLanguageChange));
|
|
11
11
|
}
|
|
12
12
|
if (_opts.languages) {
|
|
13
|
-
_opts.languages
|
|
13
|
+
if (Array.isArray(_opts.languages)) {
|
|
14
|
+
I18n.addLanguages(_opts.languages);
|
|
15
|
+
} else {
|
|
16
|
+
I18n.addLanguages(
|
|
17
|
+
Object.keys(_opts.languages).map((key) => ({
|
|
18
|
+
languageId: key,
|
|
19
|
+
contents: _opts.languages[key]
|
|
20
|
+
}))
|
|
21
|
+
);
|
|
22
|
+
}
|
|
14
23
|
}
|
|
15
|
-
if (_opts.localLanguage) {
|
|
16
|
-
I18n.
|
|
24
|
+
if (_opts.locale || _opts.localLanguage) {
|
|
25
|
+
I18n.locale = _opts.locale || _opts.localLanguage;
|
|
17
26
|
}
|
|
18
27
|
}
|
|
19
28
|
});
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/create-i18n-plugin.ts"],"sourcesContent":["export { I18n, type I18nLanguage } from '@flowgram.ai/i18n';\nexport { createI18nPlugin, type I18nPluginOptions } from './create-i18n-plugin';\n","import { I18n, type I18nLanguage } from '@flowgram.ai/i18n';\nimport { definePluginCreator } from '@flowgram.ai/core';\n\nexport interface I18nPluginOptions {\n localLanguage?: string;\n languages?: I18nLanguage[]
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/create-i18n-plugin.ts"],"sourcesContent":["export { I18n, type I18nLanguage } from '@flowgram.ai/i18n';\nexport { createI18nPlugin, type I18nPluginOptions } from './create-i18n-plugin';\n","import { I18n, type I18nLanguage } from '@flowgram.ai/i18n';\nimport { definePluginCreator } from '@flowgram.ai/core';\n\nexport interface I18nPluginOptions {\n locale?: string;\n /**\n * use `locale` instead\n * @deprecated\n */\n localLanguage?: string;\n /**\n * if missingStrictMode is true\n * expect(I18n.t('Unknown')).toEqual('[missing \"en-US.Unknown\" translation]')\n * else\n * expect(I18n.t('Unknown')).toEqual('Unknown')\n */\n missingStrictMode?: boolean;\n languages?: I18nLanguage[] | Record<string, Record<string, any>>;\n onLanguageChange?: (languageId: string) => void;\n}\n/**\n * I18n Plugin\n */\nexport const createI18nPlugin = definePluginCreator<I18nPluginOptions>({\n onInit: (ctx, _opts) => {\n if (_opts.onLanguageChange) {\n ctx.playground.toDispose.push(I18n.onLanguageChange(_opts.onLanguageChange));\n }\n if (_opts.languages) {\n if (Array.isArray(_opts.languages)) {\n I18n.addLanguages(_opts.languages);\n } else {\n I18n.addLanguages(\n Object.keys(_opts.languages).map((key) => ({\n languageId: key,\n contents: (_opts.languages as any)![key],\n }))\n );\n }\n }\n if (_opts.locale || _opts.localLanguage) {\n I18n.locale = (_opts.locale || _opts.localLanguage)!;\n }\n },\n});\n"],"mappings":";AAAA,SAAS,QAAAA,aAA+B;;;ACAxC,SAAS,YAA+B;AACxC,SAAS,2BAA2B;AAsB7B,IAAM,mBAAmB,oBAAuC;AAAA,EACrE,QAAQ,CAAC,KAAK,UAAU;AACtB,QAAI,MAAM,kBAAkB;AAC1B,UAAI,WAAW,UAAU,KAAK,KAAK,iBAAiB,MAAM,gBAAgB,CAAC;AAAA,IAC7E;AACA,QAAI,MAAM,WAAW;AACnB,UAAI,MAAM,QAAQ,MAAM,SAAS,GAAG;AAClC,aAAK,aAAa,MAAM,SAAS;AAAA,MACnC,OAAO;AACL,aAAK;AAAA,UACH,OAAO,KAAK,MAAM,SAAS,EAAE,IAAI,CAAC,SAAS;AAAA,YACzC,YAAY;AAAA,YACZ,UAAW,MAAM,UAAmB,GAAG;AAAA,UACzC,EAAE;AAAA,QACJ;AAAA,MACF;AAAA,IACF;AACA,QAAI,MAAM,UAAU,MAAM,eAAe;AACvC,WAAK,SAAU,MAAM,UAAU,MAAM;AAAA,IACvC;AAAA,EACF;AACF,CAAC;","names":["I18n"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -3,8 +3,20 @@ export { I18n, I18nLanguage } from '@flowgram.ai/i18n';
|
|
|
3
3
|
import * as _flowgram_ai_core from '@flowgram.ai/core';
|
|
4
4
|
|
|
5
5
|
interface I18nPluginOptions {
|
|
6
|
+
locale?: string;
|
|
7
|
+
/**
|
|
8
|
+
* use `locale` instead
|
|
9
|
+
* @deprecated
|
|
10
|
+
*/
|
|
6
11
|
localLanguage?: string;
|
|
7
|
-
|
|
12
|
+
/**
|
|
13
|
+
* if missingStrictMode is true
|
|
14
|
+
* expect(I18n.t('Unknown')).toEqual('[missing "en-US.Unknown" translation]')
|
|
15
|
+
* else
|
|
16
|
+
* expect(I18n.t('Unknown')).toEqual('Unknown')
|
|
17
|
+
*/
|
|
18
|
+
missingStrictMode?: boolean;
|
|
19
|
+
languages?: I18nLanguage[] | Record<string, Record<string, any>>;
|
|
8
20
|
onLanguageChange?: (languageId: string) => void;
|
|
9
21
|
}
|
|
10
22
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,20 @@ export { I18n, I18nLanguage } from '@flowgram.ai/i18n';
|
|
|
3
3
|
import * as _flowgram_ai_core from '@flowgram.ai/core';
|
|
4
4
|
|
|
5
5
|
interface I18nPluginOptions {
|
|
6
|
+
locale?: string;
|
|
7
|
+
/**
|
|
8
|
+
* use `locale` instead
|
|
9
|
+
* @deprecated
|
|
10
|
+
*/
|
|
6
11
|
localLanguage?: string;
|
|
7
|
-
|
|
12
|
+
/**
|
|
13
|
+
* if missingStrictMode is true
|
|
14
|
+
* expect(I18n.t('Unknown')).toEqual('[missing "en-US.Unknown" translation]')
|
|
15
|
+
* else
|
|
16
|
+
* expect(I18n.t('Unknown')).toEqual('Unknown')
|
|
17
|
+
*/
|
|
18
|
+
missingStrictMode?: boolean;
|
|
19
|
+
languages?: I18nLanguage[] | Record<string, Record<string, any>>;
|
|
8
20
|
onLanguageChange?: (languageId: string) => void;
|
|
9
21
|
}
|
|
10
22
|
/**
|
package/dist/index.js
CHANGED
|
@@ -35,10 +35,19 @@ var createI18nPlugin = (0, import_core.definePluginCreator)({
|
|
|
35
35
|
ctx.playground.toDispose.push(import_i18n.I18n.onLanguageChange(_opts.onLanguageChange));
|
|
36
36
|
}
|
|
37
37
|
if (_opts.languages) {
|
|
38
|
-
_opts.languages
|
|
38
|
+
if (Array.isArray(_opts.languages)) {
|
|
39
|
+
import_i18n.I18n.addLanguages(_opts.languages);
|
|
40
|
+
} else {
|
|
41
|
+
import_i18n.I18n.addLanguages(
|
|
42
|
+
Object.keys(_opts.languages).map((key) => ({
|
|
43
|
+
languageId: key,
|
|
44
|
+
contents: _opts.languages[key]
|
|
45
|
+
}))
|
|
46
|
+
);
|
|
47
|
+
}
|
|
39
48
|
}
|
|
40
|
-
if (_opts.localLanguage) {
|
|
41
|
-
import_i18n.I18n.
|
|
49
|
+
if (_opts.locale || _opts.localLanguage) {
|
|
50
|
+
import_i18n.I18n.locale = _opts.locale || _opts.localLanguage;
|
|
42
51
|
}
|
|
43
52
|
}
|
|
44
53
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/create-i18n-plugin.ts"],"sourcesContent":["export { I18n, type I18nLanguage } from '@flowgram.ai/i18n';\nexport { createI18nPlugin, type I18nPluginOptions } from './create-i18n-plugin';\n","import { I18n, type I18nLanguage } from '@flowgram.ai/i18n';\nimport { definePluginCreator } from '@flowgram.ai/core';\n\nexport interface I18nPluginOptions {\n localLanguage?: string;\n languages?: I18nLanguage[]
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/create-i18n-plugin.ts"],"sourcesContent":["export { I18n, type I18nLanguage } from '@flowgram.ai/i18n';\nexport { createI18nPlugin, type I18nPluginOptions } from './create-i18n-plugin';\n","import { I18n, type I18nLanguage } from '@flowgram.ai/i18n';\nimport { definePluginCreator } from '@flowgram.ai/core';\n\nexport interface I18nPluginOptions {\n locale?: string;\n /**\n * use `locale` instead\n * @deprecated\n */\n localLanguage?: string;\n /**\n * if missingStrictMode is true\n * expect(I18n.t('Unknown')).toEqual('[missing \"en-US.Unknown\" translation]')\n * else\n * expect(I18n.t('Unknown')).toEqual('Unknown')\n */\n missingStrictMode?: boolean;\n languages?: I18nLanguage[] | Record<string, Record<string, any>>;\n onLanguageChange?: (languageId: string) => void;\n}\n/**\n * I18n Plugin\n */\nexport const createI18nPlugin = definePluginCreator<I18nPluginOptions>({\n onInit: (ctx, _opts) => {\n if (_opts.onLanguageChange) {\n ctx.playground.toDispose.push(I18n.onLanguageChange(_opts.onLanguageChange));\n }\n if (_opts.languages) {\n if (Array.isArray(_opts.languages)) {\n I18n.addLanguages(_opts.languages);\n } else {\n I18n.addLanguages(\n Object.keys(_opts.languages).map((key) => ({\n languageId: key,\n contents: (_opts.languages as any)![key],\n }))\n );\n }\n }\n if (_opts.locale || _opts.localLanguage) {\n I18n.locale = (_opts.locale || _opts.localLanguage)!;\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,eAAwC;;;ACAxC,kBAAwC;AACxC,kBAAoC;AAsB7B,IAAM,uBAAmB,iCAAuC;AAAA,EACrE,QAAQ,CAAC,KAAK,UAAU;AACtB,QAAI,MAAM,kBAAkB;AAC1B,UAAI,WAAW,UAAU,KAAK,iBAAK,iBAAiB,MAAM,gBAAgB,CAAC;AAAA,IAC7E;AACA,QAAI,MAAM,WAAW;AACnB,UAAI,MAAM,QAAQ,MAAM,SAAS,GAAG;AAClC,yBAAK,aAAa,MAAM,SAAS;AAAA,MACnC,OAAO;AACL,yBAAK;AAAA,UACH,OAAO,KAAK,MAAM,SAAS,EAAE,IAAI,CAAC,SAAS;AAAA,YACzC,YAAY;AAAA,YACZ,UAAW,MAAM,UAAmB,GAAG;AAAA,UACzC,EAAE;AAAA,QACJ;AAAA,MACF;AAAA,IACF;AACA,QAAI,MAAM,UAAU,MAAM,eAAe;AACvC,uBAAK,SAAU,MAAM,UAAU,MAAM;AAAA,IACvC;AAAA,EACF;AACF,CAAC;","names":["import_i18n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowgram.ai/i18n-plugin",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"homepage": "https://flowgram.ai/",
|
|
5
5
|
"repository": "https://github.com/bytedance/flowgram.ai",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@flowgram.ai/
|
|
20
|
-
"@flowgram.ai/
|
|
19
|
+
"@flowgram.ai/core": "0.2.11",
|
|
20
|
+
"@flowgram.ai/i18n": "0.2.11"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/bezier-js": "4.1.3",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"styled-components": "^5",
|
|
34
34
|
"tsup": "^8.0.1",
|
|
35
35
|
"vitest": "^0.34.6",
|
|
36
|
-
"@flowgram.ai/eslint-config": "0.2.
|
|
37
|
-
"@flowgram.ai/ts-config": "0.2.
|
|
36
|
+
"@flowgram.ai/eslint-config": "0.2.11",
|
|
37
|
+
"@flowgram.ai/ts-config": "0.2.11"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {},
|
|
40
40
|
"publishConfig": {
|