Skip to content

Commit

Permalink
Fix escaping character issue in Lokalise script (#7414)
Browse files Browse the repository at this point in the history
  • Loading branch information
tillh-stripe authored Oct 9, 2023
1 parent e340fb0 commit 8a0f140
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion scripts/lokalise/lokalise_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def create_key(key_object)
"translations": [
{
"language_iso": "en",
"translation": key_object[:value],
"translation": key_object[:lokalise_value],
"is_reviewed": true,
"is_unverified": false,
"is_archived": false,
Expand Down
7 changes: 2 additions & 5 deletions scripts/lokalise/string_resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ def fetch
end

def escape_for_lokalise(value)
value
# Wrap any placeholders in square brackets
.gsub("%s", "[%s]")
# Wrap any numbered placeholders such as ""%1$s" in square brackets
.gsub(/[%]*[0-9]*[$][s]/) { |value| "[#{value}]" }
# Remove escape characters, as Lokalise doesn't understand them
return value.gsub("\\", "")
end
end

0 comments on commit 8a0f140

Please sign in to comment.