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

VPN-6649: fix translations for cities with special characters #10029

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions scripts/ci/update_server_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,15 @@ def fetch_server_list():
string_map = countries
for city in cities:
# Remove state suffix, capitalize each work, remove spaces.
id = city.split(",")[0].strip().title().replace(" ", "")
string_map[id] = city
baseId = city.split(",")[0].strip().title().replace(" ", "")
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should be able to obtain the same with this code

        id = city.split(",")[0].strip().title().replace(" ", "")
        id = re.sub(r'[^A-Za-z\s]', '', id)
        string_map[id] = city

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good call, thanks! Updated this.

I didn't include the white space check (\s), as I don't think we need it. We remove all spaces in the first line (.replace(" ", "")). While no current city names have any other whitespace characters, we'd want to remove them if they did.

# Remove special characters like the `ö` in `Malmö`
allowedIdChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
simpleId = ""
for char in baseId:
if char in allowedIdChars:
simpleId = simpleId + char
# Add it to the map
string_map[simpleId] = city

###
# 2. Fetch the list of servers in extras.xliff
Expand Down
6 changes: 3 additions & 3 deletions src/translations/extras/extras.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,6 @@
<trans-unit id="servers.Gothenburg" xml:space="preserve">
<source>Gothenburg</source>
</trans-unit>
<trans-unit id="servers.Malmö" xml:space="preserve">
<source>Malmö</source>
</trans-unit>
<trans-unit id="servers.Stockholm" xml:space="preserve">
<source>Stockholm</source>
</trans-unit>
Expand Down Expand Up @@ -531,6 +528,9 @@
<trans-unit id="servers.Nicosia" xml:space="preserve">
<source>Nicosia</source>
</trans-unit>
<trans-unit id="servers.Malm" xml:space="preserve">
<source>Malmö</source>
</trans-unit>
</body>
</file>
</xliff>
Loading