module PolyglotIos module Resource class TranslationKey < Base def clean_translation(language) translation_value = name translation = translations.find { |key| key.language.id == language.id } if translation && translation.value translation_value = translation.value end escape_translation(translation_value) end private def escape_translation(translation) translation .gsub("\"", "\\\"") .gsub("%s", "%@") .gsub(/(%\d+)(\$)(s)/, '\1\2@') # Positional parameter support, converts %1$s to %1$@ for example end end end end