doc/send-translations.rb
# Load from translation.io the translations for language lang into
# $CURRENT_TRANSLATIONS[lang]
Load from translation.io the translations for language lang into
$CURRENT_TRANSLATIONS[lang]
Load from translation . io the translations for language lang into $CURRENT_TRANSLATIONS [ lang ]
def load_language(lang)
  puts "Loading current translations for language #{lang}"
  system(
    'curl -X GET ' \
    "'https://translation.io/api/v1/segments.json?target_language=#{lang}' " \
    "-H 'x-api-key: #{$API_KEY}' > ,full-list"
  )
  current_translations_file_contents = File.read(',full-list')
  current_translations_json = JSON.parse(current_translations_file_contents)
  if current_translations_json.key?('errors')
    puts 'Error:'
    puts current_translations_json['errors']
    exit 1
  end
  $CURRENT_TRANSLATIONS[lang] = {}
  current_translations_json['segments'].each do |segment|
    if segment['target_language'] != lang
      STDERR.puts "Error: Expected language #{lang} in segment #{segment}"
      exit 1
    end
    $CURRENT_TRANSLATIONS[lang][segment['key']] = segment
  end
end
def load_language ( lang ) puts "Loading current translations for language #{lang}" system ( 'curl -X GET ' "'https://translation.io/api/v1/segments.json?target_language=#{lang}' " "-H 'x-api-key: #{$API_KEY}' > ,full-list" ) current_translations_file_contents = File . read ( ',full-list' ) current_translations_json = JSON . parse ( current_translations_file_contents ) if current_translations_json . key? ( 'errors' ) puts 'Error:' puts current_translations_json [ 'errors' ] exit 1 end $CURRENT_TRANSLATIONS [ lang ] = { } current_translations_json [ 'segments' ] . each do | segment | if segment [ 'target_language' ] != lang STDERR . puts "Error: Expected language #{lang} in segment #{segment}" exit 1 end $CURRENT_TRANSLATIONS [ lang ] [ segment [ 'key' ] ] = segment end end
Load from translation.io the translations for language lang into
$CURRENT_TRANSLATIONS[lang]
Load from translation . io the translations for language lang into $CURRENT_TRANSLATIONS [ lang ]
# Initialize hash in CURRENT_TRANSLATIONS for this new language # Reorganize so that $CURRENT_TRANSLATIONS[lang][key] contains segment # information that translations.io provides: # id, key, target_language, target, etc. # Work around bug in Rubocop
lang
<not_specific>