-
-
Notifications
You must be signed in to change notification settings - Fork 539
Add l10n helper script #2607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add l10n helper script #2607
Conversation
Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughA new script, Changes
Possibly related PRs
Suggested labels
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (2)📓 Common learnings
scripts/l10n/l10n_helper.py (2)
🪛 Pylint (3.3.7)scripts/l10n/l10n_helper.py[convention] 1-1: Missing module docstring (C0114) [error] 25-25: Unable to import 'polib' (E0401) [convention] 30-30: Missing class docstring (C0115) [convention] 68-68: Missing function or method docstring (C0116) [refactor] 68-68: Too many local variables (21/15) (R0914) [error] 70-70: Unable to import 'holidays.registry' (E0401) [convention] 70-70: Import outside toplevel (holidays.registry.COUNTRIES) (C0415) [warning] 81-81: Using possibly undefined loop variable 'module_name' (W0631) [convention] 120-120: Missing function or method docstring (C0116) [convention] 148-148: Missing function or method docstring (C0116) [convention] 158-158: Missing function or method docstring (C0116) [convention] 165-165: Missing function or method docstring (C0116) [convention] 187-187: Missing function or method docstring (C0116) [refactor] 187-187: Too many local variables (18/15) (R0914) [refactor] 187-187: Too many branches (13/12) (R0912) [convention] 223-223: Missing function or method docstring (C0116) ⏰ Context from checks skipped due to timeout of 300000ms (1)
🔇 Additional comments (7)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #2607 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 228 229 +1
Lines 14533 14571 +38
Branches 2038 2039 +1
=========================================
+ Hits 14533 14571 +38 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
scripts/l10n/l10n_helper.py
(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Comm 10000 on learnings
Learnt from: PPsyrius
PR: vacanza/holidays#2537
File: holidays/countries/finland.py:195-199
Timestamp: 2025-05-09T18:34:33.990Z
Learning: In the holidays library, localization (l10n) is handled through separate .po files for different languages rather than combining multiple translations in a single string. The code should use the default language with tr() function, and translations are provided in language-specific .po files.
🪛 Pylint (3.3.7)
scripts/l10n/l10n_helper.py
[convention] 1-1: Missing module docstring
(C0114)
[error] 26-26: Unable to import 'polib'
(E0401)
[convention] 31-31: Missing class docstring
(C0115)
[refactor] 63-63: Consider using 'sys.exit' instead
(R1722)
[convention] 69-69: Missing function or method docstring
(C0116)
[refactor] 69-69: Too many local variables (25/15)
(R0914)
[error] 71-71: Unable to import 'holidays.holiday_base'
(E0401)
[convention] 71-71: Import outside toplevel (holidays.holiday_base.HolidayBase)
(C0415)
[error] 72-72: Unable to import 'holidays.registry'
(E0401)
[convention] 72-72: Import outside toplevel (holidays.registry.COUNTRIES)
(C0415)
[refactor] 81-81: Consider using 'sys.exit' instead
(R1722)
[warning] 83-83: Using possibly undefined loop variable 'module_name'
(W0631)
[convention] 125-125: Missing function or method docstring
(C0116)
[refactor] 128-128: Consider using 'sys.exit' instead
(R1722)
[convention] 153-153: Missing function or method docstring
(C0116)
[refactor] 156-156: Consider using 'sys.exit' instead
(R1722)
[convention] 164-164: Missing function or method docstring
(C0116)
[convention] 171-171: Missing function or method docstring
(C0116)
[convention] 193-193: Missing function or method docstring
(C0116)
[refactor] 193-193: Too many local variables (18/15)
(R0914)
[refactor] 193-193: Too many branches (13/12)
(R0912)
[convention] 229-229: Missing function or method docstring
(C0116)
🔇 Additional comments (2)
scripts/l10n/l10n_helper.py (2)
171-192
: Implementation looks good!The import logic correctly handles translation updates and only saves when changes are detected.
🧰 Tools
🪛 Pylint (3.3.7)
[convention] 171-171: Missing function or method docstring
(C0116)
229-238
: Clean dispatch implementation!The run method provides a clear entry point for different operations.
🧰 Tools
🪛 Pylint (3.3.7)
[convention] 229-229: Missing function or method docstring
(C0116)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
♻️ Duplicate comments (1)
scripts/l10n/l10n_helper.py (1)
70-70
: 🧹 Nitpick (assertive)Use safer path manipulation for sys.path.
Using
sys.path.append()
with f-string is less clear than usingsys.path.insert(0, str(Path.cwd()))
for adding the current directory to the Python path.-sys.path.append(f"{Path.cwd()}") # Make holidays visible. +sys.path.insert(0, str(Path.cwd())) # Make holidays visible.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
scripts/l10n/l10n_helper.py
(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: PPsyrius
PR: vacanza/holidays#2537
File: holidays/countries/finland.py:195-199
Timestamp: 2025-05-09T18:34:33.990Z
Learning: In the holidays library, localization (l10n) is handled through separate .po files for different languages rather than combining multiple translations in a single string. The code should use the default language with tr() function, and translations are provided in language-specific .po files.
🪛 Pylint (3.3.7)
scripts/l10n/l10n_helper.py
[convention] 1-1: Missing module docstring
(C0114)
[error] 26-26: Unable to import 'polib'
(E0401)
[convention] 31-31: Missing class docstring
(C0115)
[convention] 69-69: Missing function or method docstring
(C0116)
[refactor] 69-69: Too many local variables (25/15)
(R0914)
[error] 71-71: Unable to import 'holidays.holiday_base'
(E0401)
[convention] 71-71: Import outside toplevel (holidays.holiday_base.HolidayBase)
(C0415)
[error] 72-72: Unable to import 'holidays.registry'
(E0401)
[convention] 72-72: Import outside toplevel (holidays.registry.COUNTRIES)
(C0415)
[warning] 83-83: Using possibly undefined loop variable 'module_name'
(W0631)
[convention] 125-125: Missing function or method docstring
(C0116)
[convention] 153-153: Missing function or method docstring
(C0116)
[convention] 164-164: Missing function or method docstring
(C0116)
[convention] 171-171: Missing function or method docstring
(C0116)
[convention] 193-193: Missing function or method docstring
(C0116)
[refactor] 193-193: Too many local variables (18/15)
(R0914)
[refactor] 193-193: Too many branches (13/12)
(R0912)
[convention] 229-229: Missing function or method docstring
(C0116)
⏰ Context from checks skipped due to timeout of 300000ms (2)
- GitHub Check: Test docs build
- GitHub Check: Build distribution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
scripts/l10n/l10n_helper.py
(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: PPsyrius
PR: vacanza/holidays#2537
File: holidays/countries/finland.py:195-199
Timestamp: 2025-05-09T18:34:33.990Z
Learning: In the holidays library, localization (l10n) is handled through separate .po files for different languages rather than combining multiple translations in a single string. The code should use the default language with tr() function, and translations are provided in language-specific .po files.
Learnt from: KJhellico
PR: vacanza/holidays#2607
File: scripts/l10n/l10n_helper.py:86-88
Timestamp: 2025-06-06T15:23:42.307Z
Learning: The scripts/l10n/l10n_helper.py script is an internal localization helper tool intended for use by developers who understand the codebase, so additional safety checks may not be necessary.
scripts/l10n/l10n_helper.py (1)
Learnt from: KJhellico
PR: vacanza/holidays#2607
File: scripts/l10n/l10n_helper.py:147-150
Timestamp: 2025-06-06T15:22:39.909Z
Learning: In the holidays project localization system, all .po files are generated from the same .pot template for all supported languages, ensuring that all msgids exist for all languages. This makes defensive programming for missing language keys in po_data[msgid] unnecessary in the normal workflow.
🪛 Pylint (3.3.7)
scripts/l10n/l10n_helper.py
[convention] 1-1: Missing module docstring
(C0114)
[error] 25-25: Unable to import 'polib'
(E0401)
[convention] 30-30: Missing class docstring
(C0115)
[convention] 68-68: Missing function or method docstring
(C0116)
[refactor] 68-68: Too many local variables (21/15)
(R0914)
[error] 70-70: Unable to import 'holidays.registry'
(E0401)
[convention] 70-70: Import outside toplevel (holidays.registry.COUNTRIES)
(C0415)
[warning] 81-81: Using possibly undefined loop variable 'module_name'
(W0631)
[convention] 118-118: Missing function or method docstring
(C0116)
[convention] 146-146: Missing function or method docstring
(C0116)
[convention] 157-157: Missing function or method docstring
(C0116)
[convention] 164-164: Missing function or method docstring
(C0116)
[convention] 186-186: Missing function or method docstring
(C0116)
[refactor] 186-186: Too many local variables (18/15)
(R0914)
[refactor] 186-186: Too many branches (13/12)
(R0912)
[convention] 222-222: Missing function or method docstring
(C0116)
⏰ Context from checks skipped due to timeout of 300000ms (2)
- GitHub Check: Test build on ubuntu-latest
- GitHub Check: Test build on macos-latest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huge improvement 👍
I'd like to suggest some improvements and options to check:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
// I have some naming improvement suggestions that can be addressed separately later.
@arkid15r I think I misclicked and accidentally disabled auto-merge - please enable them again 🥲 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, should be quite useful with the eventual l10n file unification in v1 👍
Proposed change
Add l10n helper script - tool to simplify the localization process.
Actually, I just wanted to do export/import from .po to .csv for easy spreadsheet editing, but then I went further.
Recommended operating cycle (for a newly created country)
default_language
andsupported_languages
are specified in code.make l10n
orpython scripts/l10n/generate_po_files.py
(to create .pot file).python scripts/l10n/l10n_helper.py MM --create-po --overwrite
(MM is the country code hereinafter). This will create .po files for all supported languages. If you don't need .csv files, you can stop here and just work with .po files using your usual methods. For en_US locale, translations will be retrieved from msg comments (!).python scripts/l10n/l10n_helper.py MM --export-csv
. This will create holidays/locale/csv/MM.csv file. You can edit it in any way you like. If you plan to use MS Excel, it's advisable to runpython scripts/l10n/l10n_helper.py MM --export-csv --bom
to generate a file in encoding "UTF-8 with BOM" that Excel prefers.python scripts/l10n/l10n_helper.py MM --fill-missing
(with--bom
, if you created .csv with it). This will try to fill in missing translations with available variants from the corresponding languages (matching is based on msg comment).python scripts/l10n/l10n_helper.py MM --import-csv
(with--bom
, if you created .csv with it). This will update .po files with your translation from .csv.I will appreciate any comments and suggestions.
Type of change
holidays
functionality in general)Checklist
make check
, all checks and tests are green