]> git.openstreetmap.org Git - rails.git/blobdiff - script/locale/po2yaml
Standardise on double quoted strings
[rails.git] / script / locale / po2yaml
index ea78ce2c64a3e1135fe18840f2cea47e4d3c71af..69278ea6914f98241511df0830c4f1b077e95ea5 100755 (executable)
@@ -11,9 +11,8 @@ def add_translation(hash, keys, value)
   if keys.empty?
     hash[key] = value
   else
-    unless hash.key? key
-      hash[key] = {}
-    end
+    hash[key] ||= {}
+
     add_translation(hash[key], keys, value)
   end
   hash
@@ -22,20 +21,20 @@ end
 def po2hash(f)
   trs = {}
   path = []
-  msgstr = ''
+  msgstr = ""
   f.each_line do |line|
     line.strip!
     if line[0..8] == 'msgctxt "'
-      path = line[9..-2].split(':')
+      path = line[9..-2].split(":")
     elsif line[0..7] == 'msgstr "'
       msgstr = line[8..-2]
     end
 
-    if !path.empty? && !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
@@ -43,7 +42,7 @@ end
 filename = ARGV[0]
 pofile = File.open(filename, "r")
 
-langcode = File.basename(filename, '.po')
+langcode = File.basename(filename, ".po")
 
 tr = { langcode => po2hash(pofile) }