mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 09:07:40 +00:00
* perf(i18n): load built-in catalogs once, without copies or a runtime plural fill
Each catalog load parsed the JSON, rebuilt it to fill CLDR plural forms
from _other, then deep-copied and deep-merged it into the store (about
26 ms after parsing per 1.3 MB catalog), and concurrent loads of one
locale fetched it twice.
- sync:localization-catalog now commits the plural forms a locale's
CLDR rules need beside each _other (fr/es/pt many, tr one, a few
de/ru), and verify:localization-catalog fails when one is missing.
Plural forms may include {{count}} where English omits it.
- Renderer and main load built-in catalogs as-is; plugin packs keep the
runtime fill.
- Renderer catalog requests are shared per locale; a timed-out request
is dropped so a retry fetches again. Bundles are added with skipCopy.
* fix(i18n): require {{count}} in plural forms when English shows it
* chore(i18n): sync plural forms for catalogs merged from main
---------
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
36 lines
1.5 KiB
JavaScript
36 lines
1.5 KiB
JavaScript
import path from 'node:path'
|
|
|
|
// Desktop and mobile ship separate catalogs under one contract: same call shape, key rules and gates.
|
|
export const LOCALIZATION_SURFACES = {
|
|
desktop: {
|
|
localesDir: path.join('src', 'renderer', 'src', 'i18n', 'locales'),
|
|
sourceRoots: [path.join('src', 'renderer', 'src'), path.join('src', 'main')],
|
|
runtimeRequiredPath: path.join('src', 'renderer', 'src', 'i18n', 'en-runtime-required.json'),
|
|
// Desktop runtimes load built-in catalogs as-is; plural forms CLDR adds beyond `_other` are committed.
|
|
fillsPluralForms: true,
|
|
syncCatalogCommand: 'pnpm run sync:localization-catalog',
|
|
syncRuntimeCatalogCommand: 'pnpm run sync:localization-runtime-catalog'
|
|
},
|
|
mobile: {
|
|
localesDir: path.join('mobile', 'src', 'i18n', 'locales'),
|
|
sourceRoots: [
|
|
path.join('mobile', 'app'),
|
|
path.join('mobile', 'src'),
|
|
path.join('mobile', 'web-entry')
|
|
],
|
|
runtimeRequiredPath: path.join('mobile', 'src', 'i18n', 'en-runtime-required.json'),
|
|
syncCatalogCommand: 'pnpm run sync:mobile-localization',
|
|
syncRuntimeCatalogCommand: 'pnpm run sync:mobile-localization'
|
|
}
|
|
}
|
|
|
|
export function readLocalizationSurface(argv) {
|
|
const index = argv.indexOf('--surface')
|
|
const name = index === -1 ? 'desktop' : argv[index + 1]
|
|
const surface = Object.hasOwn(LOCALIZATION_SURFACES, name) ? LOCALIZATION_SURFACES[name] : null
|
|
if (!surface) {
|
|
throw new Error(`Unknown localization surface: ${String(name)}`)
|
|
}
|
|
return surface
|
|
}
|