Support geozone segments with non-Latin characters
The `parameterize` method uses the `I18n.transliterate` method, whose
documentation says:
```
I18n.transliterate("Ærøskøbing")
=> "AEroskobing"
I18n.transliterate("日本語")
=> "???"
```
That means we can't use it for dictionaries where characters don't have
a transliteration to the latin alphabet.
So we're changing the code in order to only transliterate characters
with a transliteration to the latin alphabet.
Note the first example ("Česká republika") already worked with the
previous code; the test has been added to make sure accented characters
are handled properly.
This commit is contained in:
@@ -31,6 +31,16 @@ describe UserSegments do
|
||||
expect(UserSegments.segment_name("lowlands_and_highlands")).to eq "Lowlands and Highlands"
|
||||
end
|
||||
|
||||
it "supports international alphabets" do
|
||||
create(:geozone, name: "Česká republika")
|
||||
create(:geozone, name: "България")
|
||||
create(:geozone, name: "日本")
|
||||
|
||||
expect(UserSegments.segment_name("ceska_republika")).to eq "Česká republika"
|
||||
expect(UserSegments.segment_name("България")).to eq "България"
|
||||
expect(UserSegments.segment_name("日本")).to eq "日本"
|
||||
end
|
||||
|
||||
it "returns regular segments when the geozone doesn't exist" do
|
||||
expect(UserSegments.segment_name("all_users")).to eq "All users"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user