Commits

David Keegan committed bf51f84

*adding --genstrings flag to Localize.py so that strings files from genstrings can be converted to utf-8
*converting the remaining strings files to utf-8
*changing script tasks to ./Localize.py
*adding *.pyc to the ignore list

Comments (0)

Files changed (8)

 (*)
 *.pbxuser
 *.perspectivev3
+*.pyc
 *.mode1v3
 *.mode2v3
 *.mpkg

English.lproj/InfoPlist.strings

File contents unchanged.

English.lproj/Localizable.strings

File contents unchanged.

French.lproj/InfoPlist.strings

File contents unchanged.

German.lproj/InfoPlist.strings

File contents unchanged.

German.lproj/Localizable.strings

File contents unchanged.
     http://bitbucket.org/snej/murky
 
 Usage: 
-    Localize.py [options]
-
-    Options:
-      -h, --help            show this help message and exit
-      -f LANG, --from=LANG  the language to localize from
-      -t LANGS, --to=LANGS  an array of languages to localize to, separated by '|'
-      -n NIBS, --nibs=NIBS  an array of nibs to localize, separated by '|', .xib
-                            can be left off
-      -u, --utf8            if this flag is present the .strings files will be re-
-                            encoded as utf-8
-      -i, --ignore          if this flag is present the md5 checksums will be
-                            ignored
+    Localize.py -help
+    
+    Localize nibs:
+        Localize.py --from English --to "French|German" --nibs "MainMenu|Projects|Repo"
+        
+    Generate Strings:
+        Localize.py --to English --genstrings "./**/*.[hm]"
+        
+    Use the '--utf8' flag to convert the strings files from utf-16 to utf-8.
                             
 The MIT License
 
     
     print '  ', toFile, 'updated'
  
+def genStrings(toLangs, globString, utf8=False):
+    for eachToLang in toLangs:
+        toLangLproj = eachToLang.strip()+'.lproj'
+        runCommand('genstrings', '-o %s %s' % (toLangLproj, globString))
+        localizableStrings = os.path.join(toLangLproj, 'Localizable.strings')
+        if utf8:
+            fileToUtf8(localizableStrings)
+        
+        print '  ', localizableStrings, 'updated'
+ 
 def localizeNibs(fromLang, toLangs, nibs, utf8=False, ignore=False):
     '''Localize nibs from one language to others'''
     
     else:
         jsonData = {}
         
-    fromLangLproj = fromLang+'.lproj'
+    fromLangLproj = fromLang.strip()+'.lproj'
     for eachToLang in toLangs:
         toLangLproj = eachToLang.strip()+'.lproj'
         for eachNib in nibs:
     opts.add_option('--nibs', '-n', dest='nibs', help="an array of nibs to localize, separated by '|', .xib can be left off", metavar='NIBS')
     opts.add_option('--utf8', '-u', dest='utf8', help='if this flag is present the .strings files will be re-encoded as utf-8', action="store_true", default=False)
     opts.add_option('--ignore', '-i', dest='ignore', help='if this flag is present the md5 checksums will be ignored', action="store_true", default=False)
+    opts.add_option('--genstrings', '-g', dest='genstrings', help='if this argument is present the genstrings command line will be called', metavar='GLOB', default=None)
     options, arguments = opts.parse_args()
     
-    localizeNibs(options.fromLang, options.toLangs.split('|'), options.nibs.split('|'), options.utf8, options.ignore)
-    print 'Nibs updated in %.2f seconds' % (time.time()-startTime)
+    if options.genstrings != None:  
+        genStrings(options.toLangs.split('|'), options.genstrings, options.utf8)
+        print 'Strings updated in %.2f seconds' % (time.time()-startTime)
+    else:      
+        localizeNibs(options.fromLang, options.toLangs.split('|'), options.nibs.split('|'), options.utf8, options.ignore)
+        print 'Nibs updated in %.2f seconds' % (time.time()-startTime)
+    

Murky.xcodeproj/project.pbxproj

 			);
 			runOnlyForDeploymentPostprocessing = 0;
 			shellPath = /bin/zsh;
-			shellScript = "# -q silences duplicate comments with same key warning\ngenstrings -o ${SRCROOT}/English.lproj ${SRCROOT}/**/*.[hm]\n";
+			shellScript = "# -q silences duplicate comments with same key warning\n./Localize.py --to English --genstrings \"./**/*.[hm]\" --utf8";
 			showEnvVarsInLog = 0;
 		};
 		37915E6310E900A00057D687 /* Translate */ = {
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 			shellPath = /bin/sh;
-			shellScript = "# Localize nibs\n\"${SRCROOT}/Localize.py\" --from English --to \"French|German\" --nibs \"MainMenu|Projects|Repo\" --utf8\n";
+			shellScript = "# Localize nibs\n./Localize.py --from English --to \"French|German\" --nibs \"MainMenu|Projects|Repo\" --utf8\n";
 		};
 /* End PBXShellScriptBuildPhase section */