From d706c52bf29e97b61ab843b295f1b53e50879a01 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Sun, 20 Feb 2011 18:39:58 +0100
Subject: Auto-generate NSIS translation script.


diff --git a/Swift/Packaging/nsis/translations-install.nsh b/Swift/Packaging/nsis/translations-install.nsh
deleted file mode 100644
index 7e6a085..0000000
--- a/Swift/Packaging/nsis/translations-install.nsh
+++ /dev/null
@@ -1 +0,0 @@
-File "..\..\QtUI\Swift\translations\swift_nl.qm"
diff --git a/Swift/Packaging/nsis/translations-uninstall.nsh b/Swift/Packaging/nsis/translations-uninstall.nsh
deleted file mode 100644
index bfb0388..0000000
--- a/Swift/Packaging/nsis/translations-uninstall.nsh
+++ /dev/null
@@ -1 +0,0 @@
-delete $INSTDIR\translations\swift_nl.qm
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index 2255808..093b708 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -160,21 +160,47 @@ commonResources = {
 	"": ["../resources/sounds"]
 }
 
+################################################################################
 # Translation
-translation_sources = [env.File("../Translations/swift.ts").abspath]
+################################################################################
+
+# Collect available languages
+translation_languages = []
 for file in os.listdir(Dir("../Translations").abspath) :
 	if file.startswith("swift_") and file.endswith(".ts") :
-		lang = file[6:-3]
-		translation_resource = "../resources/translations/swift_" + lang + ".qm"
-		translation_source = "../Translations/swift_" + lang + ".ts"
-		translation_sources.append(env.File(translation_source).abspath)
-		myenv.Qm(translation_resource, translation_source)
-		commonResources["translations"] = commonResources.get("translations", []) + [translation_resource]
+		translation_languages.append(file[6:-3])
+
+# Generate translation modules
+translation_sources = [env.File("../Translations/swift.ts").abspath]
+translation_modules = []
+for lang in translation_languages :
+	lang = file[6:-3]
+	translation_resource = "../resources/translations/swift_" + lang + ".qm"
+	translation_source = "../Translations/swift_" + lang + ".ts"
+	translation_sources.append(env.File(translation_source).abspath)
+	translation_modules.append(env.File(translation_resource).abspath)
+	myenv.Qm(translation_resource, translation_source)
+	commonResources["translations"] = commonResources.get("translations", []) + [translation_resource]
+
+# LUpdate translation (if requested)
 if ARGUMENTS.get("update_translations", False) :
 	myenv.Precious(translation_sources)
 	t = myenv.Command(translation_sources, [], [myenv.Action("$QT4_LUPDATE -I " + env.Dir("#").abspath + " -silent -no-ui-lines -codecfortr utf-8  -recursive Swift -ts " + " ".join(translation_sources), cmdstr = "$QT4_LUPDATECOMSTR")])
 	myenv.AlwaysBuild(t)
 
+# NSIS installation script
+if env["PLATFORM"] == "win32" :
+	nsis_translation_install_script = ""
+	nsis_translation_uninstall_script = ""
+	for lang in translation_languages :
+		nsis_translation_install_script += "File \"..\\..\\QtUI\\Swift\\translations\\swift_" + lang + ".qm\""
+		nsis_translation_uninstall_script += "delete $INSTDIR\\translations\\swift_" + lang + ".qm"
+	myenv.WriteVal("../Packaging/nsis/translations-install.nsh", myenv.Value(nsis_translation_install_script))
+	myenv.WriteVal("../Packaging/nsis/translations-uninstall.nsh", myenv.Value(nsis_translation_uninstall_script))
+	
+
+################################################################################
+
 if env["PLATFORM"] == "darwin" :
   frameworks = []
   if env["HAVE_SPARKLE"] :
-- 
cgit v0.10.2-6-g49f6