Skip to content
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 option to disable case-changing of language codes #18

Conversation

stevejalim
Copy link
Collaborator

@stevejalim stevejalim commented Jul 30, 2024

This changeset adds a new setting - REFORMAT_LANGUAGE_CODES, default True, which we can use to control whether w-l-s will reformat lang codes as part of the Smartling sync.

By default w-l-s assumes the Django project will be using Django's core default of all-lowercase language codes (compared to Smartling's mixed-case approach) and forces all lang codes to the relevant style depending on the direction of travel. This change allows us to skip that step when importing strings back into Wagtail, (and the equivalent step when sending lang codes to Smartling, too, just for consistency and no surprise).

Testing

Manually tested locally. I have a stash locally with some tests for test_utils.py but neither @override_settings nor mock.patch.object seem to work for setting fake settings during a test - the former gets ignored and the latter blows up because the patched attribute can't be deleted/changed. If anyone has a tip about that, I'd welcome it

Resolves #17

@stevejalim stevejalim changed the title Add option to disable downcasing of locales Add option to disable case-changing of language codes Jul 31, 2024
Copy link
Collaborator

@zerolab zerolab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me.

I did struggle with @override_settings too when doing the locale mapping callback in the first place. pytest is cool, and also a steeper learning curve than I thought it be in some places

@stevejalim
Copy link
Collaborator Author

I did struggle with @override_settings too when doing the locale mapping callback in the first place. pytest is cool, and also a steeper learning curve than I thought it be in some places

Well I need to get better at dataclasses usage, because this caught me by surprise and stopped me using with mock.patch.object(smartling_settings, REFORMAT_LANGUAGE_CODES, some_var):

dataclasses.FrozenInstanceError: cannot assign to field 'REFORMAT_LANGUAGE_CODES'

@stevejalim stevejalim merged commit cd7b063 into bugfix/consistent-locale-id-mapping Jul 31, 2024
15 checks passed
@stevejalim stevejalim deleted the add-option-to-disable-downcasing-of-locales branch July 31, 2024 13:29
@stevejalim stevejalim self-assigned this Aug 2, 2024
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