Skip to content

Commit

Permalink
Also detect %{variable} in translations.
Browse files Browse the repository at this point in the history
  • Loading branch information
wvanbergen committed Jun 8, 2010
1 parent ac77341 commit 7d7ed74
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/tolk/translation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down
4 changes: 2 additions & 2 deletions test/locales/formats/en.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 7d7ed74

Please sign in to comment.