Repository navigation
M12: Excel-style languages (12 languages, local formulas, regional formats) - #191
quantmind-br wants to merge 1 commit into
Conversation
- Web/desktop fonts: font bytes are validated with skrifa (the parser epaint uses) before egui sees them; an HTML page served for a missing fonts/cjk-*.ttf made epaint panic. Repeated deliveries are ignored. - FontNeeds borrows instead of cloning every frame; FontKey drops the redundant bool; the CJK scan reads at most 200k cells per workbook. - The View tab's language list loads the CJK fonts when it opens, like Options; other regional CJK craft faces are a last-resort fallback. - ui.json migration: a saved language equal to what old builds detected from the system (e.g. "en" on a German system) keeps following the system; a real choice migrates and both files are rewritten at once. The web build never saved UI state, so it has nothing to migrate. - Restores upstream behaviour lost in a merge resolution: imported ODS/XLSB files are titled "<name> (imported).xlsx" and the import message shows 5 warnings plus a count. - table.resize never repeats a column name; from_csv reports errors under the command that ran; the lexer cannot advance by zero characters. - UI commands keep typed EngineErrors (localized via error codes); number boxes read plain numbers only and round to the widget's decimals; engine.commands labels stay English; the command search tooltip no longer advertises a shortcut that does not exist.
|
@h-a-n-a-s-h-i this is ready for review. It merges current Two things need a maintainer:
Open PRs touching the same files: #163 (German interface, a different i18n design; this PR already covers de-DE), #208 (calc) and #206 (cell references). I'll merge |
2e5bca0 to
12ce98c
Compare
…rmats) Interface, formula language and regional format work as in Excel: function names, booleans, errors and format-code letters follow the formula language (the interface language by default, or en-US); separators, dates, months and currency follow the regional format. Workbooks, XLSX, the journal and programmatic params stay canonical (English names, `,` arguments, `.` decimal), so a file opens the same in every language. Local text only crosses the engine boundary as `*Local` fields. Languages: en-US, pt-BR, pt-PT, es-ES, fr-FR, de-DE, it-IT, ru-RU, ja-JP, ko-KR, zh-CN, zh-TW (Japanese, Korean and Chinese keep English function names, as Excel does). - locale (new, L0): language and region data in TOML, validated by build.rs (missing keys, duplicate local names, colliding separators, canonical en-US), CLDR-style negotiation of OS and browser tags. Only en-US must list every function: one another language doesn't list yet keeps its English spelling there, so adding a worksheet function needs English data only. - formula: tokenize/parse/print per dialect; one function catalog with file prefixes replaces the four hand-kept lists (_xlfn., _xludf. for canonical names typed in a localized dialect, _xlpm. for LET/LAMBDA parameters). In ru-RU `:` separates array-constant rows: inside braces a number followed by `:` is a number, since array constants hold no references. - core, numfmt, functions, calc: regional input parsing and text-to-number coercion, localized number-format codes and display, TEXT/FIXED/DOLLAR, VALUE/DATEVALUE/NUMBERVALUE, criteria, CELL/INFO keywords, DBCS *B functions. - l10n (new, L4): Fluent messages for all 12 languages, same keys and arguments as en-US (function descriptions may fall back to en-US); `cargo xtask locales` reports coverage, lists untranslated function names and descriptions as warnings, and runs in ci. - engine: locale prefs, app.setLocale / app.getInternational / app.languages, file.options (catalog: 259 / 290), inputLocal / formulaLocal / valueLocal / numberFormatLocal / refersToLocal, stable EngineError codes, regional CSV, app-created content in the interface language. - ui-egui and apps: translated UI and native menus, local formula editing with autocomplete and argument hints, Options > Language (live switch), localized shortcuts where Excel localizes them, IME, CJK font fallback (font bytes validated before egui sees them), system locale detection, localStorage prefs on the web, CLI --locale, MCP local params. Built on upstream work: - Interface languages (storytold#31, storytold#82, storytold#104): the hand-written table in crates/ui-egui/src/i18n.rs is folded into the Fluent catalog; every upstream language stays, Russian is the 12th (function names voted from Microsoft's ru-RU pages, checked against independent tables, with aliases such as УСЛОВИЯ and ЕСЛИНД). The View-tab picker runs app.language.set and shares the preference with Options > Language; ui.json language codes migrate once to prefs.json unless they are what old builds detected from the system. Text box editing (storytold#84) and key tips (storytold#43) keep working, with translated captions; key tip letters stay English in every language. - Spanish formulas (storytold#98) are folded into this design: names follow the interface language and separators the region, so FormulaLocale, UiState.language and docs/formula-input.md are superseded. Its name-precedence rule is kept and generalized: defined names, table names and LET/LAMBDA bindings win over localized function names and booleans (parse_local_with/print_local_with, Workbook::knows_name) in cell input, *Local params, display, find/replace, CF, validation, names, FORMULATEXT and INDIRECT. A built-in whose local spelling a name took is written with its file prefix (_xlfn.SUM, _xlfn.FALSE()). The journal re-reads *Local params against the workbook as the command found it. storytold#98's UI tests are ported. - Progress docs (storytold#189): localization re-measured (~10% -> ~50% ready). - storytold#57/storytold#159: compare_numbers and MIN() with no arguments use the regional coercion. storytold#148: precedents of ranges ending in a function. storytold#127: the every-line delimiter rule applies to the regional CSV sniffer, whose fallback is the region's list separator. storytold#156: legacy array braces around the localized formula. storytold#149: table.resize writes the names it chooses into the header cells and numbers repeated headers like insert.table. storytold#105: cell-picture strings in all 12 languages. - Restored upstream behaviour: imported ODS/XLSB files are titled "<name> (imported).xlsx"; the import message shows 5 warnings plus a count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
12ce98c to
b8695c3
Compare
|
@h-a-n-a-s-h-i @echelon an update for review (it replaces the status in my comment above): State. The branch is one commit on top of current Needs a maintainer: the Packaging lint run is waiting for approval because this is the first PR from this fork. It only runs because Overlap with open PRs. I test-merged every open PR against this branch. 60 of the ones that merge cleanly into
Merge them in whatever order you prefer. I'll keep this branch rebased on Function PRs (#276, #280, #290, #292, #297, #317, #325) won't need eleven translations after this PR. A new function needs English data only:
Other languages spell the function like English and show the English description until it's translated. Function code needs one change: the coercion helpers take the context ( |
|
@echelon @h-a-n-a-s-h-i following your note on #163: main now has German, Spanish and Czech on
I'm turning this PR into a draft. It stays as the reference for the Fluent catalog approach; close it whenever you like if you don't want that direction. |
|
@echelon @h-a-n-a-s-h-i the first two focused PRs are open, both on top of current
The code in the two PRs merges cleanly; only
This draft stays only as the reference for the Fluent catalog approach. |
|
Thanks for the great work on this PR! This is exactly the kind of internationalization support I was hoping to see in GridCraft. I'd especially like to help validate the French (fr-FR) localization, including: Function names such as SOMME, MOYENNE, and SI. I noticed the PR already includes extensive test coverage. Would additional French-specific manual testing or localization review be helpful before merging? I'd be happy to contribute where needed. Thank you for your work! |
|
@RedDevilMan thanks, French review would help. This PR is now a draft kept as a reference; the work continues in #443 (formula languages) and #447 (regional formats). Where French stands:
|
|
Thanks for the detailed explanation and for pointing me in the right direction! Just to clarify, I'm not a developer or a French language specialist. I learned to use Excel in French during my school years and in my work, so French Excel terminology and formulas are what I'm familiar with as a user. I'd be happy to help with manual testing by comparing GridCraft's behavior with French Excel, especially formula names, regional formats, and switching between French and English. I'll take a look at the relevant PRs and see what I can test. If there are any specific areas where user testing would be particularly helpful, please let me know. Thanks again! |
|
@RedDevilMan that helps: a regular French Excel user is exactly what's missing, because none of the tables have been checked against a real localized Excel. There's no ready-made GridCraft build with these changes yet (v0.5.0 predates the French interface), so the most useful thing right now is what your French Excel does. Any subset of these is welcome; post what you see here or on #447:
Once a French function table exists (after #443 is reviewed), I'll post its list of names so you can check them against your Excel. That's where a user's eye matters most. |
|
Since this PR is reworking
Each should probably come back as |
|
@webdevtodayjason thanks for holding back to avoid the collision, but there isn't one. #191 stays a draft for reference only and won't be merged. The PRs that replace it, #443 and #447, leave The code matches what you describe:
Checking each coordinate against |
|
I tested the French Excel behavior using Excel 2013 (French version). Test 1 — Number separators
Test 2 — Date parsing
Test 3 — Long date format
Test 4 — Formula and array separators
Note: The second formula was entered with decimal commas, as shown above. Test 5 — French date-format tokens
Test 6 — Structured table references
These observations are from Excel 2013 with the French interface |
|
@RedDevilMan thank you, this is exactly what was missing. I ran the same six checks in GridCraft with the French interface and the Français (France) regional format (the fork's
So the regional format (1–3) matches French Excel. 4–6 are what a French formula table needs: function names, One more check would settle array constants. |
Français selects French formula syntax: 398 local function names from Microsoft's fr-fr function pages (two agreeing signals per entry, 35 reviewed by hand), VRAI/FAUX, French errors and table specifiers, ';' between arguments and array rows, ',' decimals and '.' between array columns. Separators, SOMME, TEXTE, AUJOURDHUI, LIGNES, #VALEUR! and four specifiers were observed in French Excel 2013 (storytold#191).
|
@RedDevilMan here is the French function-name list I promised. #443 now has a French formula table, so with the French interface GridCraft takes and shows French formulas. Your test 4 is now a test in the PR: The table has 398 names, The names come from Microsoft's French help pages, which are machine-translated. The 35 marked If a name differs from your Excel, just tell me which one and what Excel shows. All 398 names (English → French) |
|
I tested the marked French function names in Microsoft Excel 2024 Pro Plus with the French interface. Successful tests
Names returning
Formulas rejected before entry
For these, Excel displayed a formula syntax error; after dismissing the dialog, the formula remained in the cell as plain text. Array separator test
These results reflect my local Excel 2024 Pro Plus installation. The rejected formulas may need to be retested with the correct array-constant syntax and argument separators before drawing conclusions about the French function names. |
French Excel 2024 gives #NOM? for NBCARB, CHERCHEB and TROUVEB, the names that were inferred from the base name + B pattern (storytold#191). The French names are LENB (unchanged), CHERCHERB and TROUVERB, as in Microsoft's French text-function reference, perfectxl and auditexcel. Adds the functions added after the table was collected: the four ODD* bond functions (PRIX/REND.PCOUPON/DCOUPON.IRREG) and the four PREVISION.ETS* functions, each from the Microsoft fr-fr page and ledojo. PERCENTOF and TRIMRANGE keep English: the two sources disagree.
|
@RedDevilMan thank you, this is very useful. The three The rejected formulas probably come from the separators, not the names. An unknown name gives
About One question about the 2024 machine: is its Windows region, or Excel's "Utiliser les séparateurs système" option, set to something other than French? If Excel's separators follow the region rather than the display language, GridCraft should do the same. |
|
Closing this draft. It has been split into smaller PRs on current
The @RedDevilMan thank you for all the testing in this thread; it already fixed three wrong names. When you have results for the retest table in my last comment (or your Windows region and separator settings), please post them on #443, which is where the French table lives now. Comments here still reach me, so nothing gets lost if you already started writing. |
French Excel 2024 with an English regional format takes dd/mm/yyyy and refuses jj/mm/aaaa, which French Excel 2013 with a French region needed (storytold#191, storytold#443). Note it next to the separators; GridCraft's codes stay English in every region.
Français enters and shows French formulas: 405 local function names (SOMME, SI, RECHERCHEV), VRAI/FAUX, French errors and table specifiers, ';' between arguments and array rows, ',' decimals and '.' between array columns. Separators, TEXTE date codes and 38 names were checked in French Excel 2013 and 2024 (storytold#191); FINDB and SEARCHB are TROUVERB and CHERCHERB, and LENB keeps its English name.
Summary
GridCraft in 12 languages, working the way Excel does:
Planilha1,Total Geral, PivotTable captions).=SE(A1>1,5;SOMA(B1:B3);0),aaaa,JJJJ).{1\2;3\4}in pt-BR,{1.2;3.4}in de-DE,{1;2:3;4}in ru-RU).Storage stays canonical:
Formula.text, XLSX, the journal and programmatic params keep English names,,arguments and.decimals, so a workbook opens identically in every language. Local text only crosses the engine boundary through*Localfields (inputLocal,formulaLocal,valueLocal,numberFormatLocal,refersToLocal).Languages: en-US, pt-BR, pt-PT, es-ES, fr-FR, de-DE, it-IT, ru-RU, ja-JP, ko-KR, zh-CN, zh-TW. Japanese, Korean and Chinese keep English function names, as Excel does.
What changed
crates/locale(new, L0)build.rs(missing keys, duplicate local names, colliding separators, canonical en-US). CLDR-style negotiation of OS/browser tags (pt_BR.UTF-8,pt-AO→ pt-PT,zh-HK→ zh-TW,C/POSIX→ en-US).crates/formulatokenize_local/parse_local/print_localper dialect.catalog.rsis the single function list with file prefixes and replaces the four hand-kept lists._xludf.marks a canonical name typed in a localized dialect (=SUM(1;2)in pt-BR is#NAME?, as in Excel).core,numfmt,functions,calc[$-LCID]honoured), TEXT/FIXED/DOLLAR, VALUE/DATEVALUE/NUMBERVALUE,*IF(S)and database criteria, CELL/INFO keywords, DBCS*Bfunctions.Ctx::locale()defaults to the invariant locale, so en-US behaviour is unchanged.crates/l10n(new, L4)locales/<tag>/*.ftl), same keys and arguments as en-US in every language (enforced by tests andcargo xtask locales, now a ci step). Function descriptions (fn-*) are the exception: a language without one shows the en-US text.crates/engineapp.setLocale(live switch, full recalc),app.getInternational,app.languages,file.options(the catalog's File › Options, now implemented: 259 / 290);*Localparams and fields; stableEngineError::code()so the UI translates errors instead of string-matching; regional CSV (list-separator delimiter, local decimals).ui-egui, apps, MCPCRAFT_FONTS_DIR, no fonts in the repo; font files are validated before egui sees them, so an HTML page served for a missing web font logs a warning instead of panicking); system locale detection; localStorage prefs on the web; CLI--locale; MCP local params.xtasklocale(L0) andl10n(L4);cargo xtask localescoverage report (function names and descriptions a language hasn't translated yet are warnings, not failures).Diff size: +31.5k lines of
.ftl/keymap, +6.4k of locale TOML, +3.2k in test files, +12.7k/−6.2k of code, plus docs (README, ROADMAP, AGENTS.md/CLAUDE.md, control protocol, decisions).Data provenance
=NAME(examples, and needs two agreeing signals. Weak entries were decided by hand and are markedreviewed. For ru-RU, conflicts were also checked against independent function-translation tables; spellings Excel users meet that lost the vote are kept as accepted aliases (УСЛОВИЯ→ IFS,ЕСЛИНД→ IFNA,ПРОСМОТРХwith a Cyrillic Х → XLOOKUP). Every language file has a[provenance]table, and any token without a reliable source is listed underunsourcedand kept in English rather than guessed.Function-name coverage from
cargo xtask locales:Adding a worksheet function after this PR
Only English data is needed: the registry entry,
BUILTINSincrates/formula/src/catalog.rs(with the_xlfn.prefix when there is one),crates/locale/data/languages/en-US.tomlandfn-<NAME>inlocales/en-US/functions.ftl. Other languages spell the function like English and show the en-US description until someone translates it.cargo xtask localeslists those as warnings and doesn't fail on them; the failing tests name the files to edit.One API change reaches function code: the coercion helpers take the context, because text-to-number parsing follows the region (
num(ctx, args, i)instead ofnum(args, i)). Tried on #292 (BAHTTEXT) merged on top of this branch: after that one-line change and the four English entries, every test passes and=BAHTTEXT(SOMA(21;0,25))works in pt-BR.Integration with recent
mainThis branch is one commit on top of current
main(9f896c1, the 0.5.0 release), so every merge method works, including rebase. Changes to recent upstream work that need a reviewer's attention:FormulaLocale,UiState.language). Here that is already the general rule, as in Excel: names follow the interface language and separators follow the regional format. So Support common Spanish formula names and semicolon arguments #98'sFormulaLocale, its language-tied separators anddocs/formula-input.mdare replaced, anddocs/decisions.mdrecords why.parse_local_with/print_local_withwithWorkbook::knows_name). This applies to cell entry,*Localparams,cell.get, Show Formulas and the formula bar, find/replace, conditional formatting and validation, Name Manager,FORMULATEXT,INDIRECT, and an edit in progress when the language changes.FALSO,=SUM(1,FALSE)shows as=SUMA(1;_xlfn.FALSE()). Support common Spanish formula names and semicolon arguments #98 showed the English name instead, but a localized dialect rejects English names (#NAME?, as in Excel), so that text would not read back.*Localparams with the names as they were before the command. Without this, defining a nameSUMAwithrefersToLocal "=SUMA(1;2)"would record a call to itself.crates/formula/tests/spanish_input.rsis folded intolocal_tests.rs(plus a round trip in every language), and the 8 UI tests are ported to this API (ui-egui/tests/formula_locale.rs). One of them is inverted: pt-BR uses Portuguese names (=SOMA(1,5;2,25)) as Excel does, where Support common Spanish formula names and semicolon arguments #98 kept English.crates/ui-egui/src/i18n.rsare folded into the Fluent catalog and the file is removed. Every upstream language stays; Russian joins as the 12th language with full interface, function names and a CLDR region. The View-tab language picker now runsapp.language.setand lists all 12 languages; it shares the preference with File › Options › Language. A language code saved by the old picker inui.jsonis migrated once toprefs.json, unless it is what the old build detected from the system (a German system saveden, since the old builds had no German): that user keeps following the system, now in German.localization-parity.md,target-app-parity.md,gaps.mdExcel Password Protected - No Prompt #11,roadmap.md,function-parity.md,ui-parity.md,architecture.md, ROADMAP): localization ~10% → ~50% ready, 100–165 h → 45–65 h; the full number moves from 51.6 to 53.2 computed and stays ~50%.A1#spill operator: works in every dialect. A#right after a reference is the operator; any other#starts a local error literal (A1#;#N/Dlexes correctly in pt-BR)._xlpm.(XLSX writer omits_xlpm.prefix on LET/LAMBDA parameter names, so Excel refuses to open the file #63): both sides implemented it, and only one implementation is kept. It strips the marker on read and keeps the declared spelling, so a LET-bound LAMBDA call is written_xlpm.f(3)instead of_xlpm.F(3). I changed that one assertion in the XLSX writer omits_xlpm.prefix on LET/LAMBDA parameter names, so Excel refuses to open the file #63 tests. Excel's exact casing here was not observed.EngineError::Protected(codeprotected-sheet, translated) instead of anOtherstring.inputLocalis refused exactly likeinput. Hidden formulas stay hidden in every spelling:cell.get,sheet.read, Watch Window, Error Checking, Evaluate Formula and find/replace no longer return eitherformulaorformulaLocal. Before this branch,cell.getand the others still exposed the canonical text.DATE(1900,2,29) = 60also holds for regional input (29/02/1900in pt-BR).=0.1+0.2=0.3returns FALSE: comparisons, MATCH and COUNTIF don't use Excel's 15-significant-digit equality #57's 15-significant-digitcompare_numberssits next to the regional criteria parsing.MIN()with no arguments (functions: MIN() accepts zero arguments #159) uses the regional coercion. Recalc: stale spills and values after edits (fixes #133, #139) #148's precedents for ranges ending in a function sit next to the singleis_special. fix(csv): re-importing a single-column export splits semicolon and tab text #127's "a delimiter must appear on every line" rule applies to the regional CSV sniffer, where the region's list separator is the fallback (pt-BR keeps splitting on;and reading1,5as a number). The formula bar puts Legacy array formulas: fill the range they were entered in #156's legacy array braces around the localized formula.table.resizewrites the names it chooses into the header cells, and numbers a repeated header the wayinsert.tabledoes (Sales,Sales2). Otherwise the sync renamed resized columns by position (Column22instead ofColumn3).Verification
cargo xtask ci: all 8 steps pass (fmt, clippy, test, assets, layers, wasm, locales, parity).cargo test --workspace: 816 passed, 1 ignored (timing-sensitive).parse_local(print_local(e, d), d) == eon randomly generated expressions for every language × region pair, and fuzzparse_localfor panics.gridcraft-cli eval --locale pt-BR '=SOMA(1,5;2)'→3,5;--locale de-DE '=SUMME({1.2;3.4})'→10;--locale ru-RU '=СУММ({1;2:3;4})'→10,'=ТЕКСТ(46305;"ДД ММММ ГГГГ")'→10 октябрь 2026; in pt-BR,=SOMA(A1#)*1,5is stored as=SUM(A1#)*1.5.--locale es-ES, nameFALSO→ C1 = 7):=LET(SUMA;LAMBDA(x;x+1);SUMA(2))+FALSO→10, shown as typed;=FORMULATEXTO(A1)→=FALSO+1;=INDIRECTO("FALSO")→7.Known limitations
_xludf.) was inferred, not observed._xlfn.NAME(...). It is unambiguous and reads back, but it is not pretty. How Excel displays this case was not observed.CRAFT_FONTS_DIR. On the web they load from./fonts/when present.TEXTuse the nominative (10 октябрь 2026), andDATEVALUEdoesn't accept genitive forms (10 октября 2026). Russian Excel's behaviour for both was not observed.