Skip to content

Commit

Permalink
Possible fix for #99
Browse files Browse the repository at this point in the history
  • Loading branch information
glebm committed Oct 10, 2014
1 parent c43cd5c commit 95f5175
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/i18n/tasks/google_translation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def from_values(list, translated_values)
keys.zip parse_value(untranslated_values, translated_values.to_enum)
end

# Prepare value for translation
# Only translate String and Array<String>
def dump_value(value)
case value
when Array
Expand All @@ -61,21 +63,22 @@ def dump_value(value)
when String
replace_interpolations value
else
value
nil
end
end

# Parse translated value from the each_translated enumerator
# @param [Array] untranslated
# @param [Enumerator] each_translated
def parse_value(untranslated, each_translated)
case untranslated
when Array
# implode array
untranslated.map { |from| parse_value(from, each_translated) }
when String
restore_interpolations untranslated, each_translated.next
when NilClass
nil
else
each_translated.next
untranslated
end
end

Expand Down

0 comments on commit 95f5175

Please sign in to comment.