feat: allow for restricting the locales affected#91
feat: allow for restricting the locales affected#91olafura wants to merge 2 commits intoShopify:mainfrom
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.
| 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.
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.
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.