Permalink
Browse files

Setup a very simple i18n system. Add italian translation.

The i18n.sh script takes care of extracting messages and merging.
xgettex runs in python mode, since ruby is not supported. This does not
seem to create any problems.
  • Loading branch information...
1 parent 04f7487 commit e6b44877fb12eff121c9824b67f1a20f379fa782 @pcapriotti committed Feb 13, 2010
Showing with 450 additions and 1 deletion.
  1. +1 −1 CMakeLists.txt
  2. +41 −0 i18n.sh
  3. +188 −0 kaya.pot
  4. +33 −0 translations/CMakeLists.txt
  5. +187 −0 translations/it.po
View
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 2.6)
find_package(KDE4 REQUIRED)
include(KDE4Defaults)
add_subdirectory(lib)
-
+add_subdirectory(translations)
configure_file(main.rb main.rb)
View
41 i18n.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+PROJECT="kaya" # project name
+BUGADDR="http://github.com/pcapriotti/kaya/issues"
+WDIR=`pwd` # working dir
+BASEDIR=${WDIR} # root of translatable sources
+
+echo "Preparing rc files"
+cd ${BASEDIR}
+# we use simple sorting to make sure the lines do not jump around too much from system to system
+find . -name '*.rc' -o -name '*.ui' -o -name '*.kcfg' | sort > ${WDIR}/rcfiles.list
+xargs --arg-file=${WDIR}/rcfiles.list extractrc > ${WDIR}/rc.cpp
+cd ${WDIR}
+echo "Done preparing rc files"
+
+echo "Extracting messages"
+cd ${BASEDIR}
+# see above on sorting
+find . -name '*.rb' | sort > ${WDIR}/infiles.list
+echo "rc.cpp" >> ${WDIR}/infiles.list
+cd ${WDIR}
+xgettext --from-code=UTF-8 -L python -kde -ci18n -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 -ktr2i18n:1 \
+-kI18N_NOOP:1 -kI18N_NOOP2:1c,2 -kaliasLocale -kki18n:1 -kki18nc:1c,2 -kki18np:1,2 -kki18ncp:1c,2,3 \
+--msgid-bugs-address="${BUGADDR}" \
+--files-from=infiles.list -D ${BASEDIR} -D ${WDIR} -o ${PROJECT}.pot || { echo "error while calling xgettext. aborting."; exit 1; }
+echo "Done extracting messages"
+
+echo "Merging translations"
+catalogs=`find . -name '*.po'`
+for cat in $catalogs; do
+echo $cat
+msgmerge -o $cat.new $cat ${PROJECT}.pot
+mv $cat.new $cat
+done
+echo "Done merging translations"
+
+
+echo "Cleaning up"
+cd ${WDIR}
+rm rcfiles.list
+rm infiles.list
+rm rc.cpp
View
188 kaya.pot
@@ -0,0 +1,188 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: http://github.com/pcapriotti/kaya/issues\n"
+"POT-Creation-Date: 2010-02-13 23:23+0000\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"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: lib/engine_prefs.rb:23
+msgid "&Name:"
+msgstr ""
+
+#: lib/engine_prefs.rb:31
+msgid "&Type:"
+msgstr ""
+
+#: lib/engine_prefs.rb:47 lib/newgame.rb:27
+msgid "&Game:"
+msgstr ""
+
+#: lib/engine_prefs.rb:56
+msgid "&Path:"
+msgstr ""
+
+#: lib/engine_prefs.rb:64
+msgid "&Arguments: "
+msgstr ""
+
+#: lib/engine_prefs.rb:72
+msgid "&Work directory:"
+msgstr ""
+
+#: lib/engine_prefs.rb:116
+msgid "Configure Engines"
+msgstr ""
+
+#: lib/engine_prefs.rb:136
+msgctxt "engine"
+msgid "&New..."
+msgstr ""
+
+#: lib/engine_prefs.rb:139
+msgctxt "engine"
+msgid "&Edit..."
+msgstr ""
+
+#: lib/engine_prefs.rb:142
+msgctxt "engine"
+msgid "&Delete"
+msgstr ""
+
+#: lib/engine_prefs.rb:170
+msgid "New Engine"
+msgstr ""
+
+#: lib/engine_prefs.rb:188
+msgid "Edit Engine"
+msgstr ""
+
+#: lib/kaya.rb:25
+msgid "Kaya"
+msgstr ""
+
+#: lib/kaya.rb:26
+msgid "KDE Board Game Suite"
+msgstr ""
+
+#: lib/kaya.rb:27
+msgid "(C) 2009 Paolo Capriotti"
+msgstr ""
+
+#: lib/kaya.rb:28
+msgid "Paolo Capriotti"
+msgstr ""
+
+#: lib/kaya.rb:29
+msgid "Jani Huhtanen"
+msgstr ""
+
+#: lib/kaya.rb:29
+msgid "Gaussian blur code"
+msgstr ""
+
+#: lib/kaya.rb:30
+msgid "Yann Dirson"
+msgstr ""
+
+#: lib/kaya.rb:30
+msgid "Minishogi"
+msgstr ""
+
+#: lib/kaya.rb:32
+msgid "Initial game"
+msgstr ""
+
+#: lib/mainwindow.rb:69
+msgid "B&ack"
+msgstr ""
+
+#: lib/mainwindow.rb:73
+msgid "&Forward"
+msgstr ""
+
+#: lib/mainwindow.rb:78
+msgid "F&lip"
+msgstr ""
+
+#: lib/mainwindow.rb:85
+msgid "Configure &Engines..."
+msgstr ""
+
+#: lib/mainwindow.rb:92
+msgid "Configure &Themes..."
+msgstr ""
+
+#: lib/mainwindow.rb:129
+msgid "History"
+msgstr ""
+
+#: lib/mainwindow.rb:146
+msgid "Console"
+msgstr ""
+
+#: lib/mainwindow.rb:229
+msgid "Open game"
+msgstr ""
+
+#: lib/mainwindow.rb:293
+msgid "Save game"
+msgstr ""
+
+#: lib/newgame.rb:17
+msgid "New game"
+msgstr ""
+
+#: lib/newgame.rb:23
+msgid "Open in new &tab"
+msgstr ""
+
+#: lib/newgame.rb:90
+msgid "Human"
+msgstr ""
+
+#: lib/plugins/ics/ics.rb:28
+msgid "&Connect to ICS"
+msgstr ""
+
+#: lib/plugins/ics/ics.rb:33
+msgid "&Disconnect from ICS"
+msgstr ""
+
+#: lib/plugins/ics/ics.rb:46
+msgid "Configure &ICS..."
+msgstr ""
+
+#: lib/theme_prefs.rb:24
+msgid "&Games"
+msgstr ""
+
+#: lib/theme_prefs.rb:25
+msgid "&Categories"
+msgstr ""
+
+#: lib/theme_prefs.rb:42
+msgid "Configure themes"
+msgstr ""
+
+#: rc.cpp:3
+msgid "&Game"
+msgstr ""
+
+#: rc.cpp:6
+msgid "&View"
+msgstr ""
+
+#: rc.cpp:9
+msgid "Game Toolbar"
+msgstr ""
@@ -0,0 +1,33 @@
+FIND_PROGRAM(GETTEXT_MSGFMT_EXECUTABLE msgfmt)
+
+IF(NOT GETTEXT_MSGFMT_EXECUTABLE)
+ MESSAGE(
+"------
+ NOTE: msgfmt not found. Translations will *not* be installed
+------")
+ELSE(NOT GETTEXT_MSGFMT_EXECUTABLE)
+
+ SET(catalogname kaya)
+
+ ADD_CUSTOM_TARGET(translations ALL)
+
+ FILE(GLOB PO_FILES *.po)
+
+ FOREACH(_poFile ${PO_FILES})
+ GET_FILENAME_COMPONENT(_poFileName ${_poFile} NAME)
+ STRING(REGEX REPLACE "^${catalogname}_?" "" _langCode ${_poFileName} )
+ STRING(REGEX REPLACE "\\.po$" "" _langCode ${_langCode} )
+
+ IF( _langCode )
+ GET_FILENAME_COMPONENT(_lang ${_poFile} NAME_WE)
+ SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo)
+
+ ADD_CUSTOM_COMMAND(TARGET translations
+ COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} --check -o ${_gmoFile} ${_poFile}
+ DEPENDS ${_poFile})
+ INSTALL(FILES ${_gmoFile} DESTINATION ${LOCALE_INSTALL_DIR}/${_langCode}/LC_MESSAGES/ RENAME ${catalogname}.mo)
+ ENDIF( _langCode )
+
+ ENDFOREACH(_poFile ${PO_FILES})
+
+ENDIF(NOT GETTEXT_MSGFMT_EXECUTABLE)
Oops, something went wrong.

0 comments on commit e6b4487

Please sign in to comment.