]> git.openstreetmap.org Git - rails.git/blobdiff - script/locale/po2yaml
Fix most auto-correctable rubocop issues
[rails.git] / script / locale / po2yaml
index f2d2eb97cfe4fe7685677d4839ecd1707b63fc4e..ea78ce2c64a3e1135fe18840f2cea47e4d3c71af 100755 (executable)
@@ -11,7 +11,7 @@ def add_translation(hash, keys, value)
   if keys.empty?
     hash[key] = value
   else
-    unless hash.has_key? key
+    unless hash.key? key
       hash[key] = {}
     end
     add_translation(hash[key], keys, value)
@@ -23,20 +23,20 @@ def po2hash(f)
   trs = {}
   path = []
   msgstr = ''
-  f.each_line { |line|
-    line = line.strip
+  f.each_line do |line|
+    line.strip!
     if line[0..8] == 'msgctxt "'
       path = line[9..-2].split(':')
     elsif line[0..7] == 'msgstr "'
       msgstr = line[8..-2]
     end
-    
-    if !path.empty? and !msgstr.empty?
+
+    if !path.empty? && !msgstr.empty?
       add_translation(trs, path, msgstr)
       path = []
       msgstr = ''
     end
-  }
+  end
   trs
 end
 
@@ -45,6 +45,6 @@ pofile = File.open(filename, "r")
 
 langcode = File.basename(filename, '.po')
 
-tr = {langcode => po2hash(pofile)}
+tr = { langcode => po2hash(pofile) }
 
 print tr.to_yaml