-
Notifications
You must be signed in to change notification settings - Fork 13
feat: allow for restricting the locales affected #91
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
base: main
Are you sure you want to change the base?
feat: allow for restricting the locales affected #91
Conversation
It's often useful to limit where the pseudolocalization gets applied. This allows for checking the difference between applied and unapplied locales. It also allows for using a strategy where only locales such as XX or ZZ are used.
|
I have signed the CLA! |
| assert_equal(['Ḥḛḛḽḽṓṓ, ẁṓṓṛḽḍ!'], @backend.translate(:en, ['Hello, world!'], {})) | ||
| end | ||
|
|
||
| def test_it_allows_only_cetain_locales |
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.
| def test_it_allows_only_cetain_locales | |
| def test_it_allows_only_certain_locales |
| def initialize(original_backend) | ||
| @original_backend = original_backend | ||
| @ignores = [] | ||
| @only_locales = [] |
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.
Instead of defaulting to an empty array, and having custom logic to bypass the feature if the array is empty, would it be possible to instantiate this array to I18n.available_locales? Doing so would allow us to transform if locale_ignored?(locale) info if pseudolocalized_locale?(locale), and simply have it check if the locale is part of the array. An added benefit would be the ability to set that array to empty, and completely bypass pseudolocalization for all locales.
|
|
||
| ```ruby | ||
| I18n.backend = Pseudolocalization::I18n::Backend.new(I18n.backend) | ||
| I18n.backend.only_locales = [:en, :xx, :zz] |
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.
I wonder if it wouldn't be clearer if we were to reuse the naming convention of available_locales. If the pseudolocalization backend's available_locales doesn't include locale X, then it passes it through?
It's often useful to limit where the pseudolocalization
gets applied. This allows for checking the difference
between applied and unapplied locales. It also allows
for using a strategy where only locales such as XX or ZZ
are used.