Skip to content

Updated Czech localization - #1172

Merged
serhii73 merged 1 commit into
scrapinghub:masterfrom
TheXer:patch-2
Jun 22, 2026
Merged

serhii73 merged 1 commit into
scrapinghub:masterfrom
TheXer:patch-2

Conversation

@TheXer

@TheXer TheXer commented Jul 4, 2023

Copy link
Copy Markdown
Contributor

In some cases, there's some inconsistencies with Czech grammar. For example, in English:

In a month will output a correct datetime object - 1 month from now. But in Czech za měsíc won't print anything, but příští měsíc will. Both are correct Czech sentences.

The same proposed changes applies to za týden (in a week), za hodinu (in a hour), příští rok (next year).

Added new words:
In two days - pozítří
Two days ago - předevčírem
Last year - loni or vloni

And finally, added some new declensions of initial words.

@Gallaecio

Copy link
Copy Markdown
Contributor

- Add month locative/dative forms (lednu, únoru, březnu, dubnu, květnu,
  červnu, červenci, srpnu, říjnu, prosinci) for dates like "v lednu 2023"
- Add July abbreviation "črv"
- Fix "za měsíc/týden/rok" not parsing: add accusative simplification
  patterns (previous patterns only matched instrumental -em forms)
- Add tests covering the new expressions

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

codecov Bot commented Jun 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.11%. Comparing base (08c78d3) to head (70f5899).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1172   +/-   ##
=======================================
  Coverage   97.11%   97.11%           
=======================================
  Files         235      235           
  Lines        2909     2909           
=======================================
  Hits         2825     2825           
  Misses         84       84           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI 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.

Pull request overview

This PR improves Czech (cs) translation/normalization data so common grammatical variants (e.g., accusative forms used with “za” and locative month forms used with “v”) translate correctly into the project’s English-like intermediate representation used by dateparser’s parsing pipeline.

Changes:

  • Added Czech simplification rules so phrases like za týden / za měsíc / za rok translate to in 1 week / in 1 month / in 1 year.
  • Expanded Czech month token lists with additional declensions (e.g., lednu, únoru, červenci, etc.) to support inputs like v lednu.
  • Added/extended regression tests covering the new Czech phrases.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tests/test_languages.py Adds translation regression tests for new Czech phrases (za ..., v <month>).
dateparser/data/date_translation_data/cs.py Extends Czech month tokens and adds simplification regexes for accusative forms after za.
dateparser_data/supplementary_language_data/date_translation_data/cs.yaml Mirrors the added month declensions and za ... simplifications in supplementary YAML data used to generate bundled locale data.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@serhii73

Copy link
Copy Markdown
Collaborator

Thanks!

@serhii73
serhii73 merged commit eb111c2 into scrapinghub:master Jun 22, 2026
15 checks passed
serhii73 added a commit that referenced this pull request Jun 23, 2026
* Improve Czech (cs) language data (#1172)

- Add month locative/dative forms (lednu, únoru, březnu, dubnu, květnu,
  červnu, červenci, srpnu, říjnu, prosinci) for dates like "v lednu 2023"
- Add July abbreviation "črv"
- Fix "za měsíc/týden/rok" not parsing: add accusative simplification
  patterns (previous patterns only matched instrumental -em forms)
- Add tests covering the new expressions

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

* italian: support 'un ora fa', 'un'ora fa', 'oggi alle 11:00'.

Finishes PR #1049 and resolves conflicts with master:

- Keep master's improved "(\d+[.,]?\d*)\s+ora" simplification and add a new
  one mapping "un ora"/"un'ora" to "1 ore".
- Anchor the new simplification with word boundaries (\bun[' ]ora\b) so it no
  longer corrupts words such as "un orario" / "ciascun orario".
- Add "alle" to the skip tokens so "oggi alle 11:00" parses as "oggi 11:00".
- Regenerate it.py from it.yaml.
- Drop an accidental duplicate test line from the original PR and add a
  regression test that locks in the word-boundary fix.

Co-Authored-By: Serhii A <serhii@zyte.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Serhii A <aserhii@protonmail.com>
Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Serhii A <serhii@zyte.com>
serhii73 added a commit that referenced this pull request Jul 29, 2026
* Improve Czech (cs) language data (#1172)

- Add month locative/dative forms (lednu, únoru, březnu, dubnu, květnu,
  červnu, červenci, srpnu, říjnu, prosinci) for dates like "v lednu 2023"
- Add July abbreviation "črv"
- Fix "za měsíc/týden/rok" not parsing: add accusative simplification
  patterns (previous patterns only matched instrumental -em forms)
- Add tests covering the new expressions

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

* Do not read the day as a two-digit year after the year position (Close #519)

In year-first date orders (e.g. YMD, used by the Japanese locale),
parse_number tried the %y directive on every two-digit number, so in
"4月20日 18:10" the day 20 was consumed as the year 2020 and the day was
silently filled from the current date.

If a component that the date order places after the year has already
been found, the year position in the date string has already been
passed, so a two-digit number is now read as a year only if it cannot
be any other component (e.g. 99 in "4-99").

---------

Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@serhii73 serhii73 mentioned this pull request Aug 4, 2026
serhii73 added a commit that referenced this pull request Aug 28, 2026
)

* Improve Czech (cs) language data (#1172)

- Add month locative/dative forms (lednu, únoru, březnu, dubnu, květnu,
  červnu, červenci, srpnu, říjnu, prosinci) for dates like "v lednu 2023"
- Add July abbreviation "črv"
- Fix "za měsíc/týden/rok" not parsing: add accusative simplification
  patterns (previous patterns only matched instrumental -em forms)
- Add tests covering the new expressions

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

* Reject a %j day of year that the parsed year does not have

datetime.strptime resolves a day of year past the end of the parsed year
into the next year, so day 366 of a non-leap year became January 1 of the
following year:

    >>> dateparser.parse("1999366", date_formats=["%Y%j"])
    datetime.datetime(2000, 1, 1, 0, 0)

The returned year contradicted the year in the input, and invalid values
were rejected inconsistently: day 367 gave None while day 366 gave a date.

The std lib keeps the value it read for %j in struct_time.tm_yday even
after rolling the date into the next year, so the rollover can be spotted
by comparing it with the day of year of the resulting date. When the two
differ, strptime() now raises ValueError, which parse_with_formats()
already handles as "this format does not match".

_prepare_format() now also reports whether the format holds a real %j
directive, so that an escaped "%%j" literal is not mistaken for one.

Fixes #271.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
serhii73 added a commit that referenced this pull request Sep 16, 2026
)

* Improve Czech (cs) language data (#1172)

- Add month locative/dative forms (lednu, únoru, březnu, dubnu, květnu,
  červnu, červenci, srpnu, říjnu, prosinci) for dates like "v lednu 2023"
- Add July abbreviation "črv"
- Fix "za měsíc/týden/rok" not parsing: add accusative simplification
  patterns (previous patterns only matched instrumental -em forms)
- Add tests covering the new expressions

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

* Find a date written next to a relative one without a comma (#695)

search_dates('Today 13 Feb 2020') found no dates at all, while
'Today, 13 Feb 2020' found both. A chunk that does not parse as one date
is split by looking for a separator that the translation and the text it
was translated from hold the same number of times, and "today" is
translated into "0 day ago": the translation gains two spaces the text
never had, so the whitespace splitter is refused and the whole chunk is
dropped. The comma form works because the comma survives the translation
one for one.

Cut such a chunk where the relative expression ends instead. The cut is
taken only when the expression sits at one end of the chunk, when the
rest of the translation keeps one word per remaining original word, when
the word at that end really is the one the expression was translated
from -- which the locale is asked to confirm by translating it on its
own -- and when what is left of the chunk is a date. A chunk that fails
any of these is left alone rather than cut at a guess, which is why
'Today 13 Feb 2020 and 14 Mar 2021', whose "and" the translation drops,
still finds nothing.

The cut is only looked for when no separator lined up, so a chunk that
splits today keeps splitting exactly the way it does now.

Fixes #695

Co-Authored-By: Claude Opus 5 (1M context) <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.

5 participants