Commits

David Keegan committed 7a9a21e

*adding newline to Localize.py for diffs
*wrapping the arg to genstrings in quotes
*if there is no localized string file for the nib copy it from the 'from language'
*if the 'to language' string has been updated, update the nib

Comments (0)

Files changed (2)

 {
+    "French.lproj/Projects.strings": "7f3632a7668f39432d8dbf4ffb770f55", 
+    "French.lproj/Repo.strings": "e4707217ca4671be19a9f36a9fa68719", 
+    "English.lproj/Projects.xib": "7d4a244e8a3a6c42bc1d81a219cc2bf5", 
+    "French.lproj/MainMenu.strings": "804dc0fc6e0150907ef54c81b5d5f707", 
     "English.lproj/MainMenu.xib": "d481a98e1a5ae0a0780d7929cc856d24", 
-    "English.lproj/Projects.xib": "3d7c108b95ff7436ecfa6bcb6932edb9", 
-    "English.lproj/Repo.xib": "41dbe6fe1c9bc0170096036e114f5bfb"
-}
+    "German.lproj/Projects.strings": "8554bdd35568c0d598d3f5b322836067", 
+    "German.lproj/Repo.strings": "8bb4aeacd068f7b82e02806076095383", 
+    "English.lproj/Repo.xib": "41dbe6fe1c9bc0170096036e114f5bfb", 
+    "German.lproj/MainMenu.strings": "aa69dae50fd262857497ba56606ac537"
+}
 import os, sys, glob
 import subprocess
 from optparse import OptionParser
+from shutil import copyfile
 try:
     #python2.6+
     import json
 def genStrings(toLangs, globString, utf8=False):
     for eachToLang in toLangs:
         toLangLproj = langProjName(eachToLang)
-        runCommand('genstrings', '-o %s %s' % (toLangLproj, globString))
+        runCommand('genstrings', '-o %s "%s"' % (toLangLproj, globString))
         localizableStrings = os.path.join(toLangLproj, 'Localizable.strings')
         if utf8:
             fileToUtf8(localizableStrings)
         for eachToLang in toLangs:
             toLangLproj = langProjName(eachToLang)
             toNib =  os.path.join(toLangLproj, eachNib)
-            if not(os.path.isfile(toNib)) or not(fromNib in jsonData) or jsonData[fromNib] != fromNibMd5:
+            toStrings = nibToStringFileName(toNib)
+            #if there is no localized string file for the nib copy it from the 'from language'
+            if not(os.path.isfile(toStrings)):
+                fromStrings = nibToStringFileName(fromNib)
+                copyfile(fromStrings, toStrings)
+            toStringsMd5 = md5(toStrings)
+            if (not(os.path.isfile(toNib)) or not(fromNib in jsonData) or jsonData[fromNib] != fromNibMd5 or
+                not(toStrings in jsonData) or jsonData[toStrings] != toStringsMd5):
                 ibtoolsWriteNib(fromNib, toNib, utf8)
+                jsonData[toStrings] = toStringsMd5
                 
         jsonData[fromNib] = fromNibMd5
                 
     #update Localize.json
     localizeData = open(localizeJson, 'w')
     json.dump(jsonData, localizeData, indent=4)
+    #add newline for diffs
+    localizeData.write('\n')
     localizeData.close()
     
 if __name__ == '__main__':