chore: import upstream snapshot with attribution
CI / build (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:09:51 +08:00
commit 0232b4e2bb
3528 changed files with 291404 additions and 0 deletions
@@ -0,0 +1,50 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import { I18n, type I18nLanguage } from '@flowgram.ai/i18n';
import { definePluginCreator } from '@flowgram.ai/core';
export interface I18nPluginOptions {
locale?: string;
/**
* use `locale` instead
* @deprecated
*/
localLanguage?: string;
/**
* if missingStrictMode is true
* expect(I18n.t('Unknown')).toEqual('[missing "en-US.Unknown" translation]')
* else
* expect(I18n.t('Unknown')).toEqual('Unknown')
*/
missingStrictMode?: boolean;
languages?: I18nLanguage[] | Record<string, Record<string, any>>;
onLanguageChange?: (languageId: string) => void;
}
/**
* I18n Plugin
*/
export const createI18nPlugin = definePluginCreator<I18nPluginOptions>({
onInit: (ctx, _opts) => {
if (_opts.onLanguageChange) {
ctx.playground.toDispose.push(I18n.onLanguageChange(_opts.onLanguageChange));
}
if (_opts.languages) {
if (Array.isArray(_opts.languages)) {
I18n.addLanguages(_opts.languages);
} else {
I18n.addLanguages(
Object.keys(_opts.languages).map((key) => ({
languageId: key,
contents: (_opts.languages as any)![key],
}))
);
}
}
if (_opts.locale || _opts.localLanguage) {
I18n.locale = (_opts.locale || _opts.localLanguage)!;
}
},
});
@@ -0,0 +1,7 @@
/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
export { I18n, type I18nLanguage } from '@flowgram.ai/i18n';
export { createI18nPlugin, type I18nPluginOptions } from './create-i18n-plugin';