docs(i18n): qualify European integer counts against live UI callers

This commit is contained in:
cesnimda
2026-11-20 14:01:08 +01:00
parent aaf66ca24a
commit e7bd7ff3c0
5 changed files with 5575 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
# Integer count messages across the proposed European locales
I18N-00 research, 20 November 2026. A type-aware message contract must preserve both the integer and the complete translator-owned sentence. Under the tested runtimes, **33 of the 59 candidate tags with available cardinal-rule data** return a category other than the result of `n === 1 ? "one" : "other"` for at least one sampled integer. This includes **14 of the 24 EU official language groups**. Every EU group was sampled. The 60th candidate, Kven, fell back to the host language. All 60 catalogue entries retain their planned status.
## Application inventory
The probe parsed 139 production TypeScript/TSX files under `job-tracker-ui/src` from application commit `7a2b8a95c146d67bc4584740e4a72740cfc25cbf`. The EN/NB catalogue contains 111 keys using the exact `{count}` placeholder. One hundred have literal key references at this revision, covering 120 occurrences across 96 source lines in 25 files. The records bind each message to its English and Bokmål source text and lines, and each occurrence to its Git blob, line, translator or deferred descriptor, and count expression. Eleven keys have no literal reference in these files. Their dynamic and downstream uses require independent review before any removal. [Caller inventory](integer-counts/count-callers.json)
| Surface and source location within the UI | Observed contract | Required translation and verification |
| --- | --- | --- |
| Discovery status, `JobDiscoveryPage.tsx:290` | Array length selects `jobDiscoveryResultOne/Many`. The result is announced as a status. | Supply the raw visible-result count and translate the whole announcement. Test Polish 2 and 5, Ukrainian 21, and Welsh 0, 1, 2, 3, 4 and 6. Assert which complete message is announced. |
| Calendar, `CalendarAgenda.tsx:74` | Every date button uses the fixed `calendarDayEvents` text with its formatted date and a count, including zero. | Cover 0, 1 and multiple events with day and count together in the accessible name. At count 1 the current English template yields “1 recorded dates” and Bokmål yields “1 registrerte datoer”. |
| Command search, `QuickCommandDialog.tsx:171` | The ready-state announcement uses one `searchResultsCount` template. Its English singular produces “1 results available.” | Test the live-region message at zero, one and several results in each qualified locale. Preserve separate loading and idle states. |
| Career Profile import review, `CareerWorkspaceOverview.tsx:111–113` | The three singular messages embed the quantity directly. Their paired plural messages accept `{count}`. Selection occurs only for non-empty groups. | A grammatical “one” can also apply to 21 or 101. Always retain and format the real count. Keep the review/processing/failed state and its action unchanged. |
| Dashboard, `DashboardView.tsx:154,219,272,287,311` | Four count-message calls use `Intl.NumberFormat(...).format(...)` before passing `count`. The time-in-stage row also formats median days. | Carry the raw count separately from its rendered digits. Use the integer count to choose the whole message and preserve the independently rounded duration, currency, period or shown subtotal. |
| Applications bulk trash, `JobTable.tsx:406–412` | Zero returns without confirmation. A single selected application uses its title/company in the confirmation. Multiple selections pass `jobsToDelete.length` in a deferred key descriptor. `confirm.tsx:77` resolves the message when displayed. | Preserve exactly-one versus multiple as an **action** decision. Within the multiple-selection confirmation, use the locale’s grammatical category for the actual count. Polish two items must continue to use bulk confirmation. Keep user titles and employer names private runtime values. |
| Mail import, `Correspondence.tsx:537` | A conditional translated “skipped duplicates” fragment is interpolated into an outer import result. | Allow imported and skipped counts and any zero case to govern the whole sentence. Exercise both counts independently and preserve confirmed server outcomes. |
| Pagination and processing, `JobTable.tsx:931`, `AdminProcessingPage.tsx:210` | `tableDisplayedRows` uses `from`, `to` and `count`; `processingAttempts` uses the current attempt and `max`. | Preserve each numeric role and let translators order the whole phrase. These keys demonstrate why the name `count` alone cannot identify an inflected noun. |
The scope is the named placeholder in the EN/NB TypeScript catalogue. Other placeholders such as `days`, implicit quantities, numeric literals, dynamic key construction, backend messages and document-language output remain separate inventory work. The source records describe existing paths. Runtime screen-reader, application journey and native-language checks did not run for this audit.
## Integer classes and fallback
Each of the 60 planned tags was queried for 2,007 unformatted, nonnegative integers: 0 through 2,001 inclusive, 999,999, one million, one million plus one, two million and one billion. Node 24.19.0 (ICU 78.3, CLDR 48.0) and Chromium 151.0.7922.34 in two isolated default-language contexts returned identical category sequences for the 59 tags with lookup data. Each row records the literal tag, lookup result, resolved rules locale, category witnesses and a digest of the selected categories. Requested tags can legitimately resolve to parent rules. [Runtime results](integer-counts/cardinals.json)
| Requested tag | Actual integer witnesses and implications |
| --- | --- |
| `pl-PL` | 1 → one, 2 → few, 5 → many, 22 → few. A two-branch key pair loses a distinction even for small ordinary counts. |
| `sl-SI`, `is-IS` | Slovenian 2 → two, 3 → few, 101 → one. Icelandic 21 → one despite exposing only one/other. Never embed a literal 1 solely because the grammatical class is one. |
| `fr-FR`, `pt-PT` | French 0 → one and Portuguese (Portugal) 0 → other. Both return many at one million. Validate each actual locale and preserve the caller’s possible numeric domain. |
| `lv-LV`, `cy-GB` | Latvian 11 → zero, 21 → one. Welsh returns six different classes for 0, 1, 2, 3, 4 and 6. A locale’s zero class and an application’s exact-empty-state test are distinct. |
| `smj-NO`, `sma-NO` | Both supply cardinal two at 2. The R01 number-format lookup gap still applies. Selecting grammatical class and rendering digits have distinct data prerequisites. |
| `cnr-ME` | Both engines canonicalised this requested tag to `sr-ME` and resolved the rules to `sr`. Keep the requested product identity and the unresolved native/market decision visible. |
| `fkv-NO` | Lookup returned empty in all three runs. At 2, the English-host browser selected other; the Polish-host browser selected few. Neither result establishes Kven grammar. Keep unsupported products hidden and apply any approved fallback consistently to both the message and its rules. |
The 14 EU groups with observed binary counterexamples were Czech, Spanish, French, Irish, Croatian, Italian, Lithuanian, Latvian, Maltese, Polish, Portuguese, Romanian, Slovak and Slovenian. Categories advertised by the API can lack a witness in the integer sample. Examples include Czech `many` and Polish `other`. Preserve the translator’s fallback branch and qualify decimal measures separately. This dataset establishes finite integer witnesses, rather than general rules for decimals, negatives, ordinals or open-ended numeric ranges.
## Reproduction and remaining gates
From this audit checkout run `node docs/i18n/00/integer-counts/probe.mjs <installed-job-tracker-ui-directory> --check`. It uses the checkout’s installed TypeScript 5.9.3 and Playwright Chromium, immutable Git blobs and two blank browser contexts. It requests no application routes or external services. The second execution reproduced both committed JSON outputs, including all supported candidate sequences and the differing host-dependent fallback. The source draft catalogue blob was `0a59672c90694ed23438cb6e16992aa1eb366ef9`; the application translation blob was `c2713f2ccec7bdf092ea1cefacf5a563d663f487`. [Executable probe](integer-counts/probe.mjs)
The next localisation increment can use these bindings to classify additional placeholder names and supply translator context for messages with multiple quantities, units or asynchronously resolved parameters. Phase 10, product review, I18N-00 acceptance and explicit I18N-01 entry remain the gates for a new runtime message engine. Translation, native review, locale publication and release approval remain open.
+2
View File
@@ -1,5 +1,7 @@
# Surface inventory and message accounting
20 November 2026. The [integer-count inventory](INTEGER_COUNT_MESSAGES.md) traces 111 catalogue keys at application `7a2b8a95`, including 120 bound literal references and explicit gaps. The paired Node/browser probe covers all 60 planned tags, with counterexamples across 14 EU language groups and a host-dependent Kven fallback.
17 November R01: [European runtime observations](RUNTIME_CAPABILITIES_R01.md) add framework data/canonicalisation evidence for all60 planned candidates and24 EU language groups. This is separate from the every-string/context census below. No message is translated or surface accepted by a framework supporting a locale; native, critical-flow, browser/PDF and legal coverage remain required.
17 November 2026: [B02 upstream producer census](BACKEND_MESSAGE_CENSUS_B02.md) adds 23 source loci across actual rules/usage/notification producers and DTO forwarding boundaries, with ten caller traces. Its [records](BACKEND_MESSAGE_CENSUS_B02.json) bind 15 immutable source files, source lines/hashes, contexts, parameters/sensitivity and raw/candidate/invariant/unresolved partitions. This narrows B01's upstream gaps for controlled rules reasons, allowance messages and terminal/interrupted-send/saved-search notification prose. It does not complete upstream domains, frontend consumers or any surface/native/locale acceptance.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+150
View File
@@ -0,0 +1,150 @@
// Research probe. Run from the audit checkout with frontend development dependencies available locally.
import assert from 'node:assert/strict';
import { execFileSync } from 'node:child_process';
import { createHash } from 'node:crypto';
import { readFileSync, writeFileSync } from 'node:fs';
import { createRequire } from 'node:module';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const here = path.dirname(fileURLToPath(import.meta.url));
const require = createRequire(path.resolve(process.argv[2] || 'job-tracker-ui', 'package.json'));
const ts = require('typescript');
const { chromium } = require('playwright');
const revision = '7a2b8a95c146d67bc4584740e4a72740cfc25cbf';
const auditSource = 'aaf66ca2';
const git = (...args) => execFileSync('git', args, { encoding: 'utf8', maxBuffer: 32 * 1024 * 1024 });
const eu = new Set('bg hr cs da nl en et fi fr de el hu ga it lv lt mt pl pt ro sk sl es sv'.split(' '));
const catalogPath = 'docs/i18n/00/LOCALE_CATALOG.json';
const catalogBlob = git('rev-parse', auditSource + ':' + catalogPath).trim();
const locales = JSON.parse(git('cat-file', 'blob', catalogBlob)).locales;
const tags = locales.map(entry => entry.tag);
assert.equal(new Set(tags).size, 60);
assert.ok(locales.every(entry => entry.status === 'planned' && Object.values(entry.surfaces).every(status => status === 'planned')));
assert.deepEqual(new Set(tags.map(tag => tag.split('-')[0]).filter(language => eu.has(language))), eu);
// The function is also evaluated verbatim inside isolated Chromium language contexts.
function cardinalSamples(tags) {
const values = [...Array(2002).keys(), 999999, 1000000, 1000001, 2000000, 1000000000];
return tags.map(tag => {
const accepted = Intl.PluralRules.supportedLocalesOf([tag], { localeMatcher: 'lookup' });
const rules = new Intl.PluralRules(tag, { localeMatcher: 'lookup', type: 'cardinal' });
const options = rules.resolvedOptions();
const witnesses = {};
const sequence = [];
let binaryCounterexample = null;
for (const value of values) {
const category = rules.select(value);
sequence.push(category);
witnesses[category] ??= value;
if (binaryCounterexample === null && category !== (value === 1 ? 'one' : 'other')) binaryCounterexample = { value, category };
}
const examples = Object.fromEntries([0, 1, 2, 3, 5, 6, 11, 21, 22, 101, 1000000].map(n => [n, rules.select(n)]));
return { tag, lookup: accepted, canonical: Intl.getCanonicalLocales(tag)[0], resolved: options.locale, reported: options.pluralCategories, witnesses, binaryCounterexample, examples, sequence: sequence.join(',') };
});
}
const host = cardinalSamples(tags);
const browser = await chromium.launch({ channel: 'chromium' });
const browserVersion = browser.version();
const browsers = {};
try {
for (const locale of ['en-GB', 'pl-PL']) {
const context = await browser.newContext({ locale });
const page = await context.newPage();
browsers[locale] = await page.evaluate(cardinalSamples, tags);
await context.close();
}
} finally {
await browser.close();
}
for (const [index, node] of host.entries()) {
for (const results of Object.values(browsers)) {
const browserRow = results[index];
assert.equal(browserRow.tag, node.tag);
assert.deepEqual(browserRow.lookup, node.lookup);
if (node.lookup.length) assert.equal(browserRow.sequence, node.sequence, node.tag);
}
}
const kvenEnglishHost = browsers['en-GB'].find(row => row.tag === 'fkv-NO');
const kvenPolishHost = browsers['pl-PL'].find(row => row.tag === 'fkv-NO');
assert.deepEqual(kvenEnglishHost.lookup, []);
assert.deepEqual(kvenPolishHost.lookup, []);
assert.notEqual(kvenEnglishHost.sequence, kvenPolishHost.sequence);
for (const row of [...host, ...Object.values(browsers).flat()]) {
row.sampleSha256 = createHash('sha256').update(row.sequence).digest('hex');
delete row.sequence;
}
const listing = git('ls-tree', '-r', revision, '--', 'job-tracker-ui/src').trimEnd().split('\n');
const files = listing.map(line => {
const [modeAndObject, filename] = line.split('\t');
return { filename, blob: modeAndObject.split(' ')[2] };
}).filter(file => /\.tsx?$/.test(file.filename) && !/(?:\.(?:test|spec)\.tsx?$|\/__tests__\/|\/setupTests\.ts$)/.test(file.filename));
const blobs = execFileSync('git', ['cat-file', '--batch'], { input: files.map(file => file.blob).join('\n') + '\n', maxBuffer: 32 * 1024 * 1024 });
let offset = 0;
for (const file of files) {
const end = blobs.indexOf(10, offset);
const [hash, type, length] = blobs.subarray(offset, end).toString('ascii').split(' ');
assert.equal(hash, file.blob);
assert.equal(type, 'blob');
file.source = ts.createSourceFile(file.filename, blobs.subarray(end + 1, end + 1 + Number(length)).toString('utf8'), ts.ScriptTarget.Latest, true);
assert.equal(file.source.parseDiagnostics.length, 0, file.filename);
offset = end + 2 + Number(length);
}
const catalogFile = files.find(file => file.filename.endsWith('/i18n/translations.ts'));
const variable = catalogFile.source.statements.filter(ts.isVariableStatement).flatMap(statement => statement.declarationList.declarations).find(decl => decl.name.getText() === 'translations');
const tuples = {};
const line = (file, node) => file.source.getLineAndCharacterOfPosition(node.getStart(file.source)).line + 1;
for (const language of variable.initializer.expression.properties) {
const labels = {};
for (const property of language.initializer.properties) {
assert.ok(ts.isPropertyAssignment(property) && ts.isStringLiteralLike(property.initializer));
labels[property.name.text] = { text: property.initializer.text, line: line(catalogFile, property) };
}
tuples[language.name.text] = labels;
}
const isCount = message => /\{count\}/.test(message);
const keys = Object.keys(tuples.en).filter(key => isCount(tuples.en[key].text) || isCount(tuples.nb[key].text));
const messages = Object.fromEntries(keys.map(key => [key, { en: tuples.en[key], nb: tuples.nb[key], references: [] }]));
for (const file of files) {
if (file === catalogFile) continue;
function visit(node) {
if (ts.isStringLiteralLike(node) && Object.hasOwn(messages, node.text)) {
let cursor = node;
while (cursor.parent && ts.isConditionalExpression(cursor.parent) && (cursor === cursor.parent.whenTrue || cursor === cursor.parent.whenFalse)) cursor = cursor.parent;
const parent = cursor.parent;
const call = ts.isCallExpression(parent) && parent.arguments[0] === cursor ? parent : null;
const descriptor = ts.isPropertyAssignment(parent) && parent.name.getText() === 'key' && ts.isObjectLiteralExpression(parent.parent) ? parent.parent : null;
const descriptorParams = descriptor?.properties.find(prop => prop.name?.getText() === 'params');
const params = call?.arguments[1] ?? descriptorParams?.initializer;
const count = params && ts.isObjectLiteralExpression(params) && params.properties.find(item => item.name?.getText() === 'count');
const conditional = ts.isConditionalExpression(cursor) ? cursor : call && ts.isConditionalExpression(call.parent) ? call.parent : null;
messages[node.text].references.push({
file: file.filename, blob: file.blob, line: line(file, node),
call: call?.expression.getText() ?? (descriptor ? 'deferred key descriptor' : null), count: count?.getText() ?? null,
selection: conditional?.condition.getText() ?? null,
});
}
ts.forEachChild(node, visit);
}
visit(file.source);
}
const write = (name, data) => {
const target = path.join(here, name);
if (process.argv.includes('--check')) assert.deepEqual(data, JSON.parse(readFileSync(target, 'utf8')), name);
else writeFileSync(target, JSON.stringify(data, null, 2) + '\n');
};
// Supported browser records matched the complete Node sequence above. Retain each
// binding, and retain the full observation wherever host fallback supplies the rules.
for (const results of Object.values(browsers)) {
for (const [index, row] of results.entries()) {
if (row.lookup.length) {
const { tag, lookup, resolved, sampleSha256 } = row;
results[index] = { tag, lookup, resolved, sampleSha256 };
}
}
}
write('count-callers.json', { revision, catalogBlob: catalogFile.blob, typescript: ts.version, sourceFiles: files.length, messages });
write('cardinals.json', { catalogBlob, euLanguages: [...eu], node: process.version, hostDefault: new Intl.PluralRules().resolvedOptions().locale, icu: process.versions.icu, cldr: process.versions.cldr, browser: browserVersion, host, browsers });
console.log('Candidate tags', tags.length, 'EU languages', eu.size, 'source files', files.length, 'count keys', keys.length);