switch build process from Qt to gettext translations
authorDaniel Albers <daniel@lbers.com>
Wed, 21 Oct 2009 20:43:53 +0000 (22:43 +0200)
committerDaniel Albers <daniel@lbers.com>
Sun, 25 Oct 2009 21:23:10 +0000 (22:23 +0100)
cmake/modules/FindQt4.cmake
cmake/modules/QuasselMacros.cmake
i18n/CMakeLists.txt
i18n/README.Translations
i18n/update.sh [new file with mode: 0755]

index 64a5ce4..6a0877a 100644 (file)
 #  QT_DBUSCPP2XML_EXECUTABLE  Where to find the qdbuscpp2xml tool.
 #  QT_DBUSXML2CPP_EXECUTABLE  Where to find the qdbusxml2cpp tool.
 #  QT_LUPDATE_EXECUTABLE      Where to find the lupdate tool.
-#  QT_LRELEASE_EXECUTABLE     Where to find the lrelease tool.
+#  QT_LCONVERT_EXECUTABLE     Where to find the lconvert tool.
 #  
 #  QT_DOC_DIR                 Path to "doc" of Qt4
 #  QT_MKSPECS_DIR             Path to "mkspecs" of Qt4
@@ -1095,8 +1095,8 @@ IF (QT4_QMAKE_FOUND)
     NO_DEFAULT_PATH
     )
 
-  FIND_PROGRAM(QT_LRELEASE_EXECUTABLE
-    NAMES lrelease-qt4 lrelease
+  FIND_PROGRAM(QT_LCONVERT_EXECUTABLE
+    NAMES lconvert
     PATHS ${QT_BINARY_DIR}
     NO_DEFAULT_PATH
     )
@@ -1113,7 +1113,7 @@ IF (QT4_QMAKE_FOUND)
 
   MARK_AS_ADVANCED( QT_UIC_EXECUTABLE QT_UIC3_EXECUTABLE QT_MOC_EXECUTABLE
     QT_RCC_EXECUTABLE QT_DBUSXML2CPP_EXECUTABLE QT_DBUSCPP2XML_EXECUTABLE
-    QT_LUPDATE_EXECUTABLE QT_LRELEASE_EXECUTABLE)
+    QT_LUPDATE_EXECUTABLE QT_LCONVERT_EXECUTABLE)
 
   ######################################
   #
index 9d8c1cd..5657c8a 100644 (file)
@@ -17,15 +17,15 @@ macro(setup_qt4_variables)
   set(QUASSEL_QT_LIBRARIES ${QUASSEL_QT_LIBRARIES} ${QT_LIBRARIES})
 endmacro(setup_qt4_variables)
 
-# This generates a .qm from a .ts file
+# This generates a .qm from a .po file
 macro(generate_qm outvar basename)
-  set(input ${CMAKE_SOURCE_DIR}/i18n/${basename}.ts)
+  set(input ${CMAKE_SOURCE_DIR}/i18n/${basename}.po)
   set(output ${CMAKE_BINARY_DIR}/i18n/${basename}.qm)
   add_custom_command(OUTPUT ${output}
-          COMMAND ${QT_LRELEASE_EXECUTABLE}
-          ARGS ${input}
-               -qm ${output}
-               -silent -compress
-          DEPENDS ${basename}.ts)
+          COMMAND ${QT_LCONVERT_EXECUTABLE}
+          ARGS -i ${input}
+               -of qm
+               -o ${output}
+          DEPENDS ${basename}.po)
   set(${outvar} ${output})
 endmacro(generate_qm outvar basename)
index 8d59abf..f3d3ac2 100644 (file)
@@ -1,15 +1,15 @@
 # Generate and add translations
 # The LINGUAS variable can be used to limit that set
 
-if(QT_LRELEASE_EXECUTABLE)
-  # We always include quassel.ts
+if(QT_LCONVERT_EXECUTABLE)
+  # We always include quassel.po
   generate_qm(QM quassel)
   set(qm_files ${QM})
 
   # Find more languages
-  file(GLOB avail_tsfiles quassel_*.ts qt_*.ts)
-  foreach(TS_FILE ${avail_tsfiles})
-    get_filename_component(basename ${TS_FILE} NAME_WE)
+  file(GLOB avail_pofiles quassel_*.po qt_*.po)
+  foreach(PO_FILE ${avail_pofiles})
+    get_filename_component(basename ${PO_FILE} NAME_WE)
     string(REGEX REPLACE "q[^_]+_([a-zA-Z]+)(_.+)?$" "\\1" lang ${basename})
     # test if we want this
     set(flg 1)
@@ -21,14 +21,14 @@ if(QT_LRELEASE_EXECUTABLE)
       list(APPEND qm_files ${QM})
       list(APPEND gen_linguas ${lang})
     endif(flg)
-  endforeach(TS_FILE ${avail_tsfiles})
+  endforeach(PO_FILE ${avail_pofiles})
   if(gen_linguas)
     list(REMOVE_DUPLICATES gen_linguas)
   endif(gen_linguas)
   message(STATUS "Including languages: ${gen_linguas}")
-else(QT_LRELEASE_EXECUTABLE)
-  message(STATUS "WARNING: lrelease not found, you won't have translations!")
-endif(QT_LRELEASE_EXECUTABLE)
+else(QT_LCONVERT_EXECUTABLE)
+  message(STATUS "WARNING: lconvert not found, you won't have translations!")
+endif(QT_LCONVERT_EXECUTABLE)
 
 # For a static build, we need to include Qt translations if available
 if(STATIC AND QT_TRANSLATIONS_DIR)
index 1a65654..4042962 100644 (file)
@@ -1,28 +1,25 @@
 In order to create or update a translatable file, run the following command
 in the directory i18n/:
 
-lupdate ../src -ts quassel_xx.ts
+./update.sh xx
 
 where xx is the two-letter language code according to ISO 639 (which,
 if needed, may be suffixed by a country code according to ISO 3166).
 Quassel will automatically load these translation files based on the
-system locale. Examples for valid file names:
+system locale. Examples for valid codes: de, en_US
 
-quassel_de.ts
-quassel_en_US.ts
+You can open translation files with poedit for example and add/edit translated strings.
 
-You can open these XML files with the Qt Linguist and add/edit translated strings.
+The *.po files can and should be kept in sync with the source code by running
+update.sh regularly (existing translations won't be removed).
 
-The *.ts files can and should be kept in sync with the source code by running
-lupdate regularly (existing translations won't be removed).
-
-Qt itself does not use the *.ts files, but a compact binary format (*.qm). 
+Qt itself does not use the *.po files, but a compact binary format (*.qm). 
 These files will automatically be generated at build time. By default, all
 languages will be built. To select languages, add -DLINGUAS="<languages>"
 to your cmake call, where <languages> is a space-separated list of language
 codes as explained above.
 
-NOTE: You'll need lrelease installed with your Qt in order to generate
+NOTE: You'll need lconvert installed with your Qt in order to generate
       translation files. Some distributions don't package that tool;
       in that case you won't get translations.
 
diff --git a/i18n/update.sh b/i18n/update.sh
new file mode 100755 (executable)
index 0000000..adfb3ee
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+if [ ! $# -eq 1 ]; then
+  exec >&2
+  echo "Usage: $0 <language>"
+  echo "  language: two-letter language code + country code if applicable (de, en_GB)"
+  exit 1
+fi
+
+CONV=lconvert
+BASE=quassel_${1}
+PO=${BASE}.po
+TS=${BASE}.ts
+
+$CONV -i ${PO} -o ${TS}   &&
+  lupdate ../src -ts ${TS} &&
+  $CONV -i ${TS} -o ${PO}