Conversation
--language was already threading through to request_options.language on export, but --country never reached the REST API. tabcmd Classic combined the two into a BCP 47 locale like en-GB or de-DE so exports formatted numbers, dates, and currency for that region. - Add _resolve_locale() that joins language + country when both are set, falls back to language alone, and drops country-only (matching Classic which required --language with --country). - Route apply_png_options / apply_pdf_options / apply_csv_options through the helper. - Relax --country choices from language codes to any 2-letter code (upper-cased), so users can pass real country codes like GB, MX, BR. Fixes #109.
The docstring/PR body claimed --country alone was warned about, but the code silently dropped it. Thread the logger through _resolve_locale and emit a warning that names the ignored country code. Adds tests for both the warn-and-drop and don't-warn-when-language-is-set paths. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Address country validation and rebuild the localization catalogs.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (2)
What changed in this PR
Connects --language and --country to PNG, PDF, and CSV export locales.
Changes:
- Combines language and country into BCP 47 locales.
- Warns when country is supplied without language.
- Adds locale handling and test coverage.
| File | Summary | Findings |
|---|---|---|
tests/commands/test_datasources_and_workbooks_command.py |
Tests locale resolution and export options. | None |
tabcmd/locales/en/tabcmd_messages_en.properties |
Adds the country-only warning message. | Nit (3 votes): rebuild and commit generated catalogs. |
tabcmd/execution/parent_parser.py |
Normalizes country input. | Moderate (3 votes): validate exactly two ASCII letters. |
tabcmd/commands/datasources_and_workbooks/datasources_and_workbooks_command.py |
Applies resolved locales to export requests. | None |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # ISO 3166-1 alpha-2 country code (case-insensitive). Combined with --language | ||
| # to form a locale (e.g. --language en --country GB -> "en-GB"). Left | ||
| # unconstrained on choices since Classic accepts any 2-letter country code. | ||
| type=str.upper, |
| export.errors.white_space_workbook_view=The name of the workbook or view to export cannot include spaces. Use the normalized name of the workbook or view as it appears in the URL. | ||
| export.errors.requires_workbook_view_param=The ''{0}'' command requires a <workbook>/<view> parameter, and there must be at least one slash (/) in this parameter | ||
| export.errors.requires_valid_custom_view_uuid=The URL for custom views must contain a valid custom view uuid | ||
| export.locale.country_without_language=--country {0} was ignored: --country requires --language (e.g. --language en --country GB). Using the site''s default locale. |
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.


Closes #109.
Motivation
--languagewas threading through torequest_options.languageonexport, but
--countrynever reached the REST API. Classic combinedthe two into a BCP 47 locale (
en-GB,de-DE,pt-BR) so exportsformatted numbers, dates, and currency for that region. tabcmd 2's
--countrywas cosmetic.Behavior change
For users:
_resolve_locale()joins--language+--countryinto alang-COUNTRYlocale string when both are set; falls back tolanguage alone if only that is supplied.
--countryalone now logs a WARNING that names the ignored countrycode and drops it (matching Classic which required
--languagewith--country). Previously silently dropped.--countrychoices relaxed from the incorrectly-populated languagecodes (
de|en|es|...) to any 2-letter code (upper-cased), so userscan actually pass
GB,MX,BR, etc.apply_png_options/apply_pdf_options/apply_csv_options.Test plan
tests/commands/test_datasources_and_workbooks_command.py— 8new tests cover combined locale for PNG/PDF/CSV, country-only drops
with a warning, language-only pass-through does not warn
🤖 Generated with Claude Code