Skip to content

fix(i18n): resolve count strings with each language's plural rules - #34693

Merged
OrcaWin merged 3 commits into
mainfrom
OrcaWin/i18n-cldr-plurals
Oct 28, 2026
Merged

OrcaWin merged 3 commits into
mainfrom
OrcaWin/i18n-cldr-plurals

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​10 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​9
Prod 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​136 $\color{#cf222e}{\Huge{\mathbf{−}}}$​126 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​10

Closes #12106

What changed

  • translate() in src/renderer/src/i18n/i18n.ts handles keys with a plural suffix. When a call names a literal …_one/…_other key and passes a numeric count, it drops the suffix and resolves the plural family. i18next then picks the CLDR form for the active language. For a plugin pack, that is the language the pack declares, so a pack's _few/_many forms are now used. If a pack has no entry for a category, _other is used, as before. Keys, extraction, call-site shapes and the verify tooling don't change.
  • Built-in catalogs now go through the existing withPluralCategoriesFromOther when they load. CLDR categories they lack (es/fr/pt many) are filled from _other. Before this, very large counts fell back to English.
  • Twelve _one strings hardcoded "1": theme import, workspace batch labels, worktree hiding, dirty-change hint, setup skipped fields and Computer Use permissions. They now interpolate the count placeholder the family's _other already uses, in all 7 catalogs. The related calls that didn't pass count now do. fullCoverage_one keeps its wording. Its es/fr/pt translations say "the only agent" and have no number. It's only reachable when the count is exactly 1.
  • en-runtime-required.json was regenerated. Only those values changed.
  • I added one case to plugin-pack-plurals.test.ts: a literal _one/_other call site in a ru pack renders one/few/many.

Visible changes

  • English output is unchanged. I checked counts 0, 1, 2 and 1e6.
  • fr and pt now treat 0 as singular, as CLDR does, e.g. "0 hôte" instead of "0 hôtes".
  • es, fr and pt counts in the CLDR many range now stay in their language instead of falling back to English.

Not in this PR

About 156 ternaries pick between two unrelated keys, either hashed or Singular/Plural. They still choose the form in JS. Converting them means renaming keys, which invalidates existing pack translations. That is held as a follow-up, along with the plugin rework. The main-process translateMain (1 plural site) is unchanged.

Validation

  • verify:localization-catalogs, verify:localization-extraction, verify:localization-coverage and verify:localization-runtime-catalog pass.
  • tc:web passes.
  • pnpm test src/renderer/src/i18n passes, along with the component tests for the touched files.

translate() now resolves a literal _one/_other key passed a numeric count
through its plural family, so i18next picks the CLDR form for the active
language or plugin pack. Built-in catalogs fill missing plural categories
(e.g. many in es/fr/pt) from _other so large counts stay in-language.
_one strings that hardcoded 1 now interpolate the count.

Closes #12106
@OrcaWin
OrcaWin requested a review from brennanb2025 as a code owner October 28, 2026 03:04
…rpolate the count

Languages with a single plural category (ja/ko/zh) now resolve count 1 to fullCoverage_other, which interpolates {{value0}}.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7c598f1f-2596-481f-8a49-81108e0e14cc
Commits

Reviewing files that changed from the base of the PR and between b6ca0cd and 98431c1.

Files selected for processing: 8
  • src/renderer/src/i18n/en-runtime-required.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/pt.json
  • src/renderer/src/i18n/locales/zh.json
Files skipped from review as they are similar to previous changes: 7
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/i18n/locales/pt.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/ja.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Walkthrough

The translation loader now receives the locale and fills missing plural categories from each catalog key’s _other value. The translation function normalizes plural-suffixed keys when a numeric count is supplied. Renderer call sites now pass counts, and singular messages in runtime-required and locale catalogs interpolate those counts. A test checks plural selection for Russian plugin translations.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 98431

Plural selection and count interpolation are consistent across the changed renderer paths and catalogs, with no merge-blocking risk identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 6.25% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: applying each language's plural rules to count-string resolution.
Description check Passed The description is detailed and covers the change, rationale, linked issue, visible behavior, scope limits, and validation results. It omits several template sections, including ELI5, Visual Proof or …
Linked Issues check Passed Issue #12106 requires renderer plural selection through i18next and correct rules for plugin pack locales. translate() removes a literal plural suffix when count is numeric. The changed renderer c…
Out of Scope Changes check Passed The changed call sites, catalog updates, plural-category fallback, runtime catalog, and plugin test support Issue #12106. The count interpolation changes prevent hard-coded singular values from blocki…
Full details: Description check

Explanation

The description is detailed and covers the change, rationale, linked issue, visible behavior, scope limits, and validation results. It omits several template sections, including ELI5, Visual Proof or an explicit N/A, Review, Agent skill upstream boundary, Notes, and the Checklist, but the core PR information is complete.

Full details: Linked Issues check

Explanation

Issue #12106 requires renderer plural selection through i18next and correct rules for plugin pack locales. translate() removes a literal plural suffix when count is numeric. The changed renderer call sites pass count. pluralResolver.getRule maps synthetic plugin resource languages to the declared locale. The plugin test verifies Russian one, few, and many forms, including literal suffixed keys. Catalog loading fills missing categories from _other. These changes address the stated coding requirements. The issue does not require the documented unrelated-key ternaries or unchanged translateMain sites.

Full details: Out of Scope Changes check

Explanation

The changed call sites, catalog updates, plural-category fallback, runtime catalog, and plugin test support Issue #12106. The count interpolation changes prevent hard-coded singular values from blocking localized plural output. No unrelated change is demonstrated by the reviewed summary or inspected files.

Full details: Docstring Coverage

Explanation

Docstring coverage is 6.25% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 16 functions across 11 files. (8 skipped: 8 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7a61d2c1-ce1b-473b-a3aa-2abdd4d9ac2e
Commits

Reviewing files that changed from the base of the PR and between 6bb0c14 and b6ca0cd.

Files selected for processing: 19
  • src/renderer/src/components/right-sidebar/AiVaultScanProgressStrip.tsx
  • src/renderer/src/components/settings/ComputerUsePane.tsx
  • src/renderer/src/components/settings/OrchestrationSkillAgentCoverage.tsx
  • src/renderer/src/components/settings/WarpThemeImportModal.tsx
  • src/renderer/src/components/settings/useWarpThemeImport.ts
  • src/renderer/src/components/sidebar/DeleteWorktreeDirtyChangeHint.tsx
  • src/renderer/src/components/sidebar/ImportedWorktreesVisibilityLine.tsx
  • src/renderer/src/components/sidebar/SetupScriptPromptCard.tsx
  • src/renderer/src/components/sidebar/workspace-batch-action-labels.ts
  • src/renderer/src/i18n/en-runtime-required.json
  • src/renderer/src/i18n/i18n.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/pt.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/i18n/plugin-pack-plurals.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

export function translate(key: string, fallback: string, options?: TOptions): string {
const value = i18n.t(key, { defaultValue: fallback, ...options })
// Callers name a literal `_one`/`_other` key for extraction; with a count, let CLDR pick the form.
const resolvedKey = typeof options?.count === 'number' ? key.replace(PLURAL_SUFFIX_RE, '') : key

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

rg -n "function loadLocaleCatalog|loadLocaleCatalog|PLURAL_SUFFIX_RE|function translate|pluginLanguage|deleteCount_one|deleteCount_other" src/renderer/src/i18n src/shared/plugins
sed -n '1,190p' src/renderer/src/i18n/i18n.ts
sed -n '1,120p' src/renderer/src/i18n/plugin-pack-plurals.test.ts

Repository: stablyai/orca

Length of output: 14460


Script executed:

set -o pipefail
printf '%s\n' '--- i18n registration and tests ---'
nl -ba src/renderer/src/i18n/i18n.ts | sed -n '175,245p'
printf '%s\n' '--- localization tests mentioning sparse catalogs or literal plural keys ---'
rg -n -F --glob '*.ts' -e 'withPluralCategoriesFromOther' -e 'literal' -e '_one' -e '_other' src/renderer/src/i18n
printf '%s\n' '--- manifest and lock references for i18next ---'
rg -n -F -e '"i18next"' -e 'i18next@' -e 'node_modules/i18next' package.json pnpm-lock.yaml yarn.lock package-lock.json 2>/dev/null || true
printf '%s\n' '--- installed dependency source, if present ---'
if [ -f node_modules/i18next/src/Translator.js ]; then
  nl -ba node_modules/i18next/src/Translator.js | sed -n '1,260p'
elif [ -f node_modules/i18next/dist/esm/Translator.js ]; then
  nl -ba node_modules/i18next/dist/esm/Translator.js | sed -n '1,260p'
else
  printf '%s\n' 'i18next Translator source not present in checkout'
fi

Repository: stablyai/orca

Length of output: 3897


Script executed:

set -o pipefail
printf '%s\n' '--- plugin catalog type and registration contract ---'
nl -ba src/shared/plugins/plugin-language-pack-artifact.ts | sed -n '1,90p'
nl -ba src/shared/plugins/plugin-content-pack-contributions.ts | sed -n '1,85p'
printf '%s\n' '--- all declarations of PluginLanguagePackRegistration ---'
rg -n -F --glob '*.{ts,tsx}' 'PluginLanguagePackRegistration' src shared 2>/dev/null || true

Repository: stablyai/orca

Length of output: 9024


Web query:

i18next v26.4.2 Translator.js plural suffix fallback raw source

Result:

<source_evidence>
<source kind="find_in_page">
<title></title>
<location>https://raw.githubusercontent.com/i18next/i18next/4dba50f/src/Translator.js</location>
<excerpt>citeturn2view2 [wordlim: 200] Crawled: today; Content type: text/plain; Source: find({&quot;ref_id&quot;:&quot;turn1view0&quot;,&quot;pattern&quot;:&quot;plural&quot;}); Total lines: 602
L408:       if (opt.interpolation) this.interpolator.reset();
L409:     }
L410: 
L411:     // post process
L412:     const postProcess = opt.postProcess || this.options.postProcess;
L413:     const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
L414:     if (res != null &amp;&amp; postProcessorNames?.length &amp;&amp; opt.applyPostProcessor !== false) {
L415:       res = postProcessor.handle(
L416:         postProcessorNames,
L417:         res,
L418:         key,
L419:         this.options &amp;&amp; this.options.postProcessPassResolved
L420:           ? {
L421:               i18nResolved: { ...resolved, usedParams: this.getUsedParamsDetails(opt) },
L422:               ...opt,
L423:             }
L424:           : opt,
L425:         this,
L426:       );
L427:     }
L428: 
L429:     return res;
L430:   }
L431:   resolve(keys, opt = {}) {
L432:     let found;
L433:     let usedKey; // plain key
L434:     let exactUsedKey; // key with context / plural
L435:     let usedLng;
L436:     let usedNS;
L437: 
L438:     if (isString(keys)) keys = [keys];
L439:     if (Array.isArray(keys))
L440:       keys = keys.map((k) =&gt;
L441:         typeof k === &#39;function&#39; ? keysFromSelector(k, { ...this.options, ...opt }) : k,
L442:       );
L443:     // forEach possible key
L444:     keys.forEach((k) =&gt; {
L445:       if (this.isValidLookup(found)) return;
L446:       const extracted = this.extractFromKey(k, opt);
L447:       const key = extracted.key;
L448:       usedKey = key;
L449:       let namespaces = extracted.namespaces;
L450:       if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
L451:       const needsPluralHandling = opt.count !== undefined &amp;&amp; !isString(opt.count);
L452:       const needsZeroSuffixLookup = needsPluralHandling &amp;&amp; !opt.ordinal &amp;&amp; opt.count === 0;
L453:       const needsContextHandling =
L454:         opt.context !== undefined &amp;&amp;
L455:         (isString(opt.context) || typeof opt.context === &#39;number&#39;) &amp;&amp;
L456:         opt.context !== &#39;&#39;;
L457: 
L458:       const codes = opt.lngs
L459:         ? opt.lngs
L460:         : this.languageUtils.toResolveHierarchy(opt.lng || this.language, opt.fallbackLng);
L461:       namespaces.forEach((ns) =&gt; {
L462:         if (this.isValidLookup(found)) return;
L463:         usedNS = ns;
L464:         if (
L465:           !this.checkedLoadedFor[`${codes[0]}-${ns}`] &amp;&amp;
L466:           this.utils?.hasLoadedNamespace &amp;&amp;
L467:           !this.utils?.hasLoadedNamespace(usedNS)
L468:         ) {
L469:           this.checkedLoadedFor[`${codes[0]}-${ns}`] = true;
L470:           this.logger.warn(
L471:             `key &quot;${usedKey}&quot; for languages &quot;${codes.join(
L472:               &#39;, &#39;,
L473:             )}&quot; won&#39;t get resolved as namespace &quot;${usedNS}&quot; was not yet loaded`,
L474:             &#39;This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!&#39;,
L475:           );
L476:         }
L477:         codes.forEach((code) =&gt; {
L478:           if (this.isValidLookup(found)) return;
L479:           usedLng = code;
L480: 
L481:           const finalKeys = [key];
L482:           if (this.i18nFormat?.addLookupKeys) {
L483:             this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, opt);
L484:           } else {
L485:             let pluralSuffix;
L486:             if (needsPluralHandling)
L487:               pluralSuffix = this.pluralResolver.getSuffix(code, opt.count, opt);
L488:             const zeroSuffix = `${this.options.pluralSeparator}zero`;
L489:             const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
L490:             // get key for plural if needed
L491:             if (needsPluralHandling) {
L492:               if (opt.ordinal &amp;&amp; pluralSuffix.startsWith(ordinalPrefix)) {
L493:                 finalKeys.push(
L494:                   key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator),
L495:                 );
L496:               }
L497:               finalKeys.push(key + pluralSuffix);
L498:               if (needsZeroSuffixLookup) {
L499:                 finalKeys.push(key + zeroSuffix);
L500:               }
L501:             }
L502:             // get key for context if needed
L503:             if (needsContextHandling) {
L504:               const contextKey = `${key}${this.options.contextSeparator || &#39;_&#39;}${opt.context}`;
L505:               finalKeys.push(contextKey);
L506:               // get key for context + plural if needed
L507:               if (needsPluralHandling) {
L508:                 if (opt.ordinal &amp;&amp; pluralSuffix.startsWith(ordinalPrefix)) {
L509:                   finalKeys.push(
L510:                     contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator),
L511:                   );
L512:                 }
L513:                 finalKeys.push(contextKey + pluralSuffix);
L514:                 if (needsZeroSuffixLookup) {
L515:                   finalKeys.push(contextKey + zeroSuffix);
L516:                 }
L517:               }
L518:             }
L519:           }
L520:           // iterate over finalKeys starting with most specific pluralkey (-&gt; contextkey only) -&gt; singularkey only
L521:           let possibleKey;
L522:           while ((possibleKey = finalKeys.pop())) {
L523:             if (!this.isValidLookup(found)) {
L524:               exactUsedKey = possibleKey;
L525:               found = this.getResource(code, ns, possibleKey, opt);
L526:             }
L527:           }
L528:         });
L529:       });
L530:     });
L531: 
L532:     return { res: found, usedKey, exactUsedKey, usedLng, usedNS };
L533:   }
L534:   isValidLookup(res) {
L535:     return (
L536:       res !== undefined &amp;&amp;
L537:       !(!this.options.returnNull &amp;&amp; res === null) &amp;&amp;
L538:       !(!this.options.returnEmptyString &amp;&amp; res === &#39;&#39;)
L539:     );
L540:   }
L541: 
L542:   getResource(code, ns, key, options = {}) {
L543:     if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options);
L544:     return this.resourceStore.getResource(code, ns, key, options);
L545:   }
L546:   getUsedParamsDetails(options = {}) {
L547:     // we need to remember to extend this array whenever new option properties are added
L548:     const optionsKeys = [
L549:       &#39;defaultValue&#39;,
L550:       &#39;ordinal&#39;,
L551:       &#39;context&#39;,
L552:       &#39;replace&#39;,
L553:       &#39;lng&#39;,
L554:       &#39;lngs&#39;,
L555:       &#39;fallbackLng&#39;,
L556:       &#39;ns&#39;,
L557:       &#39;keySeparator&#39;,
L558:       &#39;nsSeparator&#39;,
L559:       &#39;returnObjects&#39;,
L560:       &#39;returnDetails&#39;,
L561:       &#39;joinArrays&#39;,
L562:       &#39;postProcess&#39;,
L563:       &#39;interpolation&#39;,
L564:     ];
L565:     const useOptionsReplaceForData = options.replace &amp;&amp; !isString(options.replace);
L566:     let data = useOptionsReplaceForData ? options.replace : options;
L567:     if (useOptionsReplaceForData &amp;&amp; typeof options.count !== &#39;undefined&#39;) {
L568:       data = { ...data, count: options.count };
L569:     }
L570: 
L571:     if (this.options.interpolation.defaultVariables) {
L572:       data = { ...this.options.interpolation.defaultVariables, ...data };
L573:     }
L574:     // avoid reporting options (execpt count) as usedParams
L575:     if (!useOptionsReplaceForData) {
L576:       data = { ...data };
L577:       for (const key of optionsKeys) {
L578:         delete data[key];
L579:       }
L580:     }
L581: 
L582:     return data;
L583:   }
L584: 
L585:   static hasDefaultValue(options) {
L586:     const prefix = &#39;defaultValue&#39;;
L587:     for (const option in options) {
L588:       if (
L589:         Object.prototype.hasOwnProperty.call(options, option) &amp;&amp;
L590:         option.startsWith(prefix) &amp;&amp;
L591:         undefined !== options[option]
L592:       ) {
L593:         return true;
L594:       }
L595:     }
L596: 
L597:     return false;
L598:   }
L599: }
L600: 
L601: export default Translator;
</excerpt>
</source>
<source kind="open_page">
<title></title>
<location>https://raw.githubusercontent.com/i18next/i18next/4dba50f/src/Translator.js</location>
<excerpt>citeturn1view0 [wordlim: 200] Crawled: today; Content type: text/plain; Source: open({&quot;ref_id&quot;:&quot;https://raw.githubusercontent.com/i18next/i18next/4dba50f/src/Translator.js&quot;,&quot;lineno&quot;:null}); Total lines: 602
L0: import baseLogger from &#39;./logger.js&#39;;
L1: import EventEmitter from &#39;./EventEmitter.js&#39;;
L2: import postProcessor from &#39;./postProcessor.js&#39;;
L3: import { copy as utilsCopy, looksLikeObjectPath, isString } from &#39;./utils.js&#39;;
L4: import keysFromSelector from &#39;./selector.js&#39;;
L5: 
L6: const shouldHandleAsObject = (res) =&gt;
L7:   !isString(res) &amp;&amp; typeof res !== &#39;boolean&#39; &amp;&amp; typeof res !== &#39;number&#39;;
L8: 
L9: class Translator extends EventEmitter {
L10:   constructor(services, options = {}) {
L11:     super();
L12:     utilsCopy(
L13:       [
L14:         &#39;resourceStore&#39;,
L15:         &#39;languageUtils&#39;,
L16:         &#39;pluralResolver&#39;,
L17:         &#39;interpolator&#39;,
L18:         &#39;backendConnector&#39;,
L19:         &#39;i18nFormat&#39;,
L20:         &#39;utils&#39;,
L21:       ],
L22:       services,
L23:       this,
L24:     );
L25: 
L26:     this.options = options;
L27:     if (this.options.keySeparator === undefined) {
L28:       this.options.keySeparator = &#39;.&#39;;
L29:     }
L30: 
L31:     this.logger = baseLogger.create(&#39;translator&#39;);
L32: 
L33:     this.checkedLoadedFor = {};
L34:   }
L35: 
L36:   changeLanguage(lng) {
L37:     if (lng) this.language = lng;
L38:   }
L39:   exists(key, o = { interpolation: {} }) {
L40:     const opt = { ...o };
L41:     if (key == null) return false;
L42:     const resolved = this.resolve(key, opt);
L43: 
L44:     // If no resource found, return false
L45:     if (resolved?.res === undefined) return false;
L46: 
L47:     // Check if the resolved resource is an object
L48:     const isObject = shouldHandleAsObject(resolved.res);
L49:     // If returnObjects is explicitly set to false and the resource is an object, return false
L50:     if (opt.returnObjects === false &amp;&amp; isObject) {
L51:       return false;
L52:     }
L53: 
L54:     // Otherwise return true (resource exists)
L55:     return true;
L56:   }
L57: 
L58:   extractFromKey(key, opt) {
L59:     let nsSeparator = opt.nsSeparator !== undefined ? opt.nsSeparator : this.options.nsSeparator;
L60:     if (nsSeparator === undefined) nsSeparator = &#39;:&#39;;
L61:     const keySeparator =
L62:       opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
L63:     let namespaces = opt.ns || this.options.defaultNS || [];
L64:     const wouldCheckForNsInKey = nsSeparator &amp;&amp; key.includes(nsSeparator);
L65:     const seemsNaturalLanguage =
L66:       !this.options.userDefinedKeySeparator &amp;&amp;
L67:       !opt.keySeparator &amp;&amp;
L68:       !this.options.userDefinedNsSeparator &amp;&amp;
L69:       !opt.nsSeparator &amp;&amp;
L70:       !looksLikeObjectPath(key, nsSeparator, keySeparator);
L71:     if (wouldCheckForNsInKey &amp;&amp; !seemsNaturalLanguage) {
L72:       const m = key.match(this.interpolator.nestingRegexp);
L73:       if (m &amp;&amp; m.length &gt; 0) {
L74:         return {
L75:           key,
L76:           namespaces: isString(namespaces) ? [namespaces] : namespaces,
L77:         };
L78:       }
L79:       const parts = key.split(nsSeparator);
L80:       if (
L81:         nsSeparator !== keySeparator ||
L82:         (nsSeparator === keySeparator &amp;&amp; this.options.ns.includes(parts[0]))
L83:       )
L84:         namespaces = parts.shift();
L85:       key = parts.join(keySeparator);
L86:     }
L87:     return {
L88:       key,
L89:       namespaces: isString(namespaces) ? [namespaces] : namespaces,
L90:     };
L91:   }
L92: 
L93:   translate(keys, o, lastKey) {
L94:     let opt = typeof o === &#39;object&#39; ? { ...o } : o;
L95:     if (typeof opt !== &#39;object&#39; &amp;&amp; this.options.overloadTranslationOptionHandler) {
L96:       opt = this.options.overloadTranslationOptionHandler(arguments);
L97:     }
L98:     if (typeof opt === &#39;object&#39;) opt = { ...opt };
L99:     if (!opt) opt = {};
L100:     // non valid keys handling
L101:     if (keys == null /* || keys === &#39;&#39; */) return &#39;&#39;;
L102:     if (typeof keys === &#39;function&#39;) keys = keysFromSelector(keys, { ...this.options, ...opt });
L103:     if (!Array.isArray(keys)) keys = [String(keys)];
L104:     keys = keys.map((k) =&gt;
L105:       typeof k === &#39;function&#39; ? keysFromSelector(k, { ...this.options, ...opt }) : String(k),
L106:     );
L107: 
L108:     const returnDetails =
L109:       opt.returnDetails !== undefined ? opt.returnDetails : this.options.returnDetails;
L110:     // separators
L111:     const keySeparator =
L112:       opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
L113: 
L114:     // get namespace(s)
L115:     const { key, namespaces } = this.extractFromKey(keys[keys.length - 1], opt);
L116:     const namespace = namespaces[namespaces.length - 1];
L117: 
L118:     let nsSeparator = opt.nsSeparator !== undefined ? opt.nsSeparator : this.options.nsSeparator;
L119:     if (nsSeparator === undefined) nsSeparator = &#39;:&#39;;
L120:     // return key on CIMode
L121:     const lng = opt.lng || this.language;
L122:     const appendNamespaceToCIMode =
L123:       opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
L124:     if (lng?.toLowerCase() === &#39;cimode&#39;) {
L125:       if (appendNamespaceToCIMode) {
L126:         if (returnDetails) {
L127:           return {
L128:             res: `${namespace}${nsSeparator}${key}`,
L129:             usedKey: key,
L130:             exactUsedKey: key,
L131:             usedLng: lng,
L132:             usedNS: namespace,
L133:             usedParams: this.getUsedParamsDetails(opt),
L134:           };
L135:         }
L136:         return `${namespace}${nsSeparator}${key}`;
L137:       }
L138:       if (returnDetails) {
L139:         return {
L140:           res: key,
L141:           usedKey: key,
L142:           exactUsedKey: key,
L143:           usedLng: lng,
L144:           usedNS: namespace,
L145:           usedParams: this.getUsedParamsDetails(opt),
L146:         };
L147:       }
L148:       return key;
L149:     }
L150: 
L151:     // resolve from store
L152:     const resolved = this.resolve(keys, opt);
L153:     let res = resolved?.res;
L154:     const resUsedKey = resolved?.usedKey || key;
L155:     const resExactUsedKey = resolved?.exactUsedKey || key;
L156:     const noObject = [&#39;[object Number]&#39;, &#39;[object Function]&#39;, &#39;[object RegExp]&#39;];
L157:     const joinArrays = opt.joinArrays !== undefined ? opt.joinArrays : this.options.joinArrays;
L158:     // object
L159:     const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
L160:     const needsPluralHandling = opt.count !== undefined &amp;&amp; !isString(opt.count);
L161:     const hasDefaultValue = Translator.hasDefaultValue(opt);
L162:     const defaultValueSuffix = needsPluralHandling
L163:       ? this.pluralResolver.getSuffix(lng, opt.count, opt)
L164:       : &#39;&#39;;
L165:     const defaultValueSuffixOrdinalFallback =
L166:       opt.ordinal &amp;&amp; needsPluralHandling
</excerpt>
</source>
<source kind="open_page">
<title>i18next/src/Translator.js at 4dba50f20669c3678db0812255716eb7693ad2da · i18next/i18next · GitHub</title>
<location>https://github.com/i18next/i18next/blob/4dba50f/src/Translator.js</location>
<excerpt>citeturn1view1 [wordlim: 200] Crawled: today; Content type: text/html; Source: open({&quot;ref_id&quot;:&quot;https://github.com/i18next/i18next/blob/4dba50f/src/Translator.js&quot;,&quot;lineno&quot;:null}); Total lines: 2579
L0: 【0†Skip to content】
L1: ## Navigation Menu
L2: 
L3: 【1†Sign in】
L4: 
L5: Appearance settings
L6: 
L7:   * Platform
L8: 
L9:     * AI CODE CREATION
L10:       * 【2†GitHub CopilotWrite better code with AI】
L11:       * 【3†GitHub Copilot appDirect agents from issue to merge】
L12:       * 【4†MCP RegistryIntegrate external tools】
L13: 
L14:     * DEVELOPER WORKFLOWS
L15:       * 【5†ActionsAutomate any workflow】
L16:       * 【6†CodespacesInstant dev environments】
L17:       * 【7†IssuesPlan and track work】
L18:       * 【8†Code ReviewManage code changes】
L19:       * 【9†Code QualityEnforce quality at merge】
L20:     * APPLICATION SECURITY
L21:       * 【10†GitHub Advanced SecurityFind and fix vulnerabilities】
L22:       * 【11†Code securitySecure your code as you build】
L23:       * 【12†Secret protectionStop leaks before they start】
L24: 
L25:     * EXPLORE
L26:       * 【13†Why GitHub】
L27:       * 【14†Documentation†docs.github.com】
L28:       * 【15†Blog†github.blog】
L29:       * 【16†Changelog†github.blog】
L30:       * 【17†Marketplace】
L31: 
L32: 【18†View all features】
L33: 
L34:   * Solutions
L35:     * BY COMPANY SIZE
L36:       * 【19†Enterprises】
L37:       * 【20†Small and medium teams】
L38:       * 【21†Startups】
L39:       * 【22†Nonprofits】
L40: 
L41:     * BY USE CASE
L42:       * 【23†App Modernization】
L43:       * 【24†DevSecOps】
L44:       * 【25†DevOps】
L45:       * 【26†CI/CD】
L46:       * 【27†View all use cases】
L47: 
L48:     * BY INDUSTRY
L49:       * 【28†Healthcare】
L50:       * 【29†Financial services】
L51:       * 【30†Manufacturing】
L52:       * 【31†Government】
L53:       * 【32†See all industries】
L54: 
L55: 【33†View all solutions】
L56: 
L57:   * Resources
L58:     * EXPLORE BY TOPIC
L59:       * 【34†AI】
L60:       * 【35†Software Development】
L61:       * 【36†DevOps】
L62:       * 【37†Security】
L63:       * 【38†View all topics】
L64: 
L65:     * EXPLORE BY TYPE
L66:       * 【39†Customer stories】
L67:       * 【40†Events &amp; webinars】
L68:       * 【41†Ebooks &amp; reports】
L69:       * 【42†Business insights】
L70:       * 【43†GitHub Skills†skills.github.com】
L71:     * SUPPORT &amp; SERVICES
L72:       * 【14†Documentation†docs.github.com】
L73:       * 【44†Customer support†support.github.com】
L74:       * 【45†Community forum】
L75:       * 【46†Trust center】
L76:       * 【47†Partners】
L77: 
L78: 【48†View all resources】
L79: 
L80:   * Open Source
L81: 
L82:     * COMMUNITY
L83:       * 【49†GitHub SponsorsFund open source developers】
L84:     * PROGRAMS
L85:       * 【50†Security Lab†securitylab.github.com】
L86:       * 【51†Maintainer Community†maintainers.github.com】
L87:       * 【52†GitHub Stars†stars.github.com】
L88:       * 【53†Archive Program†archiveprogram.github.com】
L89: 
L90:     * REPOSITORIES
L91:       * 【54†Topics】
L92:       * 【55†Trending】
L93:       * 【56†Collections】
L94: 
L95:   * Enterprise
L96: 
L97:     * ENTERPRISE SOLUTIONS
L98:       * 【19†Enterprise platformAI-powered developer platform】
L99:     * AVAILABLE ADD-ONS
L100:       * 【10†GitHub Advanced SecurityEnterprise-grade security features】
L101:       * 【57†Copilot for BusinessEnterprise-grade AI features】
L102:       * 【58†Premium SupportEnterprise-grade 24/7 support】
L103: 
L104:   * 【59†Pricing】
L105: 
L106: Search`/`
L107: 
L108: 【1†Sign in】
L109: 
L110: 【60†Sign up】
L111: 
L112: Appearance settings
L113: You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
L114: 
L115:   1. 【61†i18next】
L116:   2. 【62†i18next】
L117: ## Repository navigation
L118: 
L119:   *   * 【62†Code】
L120:   * 【63†Issues1 (1)】
L121:   * 【64†Pull requests】
L122:   * 【65†Discussions】
L123:   * 【66†Actions】
L124:   * 【67†Projects】
L125:   * 【68†Security and quality2 (2)】
L126:   * 【69†Insights】
L127: 
L128: More items
L129: 
L130: ## Files Expand file tree
L131: 
L132: 4dba50f20669c3678db0812255716eb7693ad2da
L133: 
L134: ## Breadcrumbs
L135: 
L136:   1. 【70†i18next】
L137:   2. /【71†src】
L138: 
L139: /
L140: 
L141: # Translator.js
L142: 
L143: Copy path
L144: 
L145: [Input: Go to file]
L146: 
L147: Blame More file actions
L148: 
L149: Blame More file actions
L150: 
L151: ## Latest commit
L152: 
L153: 
L154: 
L155: ## History
L156: 
L157: History
L158: 
L159: 4dba50f
L160: ## Breadcrumbs
L161: 
L162:   1. 【70†i18next】
L163:   2. /【71†src】
L164: 
L165: /
L166: 
L167: # Translator.js
L168: 
L169: Copy path
L170: 
L171: Top
L172: ## File metadata and controls
L173: 
L174:   * Code
L175: 
L176:   * Blame
L177: 
L178: 645 lines (571 loc) · 21.7 KB
L179: 
L180: 【72†Raw】
L181: 
L182: Copy raw file
L183: 
L184: Download raw file
L185: 
L186: Open symbols panel
L187: 
L188: Edit and raw actions
L189: 
L190: 1
L191: 
L192: 2
L193: 
L194: 3
L195: 
L196: 4
L197: 
L198: 5
L199: 
L200: 6
L201: 
L202: 7
L203: 
L204: 8
L205: 
L206: 9
L207: 
L208: 10
L209: 
L210: 11
L211: 
L212: 12
L213: 
L214: 13
L215: 
L216: 14
L217: 
L218: 15
L219: 
L220: 16
L221: 
L222: 17
L223: 
L224: 18
L225: 
L226: 19
L227: 
L228: 20
L229: 
L230: 21
L231: 
L232: 22
L233: 
L234: 23
L235: 
L236: 24
L237: 
L238: 25
L239: 
L240: 26
L241: 
L242: 27
L243: 
L244: 28
L245: 
L246: 29
L247: 
L248: 30
L249: 
L250: 31
L251: 
L252: 32
L253: 
L254: 33
L255: 
L256: 34
L257: 
L258: 35
L259: 
L260: 36
L261: 
L262: 37
L263: 
L264: 38
L265: 
L266: 39
L267: 
L268: 40
L269: 
L270: 41
L271: 
L272: 42
L273: 
L274: 43
L275: 
L276: 44
L277: 
L278: 45
L279: 
L280: 46
L281: 
L282: 47
L283: 
L284: 48
L285: 
L286: 49
L287: 
L288: 50
L289: 
L290: 51
L291: 
L292: 52
L293: 
L294: 53
L295: 
L296: 54
L297: 
L298: 55
L299: 
L300: 56
L301: 
L302: 57
L303: 
L304: 58
L305: 
L306: 59
L307: 
L308: 60
L309: 
L310: 61
L311: 
L312: 62
L313: 
L314: 63
L315: 
L316: 64
L317: 
L318: 65
L319: 
L320: 66
L321: 
L322: 67
L323: 
L324: 68
L325: 
L326: 69
L327: 
L328: 70
L329: 
L330: 71
L331: 
L332: 72
L333: 
L334: 73
L335: 
L336: 74
L337: 
L338: 75
L339: 
L340: 76
L341: 
L342: 77
L343: 
L344: 78
L345: 
L346: 79
L347: 
L348: 80
L349: 
L350: 81
L351: 
L352: 82
L353: 
L354: 83
L355: 
L356: 84
L357: 
L358: 85
L359: 
L360: 86
L361: 
L362: 87
L363: 
L364: 88
L365: 89
L366: 
L367: 90
L368: 
L369: 91
L370: 
L371: 92
L372: 
L373: 93
L374: 
L375: 94
L376: 
L377: 95
L378: 
L379: 96
L380: 
L381: 97
L382: 
L383: 98
L384: 
L385: 99
L386: 
L387: 100
L388: 
L389: 101
L390: 
L391: 102
L392: 
L393: 103
L394: 
L395: 104
L396: 
L397: 105
L398: 
L399: 106
L400: 
L401: 107
L402: 
L403: 108
L404: 
L405: 109
L406: 
L407: 110
L408: 
L409: 111
L410: 
L411: 112
L412: 
L413: 113
L414: 
L415: 114
L416: 
L417: 115
L418: 
L419: 116
L420: 
L421: 117
L422: 
L423: 118
L424: 
L425: 119
L426: 
L427: 120
L428: 
L429: 121
L430: 
L431: 122
L432: 
L433: 123
L434: 
L435: 124
L436: 
L437: 125
L438: 
L439: 126
L440: 
L441: 127
L442: 
L443: 128
L444: 
L445: 129
L446: 
L447: 130
L448: 
L449: 131
L450: 
L451: 132
L452: 
L453: 133
L454: 
L455: 134
L456: 
L457: 135
L458: 
L459: 136
L460: 
L461: 137
L462: 
L463: 138
L464: 
L465: 139
L466: 
L467: 140
L468: 
L469: 141
L470: 
L471: 142
L472: 
L473: 143
L474: 
L475: 144
L476: 
L477: 145
L478: 
L479: 146
L480: 
L481: 147
L482: 
L483: 148
L484: 
L485: 149
L486: 
L487: 150
L488: 
L489: 151
L490: 
L491: 152
L492: 
L493: 153
L494: 
L495: 154
L496: 
L497: 155
L498: 
L499: 156
L500: 
L501: 157
L502: 
L503: 158
L504: 
L505: 159
L506: 
L507: 160
L508: 
L509: 161
L510: 
L511: 162
L512: 
L513: 163
L514: 
L515: 164
L516: 
L517: 165
L518: 
L519: 166
L520: 
L521: 167
L522: 
L523: 168
L524: 
L525: 169
L526: 
L527: 170
L528: 
L529: 171
L530: 
L531: 172
L532: 
L533: 173
L534: 
L535: 174
L536: 
L537: 175
L538: 
L539: 176
L540: 
L541: 177
L542: 
L543: 178
L544: 
L545: 179
L546: 
L547: 180
L548: 
L549: 181
L550: 
L551: 182
L552: 
L553: 183
L554: 
L555: 184
L556: 
L557: 185
L558: 
L559: 186
L560: 
L561: 187
L562: 
L563: 188
L564: 
L565: 189
L566: 
L567: 190
L568: 
L569: 191
L570: 
L571: 192
L572: 193
L573: 
L574: 194
L575: 
L576: 195
L577: 
L578: 196
L579: 
L580: 197
L581: 
L582: 198
L583: 
L584: 199
L585: 
L586: 200
L587: 
L588: 201
L589: 
L590: 202
L591: 
L592: 203
L593: 
L594: 204
L595: 
L596: 205
L597: 
L598: 206
L599: 
L600: 207
L601: 
L602: 208
L603: 
L604: 209
L605: 
L606: 210
L607: 
L608: 211
L609: 
L610: 212
L611: 
L612: 213
L613: 
L614: 214
L615: 
L616: 215
L617: 
L618: 216
L619: 
L620: 217
L621: 
L622: 218
L623: 
L624: 219
L625: 
L626: 220
L627: 
L628: 221
L629: 
L630: 222
L631: 
L632: 223
L633: 
L634: 224
L635: 
L636: 225
L637: 
L638: 226
L639: 
L640: 227
L641: 
L642: 228
L643: 
L644: 229
L645: 
L646: 230
L647: 
L648: 231
L649: 
L650: 232
L651: 
L652: 233
L653: 
L654: 234
L655: 
L656: 235
L657: 
L658: 236
L659: 
L660: 237
L661: 
L662: 238
L663: 
L664: 239
L665: 
L666: 240
L667: 
L668: 241
L669: 
L670: 242
L671: 
L672: 243
L673: 
L674: 244
L675: 
L676: 245
L677: 
L678: 246
L679: 
L680: 247
L681: 
L682: 248
L683: 
L684: 249
L685: 
L686: 250
L687: 
L688: 251
L689: 
L690: 252
L691: 
L692: 253
L693: 
L694: 254
L695: 
L696: 255
L697: 
L698: 256
L699: 
L700: 257
L701: 
L702: 258
L703: 
L704: 259
L705: 
L706: 260
L707: 
L708: 261
L709: 
L710: 262
L711: 
L712: 263
L713: 
L714: 264
L715: 
L716: 265
L717: 
L718: 266
L719: 
L720: 267
L721: 
L722: 268
L723: 
L724: 269
L725: 
L726: 270
L727: 
L728: 271
L729: 
L730: 272
L731: 
L732: 273
L733: 
L734: 274
L735: 
L736: 275
L737: 
L738: 276
L739: 
L740: 277
L741: 
L742: 278
L743: 
L744: 279
L745: 
L746: 280
L747: 
L748: 281
L749: 
L750: 282
L751: 
L752: 283
L753: 
L754: 284
L755: 
L756: 285
L757: 
L758: 286
L759: 
L760: 287
L761: 
L762: 288
L763: 
L764: 289
L765: 
L766: 290
L767: 
L768: 291
L769: 
L770: 292
L771: 
L772: 293
L773: 
L774: 294
L775: 295
L776: 
L777: 296
L778: 
L779: 297
L780: 
L781: 298
L782: 
L783: 299
L784: 
L785: 300
L786: 
L787: 301
L788: 
L789: 302
L790: 
L791: 303
L792: 
L793: 304
L794: 
L795: 305
L796: 
L797: 306
L798: 
L799: 307
L800: 
L801: 308
L802: 
L803: 309
L804: 
L805: 310
L806: 
L807: 311
L808: 
L809: 312
L810: 
L811: 313
L812: 
L813: 314
L814: 
L815: 315
L816: 
L817: 316
L818: 
L819: 317
L820: 
L821: 318
L822: 
L823: 319
L824: 
L825: 320
L826: 
L827: 321
L828: 
L829: 322
L830: 
L831: 323
L832: 
L833: 324
L834: 
L835: 325
L836: 
L837: 326
L838: 
L839: 327
L840: 
L841: 328
L842: 
L843: 329
L844: 
L845: 330
L846: 
L847: 331
L848: 
L849: 332
L850: 
L851: 333
L852: 
L853: 334
L854: 
L855: 335
L856: 
L857: 336
L858: 
L859: 337
L860: 
L861: 338
L862: 
L863: 339
L864: 
L865: 340
L866: 
L867: 341
L868: 
L869: 342
L870: 
L871: 343
L872: 
L873: 344
L874: 
L875: 345
L876: 
L877: 346
L878: 
L879: 347
L8…[truncated]</excerpt>
</source>
<source kind="search">
<title>Releases · i18next/i18next · GitHub</title>
<location>https://github.com/i18next/i18next/releases</location>
<excerpt>citeturn0search0 [wordlim: 200] Crawled: 3 weeks ago;   * v26.4.2 ... The cache is invalidated automatically when `options.fallbackLng` changes (reassignment or in-place array mutation); if you mutate other resolution-relevant options at runtime (`load`, `lowerCaseLng`, `cleanCode`, `nonExplicitSupportedLngs`), call `i18next.services.languageUtils.clearCache()` afterwards. ... Removed the unused `coveralls` package (CI uses the Coveralls GitHub Action) and replaced `sinon` with `nise` + `vitest.spyOn` in the v1 compatibility tests, which resolves all open `npm audit` findings (0 vulnerabilities) and should close the dependabot alerts on the lockfile.

View all tags

Image: @adrai adrai released this 03 Sep 19:26

v26.4.2

`4dba50f`

  * fix: `$&amp;`, `$``, `$&#39;` and `$$` inside a nested value (`$t(key)`) now stay literal. `nest()` handed the resolved value straight to `String.replace` as the replacement argument, so those sequences were read as replacement patterns: `$&amp;` re-inserted the `$t(...)` match, `$`` / `$&#39;` inserted the text before / after it, and `$$` collapsed to `$`. Through `t()` the `$&amp;` case was worse than a wrong string: the nested lookup resets the shared nesting regexp, so the re-inserted `$t(...)` was matched again on every pass and `t()` never returned — also under the default `escapeValue: true` when the value arrives via a variable forwarded through nesting options (`$t(key, { &quot;name&quot;: &quot;{{name}}&quot; })` with a name containing `$&amp;`). The value is now `$`-escaped at the `String.replace` call, the same guard `interpolate()` already has, and a non-string value returned by a formatter in the nesting chain (`$t(key, myFormat)`) is stringified before that. Nested values are still not HTML-escaped (#854). Thanks @mahirhir (#2447).

### Contributors

  * mahirhir

Assets 2

## v26.4.1

v26.4.1

Compare

</excerpt>
</source>
<source kind="search">
<title>i18next/package.json at master · i18next/i18next · GitHub</title>
<location>https://github.com/i18next/i18next/blob/master/package.json</location>
<excerpt>citeturn0search1 [wordlim: 200] Crawled: 4 weeks ago; &quot;version&quot;: &quot;26.4.2&quot;, ... &quot;module&quot;: &quot;./dist/esm/i18next.js&quot;, ... &quot;url&quot;: &quot;https://github.com/i18next/i18next.git&quot;
</excerpt>
</source>
<omitted_sources count="21">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>

Citations:

- 1: https://github.com/i18next/i18next/releases?utm_source=openai
- 2: https://raw.githubusercontent.com/i18next/i18next/4dba50f/src/Translator.js
- 3: https://raw.githubusercontent.com/i18next/i18next/4dba50f/src/Translator.js
- 4: https://raw.githubusercontent.com/i18next/i18next/4dba50f/src/Translator.js

Preserve translations from sparse plugin packs.

For a Japanese plugin pack, Intl.PluralRules('ja') selects other, including for count: 1. translate() removes the literal _one suffix before calling i18next, so i18next requests deleteCount_other. The normalizer only fills missing categories from an existing _other value. A pack containing only deleteCount_one therefore skips the existing plugin translation and can return the English fallback.

Preserve the original literal-key translation when the selected category is absent from the active plugin pack. Packs that contain both _one and _other remain covered by the existing _other backfill.


Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

rg -n "deleteWorkspacesCountLabel|deleteCount_one|deleteCount_other|plugin.*language|language.*pack|count:" src/renderer/src/i18n src/renderer/src/components src/shared/plugins
sed -n '85,115p' src/renderer/src/i18n/i18n.ts
sed -n '1,180p' src/shared/plugins/plugin-language-pack-artifact.ts

Repository: stablyai/orca

Length of output: 41858


Script executed:

set -o pipefail
printf '%s\n' '--- i18n relevant declarations and functions ---'
rg -n -F -e 'export function translate' -e 'function loadLocaleCatalog' -e 'loadLocaleCatalog(' -e 'pluralLocaleByResourceLanguage' -e 'loadRendererUiLanguage' -e 'resolveRendererResourceLanguage' -e 'pluginLanguagePacks' src/renderer/src/i18n/i18n.ts
sed -n '1,260p' src/renderer/src/i18n/i18n.ts
printf '%s\n' '--- delete label implementation and caller ---'
sed -n '1,110p' src/renderer/src/components/sidebar/workspace-batch-action-labels.ts
sed -n '1,80p' src/renderer/src/components/sidebar/DeleteWorktreeDialogFooter.tsx
printf '%s\n' '--- plugin plural tests ---'
sed -n '1,240p' src/renderer/src/i18n/plugin-pack-plurals.test.ts
printf '%s\n' '--- plugin pack loading/registration references ---'
rg -n -F -e 'loadLocaleCatalog' -e 'resourceLanguage' -e 'pack.locale' -e 'locale:' src/renderer/src/i18n src/renderer/src/store src/shared/plugins | head -200
printf '%s\n' '--- changed diff ---'
git diff 4cd62c4946bfe155c3de5bfcb42463340c32c07c b6ca0cde7406171312d67166a6cc7ae636a664d3 -- src/renderer/src/i18n/i18n.ts src/renderer/src/components/sidebar/workspace-batch-action-labels.ts src/renderer/src/i18n/plugin-pack-plurals.test.ts src/shared/plugins/plugin-language-pack-artifact.ts

Repository: stablyai/orca

Length of output: 29071


Script executed:

set -o pipefail
printf '%s\n' '--- i18n relevant blocks ---'
rg -n -F -e 'export function translate' -e 'function loadLocaleCatalog' -e 'loadLocaleCatalog(' -e 'pluralLocaleByResourceLanguage' -e 'loadRendererUiLanguage' -e 'resolveRendererResourceLanguage' src/renderer/src/i18n/i18n.ts
sed -n '1,300p' src/renderer/src/i18n/i18n.ts
printf '%s\n' '--- delete label ---'
sed -n '1,110p' src/renderer/src/components/sidebar/workspace-batch-action-labels.ts
sed -n '1,80p' src/renderer/src/components/sidebar/DeleteWorktreeDialogFooter.tsx
printf '%s\n' '--- plural tests ---'
sed -n '1,240p' src/renderer/src/i18n/plugin-pack-plurals.test.ts
printf '%s\n' '--- plugin loading ---'
rg -n -F -e 'loadLocaleCatalog' -e 'resourceLanguage' -e 'pack.locale' -e 'locale:' src/renderer/src/i18n src/renderer/src/store src/shared/plugins | head -240
printf '%s\n' '--- diff ---'
git diff 4cd62c4946bfe155c3de5bfcb42463340c32c07c b6ca0cde7406171312d67166a6cc7ae636a664d3 -- src/renderer/src/i18n/i18n.ts src/renderer/src/components/sidebar/workspace-batch-action-labels.ts src/renderer/src/i18n/plugin-pack-plurals.test.ts src/shared/plugins/plugin-language-pack-artifact.ts

Repository: stablyai/orca

Length of output: 28681


Preserve counts in legacy plugin packs.

A legacy plugin catalog can contain a hardcoded 1 in _one. For a count of 21, deleteWorkspacesCountLabel calls translate with _other, translate strips the suffix, and the Russian plural rule selects that catalog’s _one entry. The result can display 1 instead of 21.

Built-in catalog changes do not update installed plugin catalogs. Do not unconditionally fall back to _other: for Russian, 21 correctly selects _one, and replacing it with _other can violate the pack’s plural contract. Add compatibility handling for legacy entries that do not interpolate the supplied count while preserving the locale’s selected plural category.

…rals

# Conflicts:
#	src/renderer/src/i18n/en-runtime-required.json
@OrcaWin
OrcaWin merged commit 2db73d5 into main Oct 28, 2026
43 checks passed
OrcaWin added a commit that referenced this pull request Oct 28, 2026
Main now interpolates the count in English _one strings (#34693), so the
literal-1 Russian forms no longer match their source.
OrcaWin added a commit that referenced this pull request Oct 28, 2026
* feat(i18n): add Russian UI language

Register `ru` as a built-in UI language using the catalog from #33370,
reconciled against current en.json: keys pruned from English were dropped,
stale translations whose English source changed were removed, and the
catalog verifier now accepts CLDR few/many forms for an existing `_other`
family.

Co-authored-by: Vyacheslav Scherbinin <[email protected]>

* fix(i18n): drop Russian _one entries superseded by count placeholders

Main now interpolates the count in English _one strings (#34693), so the
literal-1 Russian forms no longer match their source.

* feat(i18n): complete Russian catalog and add terminology glossary

Translate the 650 remaining English keys and the few/many plural forms for
every count family, and document the Russian glossary and style conventions.

* fix(i18n): apply reviewed Russian translation corrections

Fix mistranslations and grammar flagged in a full-catalog review, and align
terminology with the glossary: рабочее дерево for worktree, рабочее
пространство for workspace, пул-реквест and файлы cookie.

* fix(i18n): resolve Russian plural forms in main-process strings and align ru terminology

translateMain now resolves literal _one/_other keys through the CLDR plural
family like translate(), so native dialogs pick Russian few/many forms. The
plural helpers move to src/shared for reuse. apply-translation-delta accepts
locale-only plural categories sourced from English _other. ru.json follows the
glossary for account/session/prompt and uses a single ellipsis character.

---------

Co-authored-by: OrcaWin <[email protected]>
Co-authored-by: Vyacheslav Scherbinin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

i18n: languages with more than two plural forms cannot be translated

1 participant