Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Also detect %{variable} in translations.

  • Loading branch information...
commit 7d7ed74a253d4c4ca1d76c0afda9228a444074b3 1 parent ac77341
@wvanbergen wvanbergen authored
Showing with 3 additions and 3 deletions.
  1. +1 −1  app/models/tolk/translation.rb
  2. +2 −2 test/locales/formats/en.yml
View
2  app/models/tolk/translation.rb
@@ -56,7 +56,7 @@ def value
def self.detect_variables(search_in)
case search_in
- when String then Set.new(search_in.scan(/\{\{(\w+)\}\}/).flatten)
+ when String then Set.new(search_in.scan(/\{\{(\w+)\}\}/).flatten + search_in.scan(/\%\{(\w+)\}/).flatten)
when Array then search_in.inject(Set[]) { |carry, item| carry + detect_variables(item) }
when Hash then search_in.values.inject(Set[]) { |carry, item| carry + detect_variables(item) }
else Set[]
View
4 test/locales/formats/en.yml
@@ -1,11 +1,11 @@
en:
number: 1
string: I am just a stupid string :(
- variables: "String with variables {{hello}} and {{world}}"
+ variables: "String with variables {{hello}} and %{world}"
variables_in_struct:
zero: "Without variable"
one: "With {{variables}}"
- other: "With even {{more}} {{variables}}"
+ other: "With even %{more} {{variables}}"
number_array: [1, 2, 3]
string_array: ['sun', 'moon']
pluralization:
Please sign in to comment.
Something went wrong with that request. Please try again.