Skip to content

Conversation

@olafura
Copy link

@olafura olafura commented Mar 16, 2025

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.

olafura added 2 commits March 16, 2025 12:47
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.
@olafura
Copy link
Author

olafura commented Mar 16, 2025

I have signed the CLA!

assert_equal(['Ḥḛḛḽḽṓṓ, ẁṓṓṛḽḍ!'], @backend.translate(:en, ['Hello, world!'], {}))
end

def test_it_allows_only_cetain_locales
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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 = []
Copy link
Contributor

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]
Copy link
Contributor

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?

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