← Back to team overview

openshot.code team mailing list archive

[Branch ~openshot.code/openshot/translations] Rev 835: Added additional code to generate the binary / compiled Qt translation file *.QM... used by OpenS...

 

------------------------------------------------------------
revno: 835
committer: Jonathan Thomas <Jonathan.Oomph@xxxxxxxxx>
branch nick: translations
timestamp: Tue 2014-03-11 16:08:44 -0500
message:
  Added additional code to generate the binary / compiled Qt translation file *.QM... used by OpenShot 2.0
modified:
  compile.py


--
lp:~openshot.code/openshot/translations
https://code.launchpad.net/~openshot.code/openshot/translations

Your team OpenShot Code is subscribed to branch lp:~openshot.code/openshot/translations.
To unsubscribe from this branch go to https://code.launchpad.net/~openshot.code/openshot/translations/+edit-subscription
=== modified file 'compile.py'
--- compile.py	2014-03-11 20:24:46 +0000
+++ compile.py	2014-03-11 21:08:44 +0000
@@ -27,7 +27,7 @@
 locale_folder = os.path.join(path, "openshot", "locale", "OpenShot")
 
 # Compile all PO files into MO files
-#subprocess.call('find -iname "*.po" -exec msgfmt {} -o {}.mo \;', shell=True)
+subprocess.call('find -iname "*.po" -exec msgfmt {} -o {}.mo \;', shell=True)
 #subprocess.call('find -iname "*.po" -exec po2ts {} -o {}.ts \;', shell=True)
 
 # Loop through each MO file
@@ -37,12 +37,26 @@
 		# Get the culture code from the file name
 		culture = str.split(file, ".")[0]
 		extension = str.split(file, ".")[-1]
-		
+
 		# Create directory
 		if not os.path.exists(os.path.join(locale_folder, culture)):
 			os.mkdir(os.path.join(locale_folder, culture))
 			os.mkdir(os.path.join(locale_folder, culture, "LC_MESSAGES"))
 		
+		# Convert PO to TS
+		if extension == "po":
+			# Create TS files (text)
+			subprocess.call('QT_SELECT=qt4 lconvert -if po -of ts "%s" -o "%s"' % (os.path.join(locale_folder, file), os.path.join(locale_folder, "%s.ts" % culture)), shell=True)
+			
+			# Create QM files (binary)
+			subprocess.call('QT_SELECT=qt4 lrelease "%s" -qm "%s"' % (os.path.join(locale_folder, "%s.ts" % culture), os.path.join(locale_folder, "%s.qm" % culture)), shell=True)
+			
+			# Copy TS and QM files to target folder
+			shutil.copy(os.path.join(locale_folder, "%s.ts" % culture), os.path.join(locale_folder, culture, "LC_MESSAGES", "OpenShot.ts"))
+			shutil.copy(os.path.join(locale_folder, "%s.qm" % culture), os.path.join(locale_folder, culture, "LC_MESSAGES", "OpenShot.qm"))
+			os.remove(os.path.join(locale_folder, "%s.ts" % culture))
+			os.remove(os.path.join(locale_folder, "%s.qm" % culture))
+		
 		# Copy file into the new folder
 		shutil.copy(os.path.join(locale_folder, file), os.path.join(locale_folder, culture, "LC_MESSAGES", "OpenShot.%s" % extension))