]> git.openstreetmap.org Git - rails.git/blobdiff - script/locale/po2yaml
Fix rubocop style issues
[rails.git] / script / locale / po2yaml
index 3e05363e7e040eafbc0eb975c1bd3245c45b9342..a4b8ac8b7939366da132f70747c6abc9df021824 100755 (executable)
@@ -11,9 +11,8 @@ def add_translation(hash, keys, value)
   if keys.empty?
     hash[key] = value
   else
-    unless hash.has_key? key
-      hash[key] = {}
-    end
+    hash[key] ||= {}
+
     add_translation(hash[key], keys, value)
   end
   hash
@@ -23,20 +22,20 @@ def po2hash(f)
   trs = {}
   path = []
   msgstr = ''
-  f.each_line { |line|
+  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?
-      add_translation(trs, path, msgstr)
-      path = []
-      msgstr = ''
-    end
-  }
+
+    next if path.empty? || msgstr.empty?
+
+    add_translation(trs, path, msgstr)
+    path = []
+    msgstr = ''
+  end
   trs
 end
 
@@ -45,6 +44,6 @@ pofile = File.open(filename, "r")
 
 langcode = File.basename(filename, '.po')
 
-tr = {langcode => po2hash(pofile)}
+tr = { langcode => po2hash(pofile) }
 
 print tr.to_yaml