@flowgram-vue/i18n-plugin 0.2.0
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/LICENSE +22 -0
- package/dist/index.cjs +36 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/package.json +50 -0
- package/src/create-i18n-plugin.ts +50 -0
- package/src/env.d.ts +9 -0
- package/src/index.ts +7 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
4
|
+
Copyright (c) 2026 Crayon
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var i18n = require('@flowgram-vue/i18n');
|
|
4
|
+
var core = require('@flowgram-vue/core');
|
|
5
|
+
|
|
6
|
+
// src/index.ts
|
|
7
|
+
var createI18nPlugin = core.definePluginCreator({
|
|
8
|
+
onInit: (ctx, _opts) => {
|
|
9
|
+
if (_opts.onLanguageChange) {
|
|
10
|
+
ctx.playground.toDispose.push(i18n.I18n.onLanguageChange(_opts.onLanguageChange));
|
|
11
|
+
}
|
|
12
|
+
if (_opts.languages) {
|
|
13
|
+
if (Array.isArray(_opts.languages)) {
|
|
14
|
+
i18n.I18n.addLanguages(_opts.languages);
|
|
15
|
+
} else {
|
|
16
|
+
i18n.I18n.addLanguages(
|
|
17
|
+
Object.keys(_opts.languages).map((key) => ({
|
|
18
|
+
languageId: key,
|
|
19
|
+
contents: _opts.languages[key]
|
|
20
|
+
}))
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (_opts.locale || _opts.localLanguage) {
|
|
25
|
+
i18n.I18n.locale = _opts.locale || _opts.localLanguage;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
Object.defineProperty(exports, "I18n", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () { return i18n.I18n; }
|
|
33
|
+
});
|
|
34
|
+
exports.createI18nPlugin = createI18nPlugin;
|
|
35
|
+
//# sourceMappingURL=index.cjs.map
|
|
36
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/create-i18n-plugin.ts"],"names":["definePluginCreator","I18n"],"mappings":";;;;;;AA4BO,IAAM,mBAAmBA,wBAAA,CAAuC;AAAA,EACrE,MAAA,EAAQ,CAAC,GAAA,EAAK,KAAA,KAAU;AACtB,IAAA,IAAI,MAAM,gBAAA,EAAkB;AAC1B,MAAA,GAAA,CAAI,WAAW,SAAA,CAAU,IAAA,CAAKC,UAAK,gBAAA,CAAiB,KAAA,CAAM,gBAAgB,CAAC,CAAA;AAAA,IAC7E;AACA,IAAA,IAAI,MAAM,SAAA,EAAW;AACnB,MAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAA,CAAM,SAAS,CAAA,EAAG;AAClC,QAAAA,SAAA,CAAK,YAAA,CAAa,MAAM,SAAS,CAAA;AAAA,MACnC,CAAA,MAAO;AACL,QAAAA,SAAA,CAAK,YAAA;AAAA,UACH,OAAO,IAAA,CAAK,KAAA,CAAM,SAAS,CAAA,CAAE,GAAA,CAAI,CAAC,GAAA,MAAS;AAAA,YACzC,UAAA,EAAY,GAAA;AAAA,YACZ,QAAA,EAAW,KAAA,CAAM,SAAA,CAAmB,GAAG;AAAA,WACzC,CAAE;AAAA,SACJ;AAAA,MACF;AAAA,IACF;AACA,IAAA,IAAI,KAAA,CAAM,MAAA,IAAU,KAAA,CAAM,aAAA,EAAe;AACvC,MAAAA,SAAA,CAAK,MAAA,GAAU,KAAA,CAAM,MAAA,IAAU,KAAA,CAAM,aAAA;AAAA,IACvC;AAAA,EACF;AACF,CAAC","file":"index.cjs","sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { I18n, type I18nLanguage } from '@flowgram-vue/i18n';\nimport { definePluginCreator } from '@flowgram-vue/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"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { I18nLanguage } from '@flowgram-vue/i18n';
|
|
2
|
+
export { I18n, I18nLanguage } from '@flowgram-vue/i18n';
|
|
3
|
+
import * as _flowgram_vue_core from '@flowgram-vue/core';
|
|
4
|
+
|
|
5
|
+
interface I18nPluginOptions {
|
|
6
|
+
locale?: string;
|
|
7
|
+
/**
|
|
8
|
+
* use `locale` instead
|
|
9
|
+
* @deprecated
|
|
10
|
+
*/
|
|
11
|
+
localLanguage?: string;
|
|
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>>;
|
|
20
|
+
onLanguageChange?: (languageId: string) => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* I18n Plugin
|
|
24
|
+
*/
|
|
25
|
+
declare const createI18nPlugin: _flowgram_vue_core.PluginCreator<I18nPluginOptions>;
|
|
26
|
+
|
|
27
|
+
export { type I18nPluginOptions, createI18nPlugin };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { I18n } from '@flowgram-vue/i18n';
|
|
2
|
+
export { I18n } from '@flowgram-vue/i18n';
|
|
3
|
+
import { definePluginCreator } from '@flowgram-vue/core';
|
|
4
|
+
|
|
5
|
+
// src/index.ts
|
|
6
|
+
var createI18nPlugin = definePluginCreator({
|
|
7
|
+
onInit: (ctx, _opts) => {
|
|
8
|
+
if (_opts.onLanguageChange) {
|
|
9
|
+
ctx.playground.toDispose.push(I18n.onLanguageChange(_opts.onLanguageChange));
|
|
10
|
+
}
|
|
11
|
+
if (_opts.languages) {
|
|
12
|
+
if (Array.isArray(_opts.languages)) {
|
|
13
|
+
I18n.addLanguages(_opts.languages);
|
|
14
|
+
} else {
|
|
15
|
+
I18n.addLanguages(
|
|
16
|
+
Object.keys(_opts.languages).map((key) => ({
|
|
17
|
+
languageId: key,
|
|
18
|
+
contents: _opts.languages[key]
|
|
19
|
+
}))
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (_opts.locale || _opts.localLanguage) {
|
|
24
|
+
I18n.locale = _opts.locale || _opts.localLanguage;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export { createI18nPlugin };
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/create-i18n-plugin.ts"],"names":[],"mappings":";;;;;AA4BO,IAAM,mBAAmB,mBAAA,CAAuC;AAAA,EACrE,MAAA,EAAQ,CAAC,GAAA,EAAK,KAAA,KAAU;AACtB,IAAA,IAAI,MAAM,gBAAA,EAAkB;AAC1B,MAAA,GAAA,CAAI,WAAW,SAAA,CAAU,IAAA,CAAK,KAAK,gBAAA,CAAiB,KAAA,CAAM,gBAAgB,CAAC,CAAA;AAAA,IAC7E;AACA,IAAA,IAAI,MAAM,SAAA,EAAW;AACnB,MAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAA,CAAM,SAAS,CAAA,EAAG;AAClC,QAAA,IAAA,CAAK,YAAA,CAAa,MAAM,SAAS,CAAA;AAAA,MACnC,CAAA,MAAO;AACL,QAAA,IAAA,CAAK,YAAA;AAAA,UACH,OAAO,IAAA,CAAK,KAAA,CAAM,SAAS,CAAA,CAAE,GAAA,CAAI,CAAC,GAAA,MAAS;AAAA,YACzC,UAAA,EAAY,GAAA;AAAA,YACZ,QAAA,EAAW,KAAA,CAAM,SAAA,CAAmB,GAAG;AAAA,WACzC,CAAE;AAAA,SACJ;AAAA,MACF;AAAA,IACF;AACA,IAAA,IAAI,KAAA,CAAM,MAAA,IAAU,KAAA,CAAM,aAAA,EAAe;AACvC,MAAA,IAAA,CAAK,MAAA,GAAU,KAAA,CAAM,MAAA,IAAU,KAAA,CAAM,aAAA;AAAA,IACvC;AAAA,EACF;AACF,CAAC","file":"index.js","sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { I18n, type I18nLanguage } from '@flowgram-vue/i18n';\nimport { definePluginCreator } from '@flowgram-vue/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"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flowgram-vue/i18n-plugin",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"homepage": "https://flowgram.ai/",
|
|
6
|
+
"repository": "https://github.com/Crayon-hua/flowgram-vue",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"main": "./dist/index.cjs",
|
|
16
|
+
"module": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"files": [
|
|
19
|
+
"src",
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@flowgram-vue/core": "0.2.0",
|
|
24
|
+
"@flowgram-vue/i18n": "0.2.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^20",
|
|
28
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
29
|
+
"eslint": "^9.0.0",
|
|
30
|
+
"reflect-metadata": "~0.2.2",
|
|
31
|
+
"typescript": "^5.8.3",
|
|
32
|
+
"vitest": "^3.2.4",
|
|
33
|
+
"@flowgram-vue/ts-config": "0.2.0",
|
|
34
|
+
"@flowgram-vue/build-config": "0.2.0",
|
|
35
|
+
"@flowgram-vue/eslint-config": "0.2.0"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"registry": "https://registry.npmjs.org/"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "flowgram-build",
|
|
43
|
+
"test": "vitest run --passWithNoTests",
|
|
44
|
+
"lint": "eslint .",
|
|
45
|
+
"ts-check": "tsc --noEmit",
|
|
46
|
+
"type-check": "tsc --noEmit",
|
|
47
|
+
"build:fast": "flowgram-build --fast",
|
|
48
|
+
"build:watch": "flowgram-build --watch"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { I18n, type I18nLanguage } from '@flowgram-vue/i18n';
|
|
7
|
+
import { definePluginCreator } from '@flowgram-vue/core';
|
|
8
|
+
|
|
9
|
+
export interface I18nPluginOptions {
|
|
10
|
+
locale?: string;
|
|
11
|
+
/**
|
|
12
|
+
* use `locale` instead
|
|
13
|
+
* @deprecated
|
|
14
|
+
*/
|
|
15
|
+
localLanguage?: string;
|
|
16
|
+
/**
|
|
17
|
+
* if missingStrictMode is true
|
|
18
|
+
* expect(I18n.t('Unknown')).toEqual('[missing "en-US.Unknown" translation]')
|
|
19
|
+
* else
|
|
20
|
+
* expect(I18n.t('Unknown')).toEqual('Unknown')
|
|
21
|
+
*/
|
|
22
|
+
missingStrictMode?: boolean;
|
|
23
|
+
languages?: I18nLanguage[] | Record<string, Record<string, any>>;
|
|
24
|
+
onLanguageChange?: (languageId: string) => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* I18n Plugin
|
|
28
|
+
*/
|
|
29
|
+
export const createI18nPlugin = definePluginCreator<I18nPluginOptions>({
|
|
30
|
+
onInit: (ctx, _opts) => {
|
|
31
|
+
if (_opts.onLanguageChange) {
|
|
32
|
+
ctx.playground.toDispose.push(I18n.onLanguageChange(_opts.onLanguageChange));
|
|
33
|
+
}
|
|
34
|
+
if (_opts.languages) {
|
|
35
|
+
if (Array.isArray(_opts.languages)) {
|
|
36
|
+
I18n.addLanguages(_opts.languages);
|
|
37
|
+
} else {
|
|
38
|
+
I18n.addLanguages(
|
|
39
|
+
Object.keys(_opts.languages).map((key) => ({
|
|
40
|
+
languageId: key,
|
|
41
|
+
contents: (_opts.languages as any)![key],
|
|
42
|
+
}))
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (_opts.locale || _opts.localLanguage) {
|
|
47
|
+
I18n.locale = (_opts.locale || _opts.localLanguage)!;
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
});
|
package/src/env.d.ts
ADDED
package/src/index.ts
ADDED