Sha256: 30995c1e6827a6c175d3e37aa403138b01470a95cf4312df21d5ec8fc9beb5eb
Contents?: true
Size: 1 KB
Versions: 12
Compression:
Stored size: 1 KB
Contents
module PolyglotIos module Serializer class Translation class << self def write(translation_keys, language, translations_path, use_old_naming = false) translations = extract_translations(translation_keys, language) data = translations .sort .map { |key, value| "\"#{key}\" = \"#{value}\";" } .join("\n") .concat("\n") FileUtils.mkdir_p translations_path unless File.exist? translations_path locale_code = language.code(use_old_naming) output_path = File.join(translations_path, "#{locale_code}.strings") File.write(output_path, data) end def extract_translations(translation_keys, language) translation_keys.each_with_object({}) do |translation_key, strings| key_name = translation_key.name next if key_name.nil? strings[key_name] = translation_key.clean_translation(language) end end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems