feat(locale): add Polish support and complex pluralization#683
Open
juliarzymowska wants to merge 1 commit intorendercv:mainfrom
Open
feat(locale): add Polish support and complex pluralization#683juliarzymowska wants to merge 1 commit intorendercv:mainfrom
juliarzymowska wants to merge 1 commit intorendercv:mainfrom
Conversation
- Update EnglishLocale schema to support dictionary-based pluralization for months and years using 'str | dict[str, str]'. - Implement a centralized plural rule registry in plural_rules.py following Unicode CLDR standards. - Refactor compute_time_span_string in date.py to select unit labels based on language-specific numeric rules. - Add the Polish locale with grammatically correct paucal (few) and genitive plural (many) forms.
Member
|
Thank you. I'll review this before v2.8 release. |
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.
Description
This PR introduces support for the Polish locale and refactors the duration calculation logic to support languages with complex pluralization rules.
The Problem
Previously, RenderCV utilized a binary pluralization logic (singular
if n=1, elseplural). This is insufficient for languages like Polish, where nouns decline into three or more forms depending on the numeral:Using a simple string for the months or years field forced users to choose one incorrect form for durations like "5 months" or "22 years".
Key Changes
compute_time_span_stringin date.py to use a universal helper function,_get_localized_label. This ensures that years and months follow the exact same linguistic rules.How to add new complex language
After following instructions to add a new language new contributors should:
Identify plural rules
Check the https://www.unicode.org/cldr/charts/48/supplemental/language_plural_rules.html for target language (link is also in
plural_rules.py).Implement logic in
plural_rules.pyAdd language's numeric logic to
plural_rules.py:In locale YAML (e.g
polish.yaml) use dictionary formonthsandyearsfields (keys have to match strings returned rule function!)Done!
Others
There is a
default_ruleas a fallback even if a specific rule of key is missing.There is backward compatibility for simple string-based locales (English, German, etc.).