Skip to content

Update the CLDR data - #1216

Closed
Gallaecio wants to merge 4 commits into
scrapinghub:masterfrom
Gallaecio:cldr-update
Closed

Update the CLDR data#1216
Gallaecio wants to merge 4 commits into
scrapinghub:masterfrom
Gallaecio:cldr-update

Conversation

@Gallaecio

@Gallaecio Gallaecio commented Feb 1, 2024

Copy link
Copy Markdown
Contributor

No description provided.

@serhii73

Copy link
Copy Markdown
Collaborator

Closing in favour of #1343, which re-implements this work cleanly on top of current master (the branch had merge conflicts and the PR was still a draft). Thank you @Gallaecio for the original work!

@serhii73 serhii73 closed this Jun 24, 2026
serhii73 added a commit that referenced this pull request Jul 22, 2026
* Update CLDR data to 44.1.0 and add hour/duration support

- Upgrade CLDR source data from version 31.0.1 to 44.1.0: 288 new
  locales added, all existing locale JSONs updated in
  dateparser_data/cldr_language_data/date_translation_data/
- Add hour/duration unit to relative-type data for all locales
- Regenerate all dateparser/data/date_translation_data/*.py from the
  new source data, keeping master's possessive-quantifier optimization
  in relative-type-regex patterns
- Modernize dateparser_scripts/ to use pathlib.Path and unified
  cldr-json repository layout (utils.py, write_complete_data.py,
  get_cldr_data.py, order_languages.py)
- Restore Ukrainian words removed by the CLDR upgrade (uk.yaml)
- Update docs/supported_locales.rst and languages_info.py
- Update 34 test inputs in test_languages.py to reflect CLDR 44.1.0
  abbreviation/name changes (bs-Latn, ce, kl, qu, so, sr, sw, zu,
  am, as, brx, hy, ig, kok, mr, nn, de, eu, gu, mk, chr, bs-Cyrl)
- Add /cldr-json/ to .gitignore

Finishes PR #1216 (Gallaecio:cldr-update).

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

* Fix 7 regressions from CLDR 44.1.0 update

- en.yaml: restore 'in {0} weeks time' and 'in {0} weeks\' time' patterns
  for 'in \1 week' that CLDR 44 dropped; regenerate en.py
- af.yaml: restore 'sek' (second abbreviation) dropped by CLDR 44; regenerate af.py
- en-US: CLDR 44 has no en-US.json (US settings merged into base en);
  add minimal en-US.json, regenerate en-US.py, add en-US back to
  languages_info.py locale list for 'en'
- tests/test_freshness_date_parser.py: update Cherokee (chr) test input
  from uppercase to lowercase Cherokee encoding used by CLDR 44 patterns
- tests/test_search.py: update Danish detection test to text that includes
  'tirsdag' and 'januar' (distinctly Danish vs Swedish), since CLDR 44
  sv.py changes caused the old text to be ambiguous

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

* Fix en-US locale name: add to en.yaml locale_specific section

The en-US locale is loaded via en.py's locale_specific["en-US"] section,
not as a standalone language file. Adding it to en.yaml ensures the
locale_specific entry gets the correct name ("en-US") and date_order
(MDY). Remove the standalone en-US.json that was added by mistake.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

* Finalize CLDR 44 update: keep supported locale set and address review

Regenerating the data files for CLDR 44 also produced ~144 new low-resource
locales, but languages_info.py (the locale registry) was never regenerated, so
those files were shipped unused (parse(locales=['ceb']) raised ValueError).
Rather than expand the auto-detected language set in this data-refresh PR, keep
the supported set identical to master and defer the new locales to a dedicated
change.

- order_languages.py: exclude the 144 new CLDR 44 locales via avoid_languages so
  generation stays limited to the already-supported set.
- Regenerate data: drop the 144 unused locale files and their intermediate JSON;
  the 205 supported locales are byte-identical.
- Restore ff-CM/ff-GN/ff-MR (dropped by CLDR 44, moved under ff-Latn): keep them
  registered and add supplementary ff.yaml so they resolve to the base `ff` data,
  preserving backwards compatibility.
- languages_info.py and docs/supported_locales.rst: revert to master now that the
  supported set is unchanged (en-US stays in sorted order, ff keeps its locales).
- Drop the unnecessary OrderedDict usage from the generation scripts: dict keeps
  insertion order on all supported Python versions and the output is sorted, so
  the generated data is byte-identical.
- Add tests for the new hour/duration parsing (ca "2 hores") and ff-CM/GN/MR
  backwards compatibility.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Restore vocabulary dropped by CLDR 44 so original tests pass unchanged

The CLDR 31->44 refresh silently dropped ~690 previously-recognized
words/patterns across 87 languages (e.g. ru "5 д назад", de "nachm.",
pt "há 5 mins", hi "5 मि पहले", mk "минатата година", da "tir"/"tor").
Restore all of them through supplementary_language_data YAMLs - the
mechanism already used for uk/en/af/ff - so the update becomes purely
additive: every form that parsed before still parses, plus ~1,800 new
CLDR 44 forms.

Excluded from the restore are 8 forms that CLDR corrected deliberately
(dsb/hsb "now" is a November abbreviation, mk "недела" moved from week
to sunday, hi "से" moved from second to skip, bg "с" moved from second
to week, af "oor N minuut" was wrongly mapped to in-N-days/months, and
ms "dalam N saat" was wrongly mapped to in-N-years).

Revert all test-expectation edits back to master, keeping only the
additive tests (ff-CM/ff-GN/ff-MR locales, ca standalone hour unit).

Add "den" as a Danish skip word: CLDR 44 gave Swedish "den här veckan"
style phrases, which made Danish text win-by-tie-break as "sv" in
language detection. Danish dates routinely use "den" ("den 8. maj
1945"), so this restores correct detection and makes such strings
parseable; the two Danish search_dates spans now include "den", like
"de" in Spanish.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants