Index: macosx/genstrings.sh =================================================================== --- macosx/genstrings.sh (revision 1312) +++ macosx/genstrings.sh (working copy) @@ -1,7 +1,49 @@ #! /bin/sh -rm -f genstrings.tmp +# Delete previous strings files +rm -f English.lproj/AdvancedView_ib.strings +rm -f English.lproj/MainMenu_ib.strings +rm -f English.lproj/OutputPanel_ib.strings +rm -f English.lproj/PictureSettings_ib.strings +#rm -f English.lproj/Preferences_ib.strings +rm -f English.lproj/Queue_ib.strings + +rm -f English.lproj/AdvancedView.strings +rm -f English.lproj/MainMenu.strings +rm -f English.lproj/OutputPanel.strings +rm -f English.lproj/PictureSettings.strings +#rm -f English.lproj/Preferences.strings +rm -f English.lproj/Queue.strings + +rm -f English.lproj/Localizable.strings +rm -f English.lproj/genstrings.tmp + +# Generate Localizable.strings cat *.mm | grep -v "^#define.*_(" | \ sed 's/_( \(@"[^"]*"\) )/NSLocalizedString( \1, nil )/g' > \ - genstrings.tmp -genstrings genstrings.tmp + English.lproj/genstrings.tmp +cd English.lproj +genstrings -a genstrings.tmp rm -f genstrings.tmp +cd .. + +# Generate IB Stringfiles +ibtool --generate-stringsfile English.lproj/AdvancedView_ib.strings English.lproj/AdvancedView.xib +ibtool --generate-stringsfile English.lproj/MainMenu_ib.strings English.lproj/MainMenu.xib +ibtool --generate-stringsfile English.lproj/OutputPanel_ib.strings English.lproj/OutputPanel.xib +ibtool --generate-stringsfile English.lproj/PictureSettings_ib.strings English.lproj/PictureSettings.xib +#ibtool --generate-stringsfile English.lproj/Preferences_ib.strings English.lproj/Preferences.xib +ibtool --generate-stringsfile English.lproj/Queue_ib.strings English.lproj/Queue.xib + +./gen_nib_strings.py English.lproj/AdvancedView_ib.strings English.lproj/AdvancedView.strings +./gen_nib_strings.py English.lproj/MainMenu_ib.strings English.lproj/MainMenu.strings +./gen_nib_strings.py English.lproj/OutputPanel_ib.strings English.lproj/OutputPanel.strings +./gen_nib_strings.py English.lproj/PictureSettings_ib.strings English.lproj/PictureSettings.strings +#./gen_nib_strings.py English.lproj/Preferences_ib.strings English.lproj/Preferences.strings +./gen_nib_strings.py English.lproj/Queue_ib.strings English.lproj/Queue.strings + +./strings_update.py German AdvancedView.strings +./strings_update.py German MainMenu.strings +./strings_update.py German OutputPanel.strings +./strings_update.py German PictureSettings.strings +#./strings_update.py German Preferences.strings +./strings_update.py German Queue.strings Index: macosx/German.lproj/MainMenu.strings =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: macosx/German.lproj/MainMenu.strings ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Index: macosx/German.lproj/PictureSettings.strings =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: macosx/German.lproj/PictureSettings.strings ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Index: macosx/German.lproj/AdvancedView.strings =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: macosx/German.lproj/AdvancedView.strings ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Index: macosx/German.lproj/OutputPanel.strings =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: macosx/German.lproj/OutputPanel.strings ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Index: macosx/German.lproj/Localizable.strings =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: macosx/German.lproj/Localizable.strings ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Index: macosx/German.lproj/Queue.strings =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: macosx/German.lproj/Queue.strings ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Index: macosx/translate_ib_strings.py =================================================================== --- macosx/translate_ib_strings.py (revision 0) +++ macosx/translate_ib_strings.py (revision 0) @@ -0,0 +1,93 @@ +#!/usr/bin/python +## translate a file generated with ibtool --generate-stringsfile : +## /* Class = "NSMenu"; title = "Menu"; ObjectID = "305"; */ +## "305.title" = "Menu"; +## with a strings file in the style of nibtool: +## /* NSMenu : (oid:305) */ +## "Menu" = "Menu"; + +import sys +import codecs +import re +import os.path + +def exit_usage(err): + sys.stderr.write('Usage: ' + sys.argv[0] + ' \n') + sys.stderr.write(err) + sys.exit() + +try: + if len(sys.argv) != 4: + exit_usage('') + + # read "nibtool-style" strings' translations + stringsFileName = sys.argv[2] + if not os.path.isfile(stringsFileName): + exit_usage('Strings file not found.\n') + + stringsFile = codecs.open(stringsFileName, "r", "utf-16") + text = stringsFile.read() + stringsFile.close() + lines = text.split(u'\n') + assign_preg = re.compile(r'^\"(.*)\" = \"(.*)\"\;') + + strings = {} + for line in lines: + m = assign_preg.match(line) + if m: + orig = m.expand(r'\1') + trad = m.expand(r'\2') + strings[orig] = trad + + # read and translate the ibtool strings file + srcFileName = sys.argv[1] + if not os.path.isfile(srcFileName): + exit_usage('Source file not found.\n') + + dstFileName = sys.argv[3] + dstFile = codecs.open(dstFileName, 'w', 'utf-16') + + srcFile = codecs.open(srcFileName, "r", "utf-16") + text = srcFile.read() + srcFile.close() + lines = text.split(u'\n') + comment_preg = re.compile( + r'^\/\*\s*' + r'Class\s*\=\s*\"(.*)\";\s*' # Class = "xxx"; + r'(\S+)\s*\=\s*\"(.*)\";\s*' # yyy = "xxx"; + r'ObjectID\s*\=\s*\"(.*)\";') # ObjectID = "xxx"; + assign_preg = re.compile(r'^\"([^\.]+)\.(.*)\" = \"(.*)\"\;') + + class_name = '' + data_type = '' + orig_text = '' + object_id = '' + + for line in lines: + m = assign_preg.match(line) + if m: + object_id_2 = m.expand(r'\1') + data_type_2 = m.expand(r'\2') + if object_id_2 != object_id or data_type_2 != data_type: + dstFile.close() + exit_usage('Malformed source file, object_id: ' + + object_id + ', data_type: ' + data_type + '\n') + + if len(orig_text)>0 and orig_text in strings: + dstFile.write(u'"' + object_id + u'.' + data_type + u'" = "' + strings[orig_text] + u'";\n') + else: + dstFile.write(line + u'\n') + else: + c = comment_preg.match(line) + if c: + class_name = c.expand(r'\1') + data_type = c.expand(r'\2') + orig_text = c.expand(r'\3') + object_id = c.expand(r'\4') + dstFile.write(line + u'\n') + + dstFile.close() + +except IOError: + print 'I/O error' + sys.exit(0) \ No newline at end of file Property changes on: macosx/translate_ib_strings.py ___________________________________________________________________ Name: svn:executable + * Index: macosx/HandBrake.xcodeproj/project.pbxproj =================================================================== --- macosx/HandBrake.xcodeproj/project.pbxproj (revision 1312) +++ macosx/HandBrake.xcodeproj/project.pbxproj (working copy) @@ -248,6 +248,11 @@ 4DEB2024052B055F00C39CA9 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = ""; }; 4DF3C8CB052889CD00A80101 /* Controller.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Controller.h; sourceTree = ""; }; 4DF3C8CC052889CD00A80101 /* Controller.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = Controller.mm; sourceTree = ""; }; + 5039E8C40D6E15C0006DD5DB /* German */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = German; path = German.lproj/AdvancedView.xib; sourceTree = ""; }; + 5039E8C50D6E15C0006DD5DB /* German */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = German; path = German.lproj/MainMenu.xib; sourceTree = ""; }; + 5039E8C60D6E15C0006DD5DB /* German */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = German; path = German.lproj/OutputPanel.xib; sourceTree = ""; }; + 5039E8C70D6E15C0006DD5DB /* German */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = German; path = German.lproj/PictureSettings.xib; sourceTree = ""; }; + 5039E8C80D6E15C0006DD5DB /* German */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = German; path = German.lproj/Queue.xib; sourceTree = ""; }; 526FBC760B4CA8F40064E04C /* test.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.c; fileEncoding = 30; name = test.c; path = ../test/test.c; sourceTree = SOURCE_ROOT; }; 526FBC9B0B4CAB100064E04C /* common.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = common.c; path = ../libhb/common.c; sourceTree = SOURCE_ROOT; }; 526FBC9D0B4CAB100064E04C /* deca52.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = deca52.c; path = ../libhb/deca52.c; sourceTree = SOURCE_ROOT; }; @@ -650,11 +655,13 @@ isa = PBXNativeTarget; buildConfigurationList = 4D4E7BC0087804870051572B /* Build configuration list for PBXNativeTarget "HandBrake" */; buildPhases = ( + 5039E8AB0D6E1535006DD5DB /* ShellScript */, 4DD93F8E082036E8008E1322 /* Headers */, 4DD93F95082036E8008E1322 /* Resources */, 4DD93F99082036E8008E1322 /* Sources */, 4DD93FA1082036E8008E1322 /* Frameworks */, A29E05840BE12861000533F5 /* CopyFiles */, + 5039E8D00D6E166C006DD5DB /* ShellScript */, ); buildRules = ( ); @@ -743,6 +750,35 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 5039E8AB0D6E1535006DD5DB /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "# Create temporary IB Stringfiles\n./translate_ib_strings.py English.lproj/AdvancedView_ib.strings German.lproj/AdvancedView.strings German.lproj/AdvancedView_ib.strings\n./translate_ib_strings.py English.lproj/MainMenu_ib.strings German.lproj/MainMenu.strings German.lproj/MainMenu_ib.strings\n./translate_ib_strings.py English.lproj/OutputPanel_ib.strings German.lproj/OutputPanel.strings German.lproj/OutputPanel_ib.strings\n./translate_ib_strings.py English.lproj/PictureSettings_ib.strings German.lproj/PictureSettings.strings German.lproj/PictureSettings_ib.strings\n#./translate_ib_strings.py English.lproj/Preferences_ib.strings German.lproj/Preferences.strings German.lproj/Preferences_ib.strings\n./translate_ib_strings.py English.lproj/Queue_ib.strings German.lproj/Queue.strings German.lproj/Queue_ib.strings\n\n# Create NIBs\nibtool --strings-file German.lproj/AdvancedView_ib.strings English.lproj/AdvancedView.xib --write German.lproj/AdvancedView.xib\nibtool --strings-file German.lproj/MainMenu_ib.strings English.lproj/MainMenu.xib --write German.lproj/MainMenu.xib\nibtool --strings-file German.lproj/OutputPanel_ib.strings English.lproj/OutputPanel.xib --write German.lproj/OutputPanel.xib\nibtool --strings-file German.lproj/PictureSettings_ib.strings English.lproj/PictureSettings.xib --write German.lproj/PictureSettings.xib\n#ibtool --strings-file German.lproj/Preferences_ib.strings English.lproj/Preferences.xib --write German.lproj/Preferences.xib\nibtool --strings-file German.lproj/Queue_ib.strings English.lproj/Queue.xib --write German.lproj/Queue.xib\n\n# Delete temporary IB Stringfiles\nrm -f German.lproj/AdvancedView_ib.strings\nrm -f German.lproj/MainMenu_ib.strings\nrm -f German.lproj/OutputPanel_ib.strings\nrm -f German.lproj/PictureSettings_ib.strings\n#rm -f German.lproj/Preferences_ib.strings\nrm -f German.lproj/Queue_ib.strings"; + }; + 5039E8D00D6E166C006DD5DB /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "# Removes translated XIBs\nrm -f German.lproj/AdvancedView.xib\nrm -f German.lproj/MainMenu.xib\nrm -f German.lproj/OutputPanel.xib\nrm -f German.lproj/PictureSettings.xib\n#rm -f German.lproj/Preferences.xib\nrm -f German.lproj/Queue.xib"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 0D096DFC0B707D1200A845D4 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -889,6 +925,7 @@ isa = PBXVariantGroup; children = ( E39AA4DB0D32DC0B0007A415 /* English */, + 5039E8C50D6E15C0006DD5DB /* German */, ); name = MainMenu.xib; sourceTree = ""; @@ -897,6 +934,7 @@ isa = PBXVariantGroup; children = ( E39AA4DD0D32DC0B0007A415 /* English */, + 5039E8C80D6E15C0006DD5DB /* German */, ); name = Queue.xib; sourceTree = ""; @@ -913,6 +951,7 @@ isa = PBXVariantGroup; children = ( E39AA4E10D32DC0B0007A415 /* English */, + 5039E8C70D6E15C0006DD5DB /* German */, ); name = PictureSettings.xib; sourceTree = ""; @@ -921,6 +960,7 @@ isa = PBXVariantGroup; children = ( E39AA4E30D32DC0B0007A415 /* English */, + 5039E8C40D6E15C0006DD5DB /* German */, ); name = AdvancedView.xib; sourceTree = ""; @@ -929,6 +969,7 @@ isa = PBXVariantGroup; children = ( E39AA4E50D32DC0B0007A415 /* English */, + 5039E8C60D6E15C0006DD5DB /* German */, ); name = OutputPanel.xib; sourceTree = ""; Index: macosx/strings_update.py =================================================================== --- macosx/strings_update.py (revision 0) +++ macosx/strings_update.py (revision 0) @@ -0,0 +1,76 @@ +#!/usr/bin/python + +import sys +import codecs +import re +import os.path + +def exit_usage(err): + sys.stderr.write('Usage: ' + sys.argv[0] + ' \n') + sys.stderr.write(err) + sys.exit() + +try: + if len(sys.argv) != 3: + exit_usage('') + + tgtLang = sys.argv[1] + if not os.path.isdir(tgtLang + '.lproj'): + exit_usage('Target language\'s folder not found.\n') + + filename = sys.argv[2] + tgtFileName = tgtLang + '.lproj/' + filename + if not os.path.isfile(tgtFileName): + exit_usage('Target file not found.\n') + + srcFileName = 'English.lproj/' + filename + if not os.path.isfile(srcFileName): + exit_usage('English source file not found\n') + + tgtFile = codecs.open(tgtFileName, "r", "utf-16") + text = tgtFile.read() + tgtFile.close() + lines = text.split(u'\n') + assign_preg = re.compile(r'^\"(.*)\" = \"(.*)\"\;') + + strings = {} + for line in lines: + m = assign_preg.match(line) + if m: + orig = m.expand(r'\1') + trad = m.expand(r'\2') + strings[orig] = trad + + srcFile = codecs.open(srcFileName, "r", "utf-16") + text = srcFile.read() + srcFile.close() + lines = text.split(u'\n') + + txtOut = u'' + + for line in lines: + m = assign_preg.match(line) + if m: + orig = m.expand(r'\1') + if orig in strings: + txtOut += u'"' + orig + u'" = "' + strings[orig] + u'";\n' + del strings[orig] + else: + txtOut += line + u'\n' + else: + txtOut += line + u'\n' + + if len(strings): + txtOut += u'/* The following strings were not found ' + txtOut += u'in the English file: delete them if you don\'t ' + txtOut += u'need them anymore */\n\n' + for k in strings.keys(): + txtOut += u'"' + k + u'" = "' + strings[k] + u'";\n' + + tgtFile = codecs.open(tgtFileName + '.new', 'w', 'utf-16') + tgtFile.write(txtOut) + tgtFile.close() + +except IOError: + print 'I/O error' + sys.exit(0) \ No newline at end of file Property changes on: macosx/strings_update.py ___________________________________________________________________ Name: svn:executable + * Index: macosx/gen_nib_strings.py =================================================================== --- macosx/gen_nib_strings.py (revision 0) +++ macosx/gen_nib_strings.py (revision 0) @@ -0,0 +1,82 @@ +#!/usr/bin/python +## generate a strings file compatible with nibtool from a strings file generated +## with ibtool --generate-stringsfile + +import sys +import codecs +import re +import os.path + +def exit_usage(err): + sys.stderr.write('Usage: ' + sys.argv[0] + ' \n') + sys.stderr.write(err) + sys.exit() + +def append_nib_string(dstFile, class_name, data_type, object_id, orig_text, translated_text): + # dstFile format: + # /* NSMenu : (oid:305) */ + # "Menu" = "Menu"; + if len(orig_text) > 0: + text = u"/* " + class_name + u" : <" + data_type + u":" + orig_text + u"> (oid:" + object_id + u") */\n" +\ + u"\"" + orig_text + u"\" = \"" + translated_text + u"\";\n\n" + dstFile.write(text) + +try: + if len(sys.argv) != 3: + exit_usage('') + + srcFileName = sys.argv[1] + if not os.path.isfile(srcFileName): + exit_usage('Source file not found.\n') + + srcFile = codecs.open(srcFileName, "r", "utf-16") + text = srcFile.read() + srcFile.close() + lines = text.split(u'\n') + + dstFileName = sys.argv[2] + dstFile = codecs.open(dstFileName, 'w', 'utf-16') + + # lines in srcFile should follow the format: + # /* Class = "NSMenu"; title = "Menu"; ObjectID = "305"; */ + # "305.title" = "Menu"; + comment_preg = re.compile( + r'^\/\*\s*' + r'Class\s*\=\s*\"(.*)\";\s*' # Class = "xxx"; + r'(\S+)\s*\=\s*\"(.*)\";\s*' # yyy = "xxx"; + r'ObjectID\s*\=\s*\"(.*)\";') # ObjectID = "xxx"; + assign_preg = re.compile(r'^\"([^\.]+)\.(.*)\" = \"(.*)\"\;') + + class_name = '' + data_type = '' + orig_text = '' + object_id = '' + strings = {} + + for line in lines: + c = comment_preg.match(line) + if c: + class_name = c.expand(r'\1') + data_type = c.expand(r'\2') + orig_text = c.expand(r'\3') + object_id = c.expand(r'\4') + else: + m = assign_preg.match(line) + if m: + object_id_2 = m.expand(r'\1') + data_type_2 = m.expand(r'\2') + if object_id_2 != object_id or data_type_2 != data_type: + dstFile.close() + exit_usage('Malformed source file, object_id: ' + + object_id + ', data_type: ' + data_type + '\n') + + if not orig_text in strings: + translated_text = m.expand(r'\3') + append_nib_string(dstFile, class_name, data_type, object_id, orig_text, translated_text) + strings[orig_text] = 1 + + dstFile.close() + +except IOError: + print 'I/O error' + sys.exit(0) \ No newline at end of file Property changes on: macosx/gen_nib_strings.py ___________________________________________________________________ Name: svn:executable + *