[latexila] Build Tools: use Intl.get_language_names()



commit 6cdb8dc3ed4bac39ce50f8009b576da183ca7890
Author: SÃbastien Wilmet <swilmet src gnome org>
Date:   Mon Jul 18 01:27:06 2011 +0200

    Build Tools: use Intl.get_language_names()
    
    Before, to know which build_tools-xx.xml to load, the string
    "build_tools-en.xml" was translated...
    
    Now the *.xml are stored in separated directories: C, fr, de, etc.

 .../{build_tools-en.xml => C/build_tools.xml}      |    0
 data/build_tools/CMakeLists.txt                    |   10 +++---
 data/build_tools/build_tools.pot                   |   28 ++++++++--------
 data/build_tools/fr.po                             |   34 ++++++++++---------
 data/build_tools/update_build_tools_pot.sh         |    6 ++-
 help/help.pot                                      |    2 +-
 help/update_help_pot.sh                            |    6 ++-
 src/build_tools.vala                               |   20 +++++------
 8 files changed, 55 insertions(+), 51 deletions(-)
---
diff --git a/data/build_tools/build_tools-en.xml b/data/build_tools/C/build_tools.xml
similarity index 100%
rename from data/build_tools/build_tools-en.xml
rename to data/build_tools/C/build_tools.xml
diff --git a/data/build_tools/CMakeLists.txt b/data/build_tools/CMakeLists.txt
index 7f0520d..0ef195e 100644
--- a/data/build_tools/CMakeLists.txt
+++ b/data/build_tools/CMakeLists.txt
@@ -1,7 +1,7 @@
 set (bt_dir ${DATA_DIR}/build_tools)
 set (tmp_bt_dir "${latexila_BINARY_DIR}/data/build_tools")
 
-install (FILES build_tools-en.xml DESTINATION ${DATA_DIR}/build_tools)
+install (DIRECTORY "C" DESTINATION ${bt_dir})
 
 set (all_new_bt)
 
@@ -12,18 +12,18 @@ foreach (po_file ${po_files})
 	get_filename_component (lang ${po_file} NAME_WE)
 
 	# Generate the new XML file
-	set (new_bt "${tmp_bt_dir}/build_tools-${lang}.xml")
 	set (mo_file "${tmp_bt_dir}/${lang}.mo")
+	set (new_bt "${tmp_bt_dir}/${lang}/build_tools.xml")
 	add_custom_command (
 		OUTPUT ${new_bt}
 		COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${mo_file} ${po_file}
 		COMMAND mkdir ${tmp_bt_dir}/${lang}
-		COMMAND itstool -m ${mo_file} -o ${tmp_bt_dir}/${lang}/ ${latexila_SOURCE_DIR}/data/build_tools/build_tools-en.xml
-		COMMAND mv ${tmp_bt_dir}/${lang}/build_tools-en.xml ${new_bt}
+		COMMAND itstool -m ${mo_file} -o ${tmp_bt_dir}/${lang}/ ${latexila_SOURCE_DIR}/data/build_tools/C/build_tools.xml
 		DEPENDS ${po_file}
 	)
 
-	install (FILES ${new_bt} DESTINATION ${DATA_DIR}/build_tools)
+	# Install the directory (which contains only the pages)
+	install (DIRECTORY ${tmp_bt_dir}/${lang} DESTINATION ${bt_dir})
 
 	set (all_new_bt ${all_new_bt} ${new_bt})
 endforeach ()
diff --git a/data/build_tools/build_tools.pot b/data/build_tools/build_tools.pot
index e30b262..28e77fb 100644
--- a/data/build_tools/build_tools.pot
+++ b/data/build_tools/build_tools.pot
@@ -1,7 +1,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2011-07-17 23:53+0200\n"
+"POT-Creation-Date: 2011-07-18 01:01+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL ADDRESS>\n"
 "Language-Team: LANGUAGE <LL li org>\n"
@@ -9,55 +9,55 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: build_tools-en.xml:37(tool/label)
+#: C/build_tools.xml:37(tool/label)
 msgid "View PDF"
 msgstr ""
 
-#: build_tools-en.xml:38(tool/description)
+#: C/build_tools.xml:38(tool/description)
 msgid "View the PDF file"
 msgstr ""
 
-#: build_tools-en.xml:43(tool/label)
+#: C/build_tools.xml:43(tool/label)
 msgid "View DVI"
 msgstr ""
 
-#: build_tools-en.xml:44(tool/description)
+#: C/build_tools.xml:44(tool/description)
 msgid "View the DVI file"
 msgstr ""
 
-#: build_tools-en.xml:49(tool/label)
+#: C/build_tools.xml:49(tool/label)
 msgid "View PS"
 msgstr ""
 
-#: build_tools-en.xml:50(tool/description)
+#: C/build_tools.xml:50(tool/description)
 msgid "View the PostScript file"
 msgstr ""
 
-#: build_tools-en.xml:84(tool/description)
+#: C/build_tools.xml:84(tool/description)
 msgid "Create a PDF file from LaTeX sources with the 'pdflatex' command"
 msgstr ""
 
-#: build_tools-en.xml:90(tool/description)
+#: C/build_tools.xml:90(tool/description)
 msgid "Create a DVI file from LaTeX sources with the 'latex' command"
 msgstr ""
 
-#: build_tools-en.xml:98(tool/description)
+#: C/build_tools.xml:98(tool/description)
 msgid "Run BibTeX (bibliography)"
 msgstr ""
 
-#: build_tools-en.xml:104(tool/description)
+#: C/build_tools.xml:104(tool/description)
 msgid "Run MakeIndex"
 msgstr ""
 
-#: build_tools-en.xml:112(tool/description)
+#: C/build_tools.xml:112(tool/description)
 msgid "Convert the DVI document to the PDF format"
 msgstr ""
 
-#: build_tools-en.xml:118(tool/description)
+#: C/build_tools.xml:118(tool/description)
 msgid "Convert the DVI document to the PostScript format"
 msgstr ""
 
-#: build_tools-en.xml:124(tool/description)
+#: C/build_tools.xml:124(tool/description)
 msgid "Convert the PostScript document to the PDF format"
 msgstr ""
 
diff --git a/data/build_tools/fr.po b/data/build_tools/fr.po
index a675a6e..6ff42d2 100644
--- a/data/build_tools/fr.po
+++ b/data/build_tools/fr.po
@@ -1,64 +1,66 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: LaTeXila 2.1\n"
-"POT-Creation-Date: 2011-07-17 23:53+0200\n"
+"POT-Creation-Date: 2011-07-18 01:01+0200\n"
 "PO-Revision-Date: 2011-07-17 23:59+0100\n"
 "Last-Translator: SÃbastien Wilmet <sebastien wilmet gmail com>\n"
 "Language-Team: \n"
+"Language: \n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "X-Poedit-Language: French\n"
 
-#: build_tools-en.xml:37(tool/label)
+#: C/build_tools.xml:37(tool/label)
 msgid "View PDF"
 msgstr "Voir PDF"
 
-#: build_tools-en.xml:38(tool/description)
+#: C/build_tools.xml:38(tool/description)
 msgid "View the PDF file"
 msgstr "Voir le fichier PDF"
 
-#: build_tools-en.xml:43(tool/label)
+#: C/build_tools.xml:43(tool/label)
 msgid "View DVI"
 msgstr "Voir DVI"
 
-#: build_tools-en.xml:44(tool/description)
+#: C/build_tools.xml:44(tool/description)
 msgid "View the DVI file"
 msgstr "Voir le fichier DVI"
 
-#: build_tools-en.xml:49(tool/label)
+#: C/build_tools.xml:49(tool/label)
 msgid "View PS"
 msgstr "Voir PS"
 
-#: build_tools-en.xml:50(tool/description)
+#: C/build_tools.xml:50(tool/description)
 msgid "View the PostScript file"
 msgstr "Voir le fichier PostScript"
 
-#: build_tools-en.xml:84(tool/description)
+#: C/build_tools.xml:84(tool/description)
 msgid "Create a PDF file from LaTeX sources with the 'pdflatex' command"
-msgstr "CrÃer un fichier PDF à partir des sources LaTeX grÃce à la commande ÂÂpdflatexÂÂ."
+msgstr ""
+"CrÃer un fichier PDF à partir des sources LaTeX grÃce à la commande "
+"ÂÂpdflatexÂÂ."
 
-#: build_tools-en.xml:90(tool/description)
+#: C/build_tools.xml:90(tool/description)
 msgid "Create a DVI file from LaTeX sources with the 'latex' command"
 msgstr ""
 
-#: build_tools-en.xml:98(tool/description)
+#: C/build_tools.xml:98(tool/description)
 msgid "Run BibTeX (bibliography)"
 msgstr ""
 
-#: build_tools-en.xml:104(tool/description)
+#: C/build_tools.xml:104(tool/description)
 msgid "Run MakeIndex"
 msgstr ""
 
-#: build_tools-en.xml:112(tool/description)
+#: C/build_tools.xml:112(tool/description)
 msgid "Convert the DVI document to the PDF format"
 msgstr ""
 
-#: build_tools-en.xml:118(tool/description)
+#: C/build_tools.xml:118(tool/description)
 msgid "Convert the DVI document to the PostScript format"
 msgstr ""
 
-#: build_tools-en.xml:124(tool/description)
+#: C/build_tools.xml:124(tool/description)
 msgid "Convert the PostScript document to the PDF format"
 msgstr ""
-
diff --git a/data/build_tools/update_build_tools_pot.sh b/data/build_tools/update_build_tools_pot.sh
index fe5f19a..1907589 100755
--- a/data/build_tools/update_build_tools_pot.sh
+++ b/data/build_tools/update_build_tools_pot.sh
@@ -1,7 +1,9 @@
 #!/bin/sh
 
-itstool -o build_tools.pot -i build_tools.its build_tools-en.xml
+pot_file="build_tools.pot"
+
+itstool -o $pot_file -i build_tools.its C/build_tools.xml
 
 for po_file in *.po; do
-	msgmerge --update --quiet --backup=none $po_file build_tools.pot
+	msgmerge --update --quiet --backup=none $po_file $pot_file
 done
diff --git a/help/help.pot b/help/help.pot
index 04c39ed..4d148bf 100644
--- a/help/help.pot
+++ b/help/help.pot
@@ -1,7 +1,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2011-07-17 18:49+0200\n"
+"POT-Creation-Date: 2011-07-18 01:01+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL ADDRESS>\n"
 "Language-Team: LANGUAGE <LL li org>\n"
diff --git a/help/update_help_pot.sh b/help/update_help_pot.sh
index c07c9d9..534b3d0 100755
--- a/help/update_help_pot.sh
+++ b/help/update_help_pot.sh
@@ -1,7 +1,9 @@
 #!/bin/sh
 
-itstool -o help.pot C/*.page
+pot_file="help.pot"
+
+itstool -o $pot_file C/*.page
 
 for po_file in *.po; do
-	msgmerge --update --quiet --backup=none $po_file help.pot
+	msgmerge --update --quiet --backup=none $po_file $pot_file
 done
diff --git a/src/build_tools.vala b/src/build_tools.vala
index c864c0f..e420db8 100644
--- a/src/build_tools.vala
+++ b/src/build_tools.vala
@@ -249,21 +249,19 @@ public class BuildTools
         build_tools = new LinkedList<BuildTool?> ();
 
         // First, try to load the user config file if it exists.
-        // Otherwise try to load the default config file translated.
-        // If the translated file doesn't exist or there is no translation
-        // available, try to load the default file.
+        // Otherwise try to load the default file (from most desirable to least desirable,
+        // depending of the current locale).
 
         File[] files = {};
         files += get_user_config_file ();
-        files += File.new_for_path (Path.build_filename (Config.DATA_DIR, "build_tools",
-            _("build_tools-en.xml"), null));
 
-        File default_file = File.new_for_path (Path.build_filename (Config.DATA_DIR,
-            "build_tools", "build_tools-en.xml", null));
-
-        // if no translation is available, there is only two files to test
-        if (! default_file.equal (files[1]))
-            files += default_file;
+        unowned string[] language_names = Intl.get_language_names ();
+        foreach (string language_name in language_names)
+        {
+            stdout.printf ("language_name: %s\n", language_name);
+            files += File.new_for_path (Path.build_filename (Config.DATA_DIR,
+                "build_tools", language_name, "build_tools.xml"));
+        }
 
         foreach (File file in files)
         {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]