refactor: do not import i18n resource json to split chunk (#32947)

This commit is contained in:
Stephen Zhou
2026-03-04 14:28:06 +08:00
committed by GitHub
parent 3aed24c507
commit b8a4e0c13b

View File

@@ -1,73 +1,100 @@
import type appAnnotation from '../i18n/en-US/app-annotation.json'
import type appApi from '../i18n/en-US/app-api.json'
import type appDebug from '../i18n/en-US/app-debug.json'
import type appLog from '../i18n/en-US/app-log.json'
import type appOverview from '../i18n/en-US/app-overview.json'
import type app from '../i18n/en-US/app.json'
import type billing from '../i18n/en-US/billing.json'
import type common from '../i18n/en-US/common.json'
import type custom from '../i18n/en-US/custom.json'
import type datasetCreation from '../i18n/en-US/dataset-creation.json'
import type datasetDocuments from '../i18n/en-US/dataset-documents.json'
import type datasetHitTesting from '../i18n/en-US/dataset-hit-testing.json'
import type datasetPipeline from '../i18n/en-US/dataset-pipeline.json'
import type datasetSettings from '../i18n/en-US/dataset-settings.json'
import type dataset from '../i18n/en-US/dataset.json'
import type education from '../i18n/en-US/education.json'
import type explore from '../i18n/en-US/explore.json'
import type layout from '../i18n/en-US/layout.json'
import type login from '../i18n/en-US/login.json'
import type oauth from '../i18n/en-US/oauth.json'
import type pipeline from '../i18n/en-US/pipeline.json'
import type pluginTags from '../i18n/en-US/plugin-tags.json'
import type pluginTrigger from '../i18n/en-US/plugin-trigger.json'
import type plugin from '../i18n/en-US/plugin.json'
import type register from '../i18n/en-US/register.json'
import type runLog from '../i18n/en-US/run-log.json'
import type share from '../i18n/en-US/share.json'
import type time from '../i18n/en-US/time.json'
import type tools from '../i18n/en-US/tools.json'
import type workflow from '../i18n/en-US/workflow.json'
import { kebabCase } from 'string-ts' import { kebabCase } from 'string-ts'
import { ObjectKeys } from '@/utils/object'
import appAnnotation from '../i18n/en-US/app-annotation.json'
import appApi from '../i18n/en-US/app-api.json'
import appDebug from '../i18n/en-US/app-debug.json'
import appLog from '../i18n/en-US/app-log.json'
import appOverview from '../i18n/en-US/app-overview.json'
import app from '../i18n/en-US/app.json'
import billing from '../i18n/en-US/billing.json'
import common from '../i18n/en-US/common.json'
import custom from '../i18n/en-US/custom.json'
import datasetCreation from '../i18n/en-US/dataset-creation.json'
import datasetDocuments from '../i18n/en-US/dataset-documents.json'
import datasetHitTesting from '../i18n/en-US/dataset-hit-testing.json'
import datasetPipeline from '../i18n/en-US/dataset-pipeline.json'
import datasetSettings from '../i18n/en-US/dataset-settings.json'
import dataset from '../i18n/en-US/dataset.json'
import education from '../i18n/en-US/education.json'
import explore from '../i18n/en-US/explore.json'
import layout from '../i18n/en-US/layout.json'
import login from '../i18n/en-US/login.json'
import oauth from '../i18n/en-US/oauth.json'
import pipeline from '../i18n/en-US/pipeline.json'
import pluginTags from '../i18n/en-US/plugin-tags.json'
import pluginTrigger from '../i18n/en-US/plugin-trigger.json'
import plugin from '../i18n/en-US/plugin.json'
import register from '../i18n/en-US/register.json'
import runLog from '../i18n/en-US/run-log.json'
import share from '../i18n/en-US/share.json'
import time from '../i18n/en-US/time.json'
import tools from '../i18n/en-US/tools.json'
import workflow from '../i18n/en-US/workflow.json'
// @keep-sorted export type Resources = {
const resources = { app: typeof app
app, appAnnotation: typeof appAnnotation
appAnnotation, appApi: typeof appApi
appApi, appDebug: typeof appDebug
appDebug, appLog: typeof appLog
appLog, appOverview: typeof appOverview
appOverview, billing: typeof billing
billing, common: typeof common
common, custom: typeof custom
custom, dataset: typeof dataset
dataset, datasetCreation: typeof datasetCreation
datasetCreation, datasetDocuments: typeof datasetDocuments
datasetDocuments, datasetHitTesting: typeof datasetHitTesting
datasetHitTesting, datasetPipeline: typeof datasetPipeline
datasetPipeline, datasetSettings: typeof datasetSettings
datasetSettings, education: typeof education
education, explore: typeof explore
explore, layout: typeof layout
layout, login: typeof login
login, oauth: typeof oauth
oauth, pipeline: typeof pipeline
pipeline, plugin: typeof plugin
plugin, pluginTags: typeof pluginTags
pluginTags, pluginTrigger: typeof pluginTrigger
pluginTrigger, register: typeof register
register, runLog: typeof runLog
runLog, share: typeof share
share, time: typeof time
time, tools: typeof tools
tools, workflow: typeof workflow
workflow,
} }
export type Resources = typeof resources export const namespaces = [
'app',
export const namespaces = ObjectKeys(resources) 'appAnnotation',
'appApi',
'appDebug',
'appLog',
'appOverview',
'billing',
'common',
'custom',
'dataset',
'datasetCreation',
'datasetDocuments',
'datasetHitTesting',
'datasetPipeline',
'datasetSettings',
'education',
'explore',
'layout',
'login',
'oauth',
'pipeline',
'plugin',
'pluginTags',
'pluginTrigger',
'register',
'runLog',
'share',
'time',
'tools',
'workflow',
] as const satisfies ReadonlyArray<keyof Resources>
export type Namespace = typeof namespaces[number] export type Namespace = typeof namespaces[number]
export const namespacesInFileName = namespaces.map(ns => kebabCase(ns)) export const namespacesInFileName = namespaces.map(ns => kebabCase(ns))