Repository navigation
refactor(util): read a locale tag in one place - #1272
Merged
Merged
Conversation
The formula names, the number symbols, the month names and the boolean words each read the BCP 47 tag of a locale on their own, with different rules: one lowered the case, one took the last subtag as the region, and three of four mapped `no` to `nb`. util::locale::LanguageTag::parse now reads the language, the script and the region once, in any case and with `-` or `_`, and drops a variant and an extension. So `pt-Latn-BR` takes the Brazilian names, `zh-Hans` has no region, and `DE-ch` and `de_CH` group with an apostrophe. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YHNzLmVv1mFWfPitHASucN
andiwand
force-pushed
the
refactor/locale-util
branch
from
October 25, 2026 10:09
178f178 to
109f018
Compare
lower_function_letter lowercased only the letters of the generated name table and mapped the Turkish I, so it could not leave the formula code. util::locale::to_lower now lowercases any letter from a table of the 1460 Unicode letters whose lowercase is one code point, which tools/util/generate_lowercase.py writes, and takes the dotless i of tr and az. util::locale::equals_ignore_case compares two UTF-8 strings with it, and the formula code uses it in place of same_name. The formula table and its generator are as they were before #1270. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YHNzLmVv1mFWfPitHASucN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Generated with Claude Code
Follows #1270.
Summary
Four places read the BCP 47 tag of a locale, each with its own rules:
formula::language_of(function names)notonb, and matched only the exact tagpt-BRnumber_format::symbols_of(decimal sign, grouping)names_of(month names) andboolean_wordsnotonbutil::locale::LanguageTag::parse(newsrc/odr/internal/util/locale_util.{hpp,cpp}) now reads the tag once:noasnb-or_between the subtags, in any case-u-,-x-) droppedThe callers use it, so the four
no→nbmappings and the"no"entry of the grouping table go away. The LibreOffice keypt-BRstays in the formula code, but it now tests the language and the region.Lowercase.
lower_function_letterlowercased only the letters of the generated name table, and mapped the TurkishIforsame_name. It is gone, and the formula table and its generator are as they were before #1270:util::locale::to_lower(letter, language)lowercases any letter fromlowercase_table.cpp: the 1460 Unicode letters whose lowercase is one code point.tools/util/generate_lowercase.pywrites it from the Unicode data of Python (16.0.0 here), and adds the simple lowercaseiofİ. Intrandaz,Ibecomesı.util::locale::equals_ignore_case(a, b, language)compares two UTF-8 strings with it, in place ofsame_name.What a user sees:
pt-Latn-BRandpt_brtake the Brazilian function names,zh-Hanshas no region, andDE-chandde_CHgroup with an apostrophe.Test
LocaleUtil.*(9 tests): case,_, script, variant, extension, Norwegian, empty, the lowercase of Latin, Greek, Cyrillic and an astral letter, the TurkishI, and a compare of UTF-8.NumberFormatandFormulaWritercheck the new tags at their callers:COLUMNisCOLin Portugal andCOLUNAin Brazil.locale,formula-input,formula-wordsanddates.-Wall -Wextra -Werrorcheck of the three changed sources is clean, and clang-tidy reports nothing on them.Review fixes
data-odr-localetoIntlinside atry, and the[$-407]of a number format code is an LCID, which keeps its own path. The decoders write the tag with-.