Navigation Menu

Skip to content

Commit

Permalink
Generate binary translation files at build time
Browse files Browse the repository at this point in the history
Remove generated .qml files from the repo.
To build the trads, simply run cmake.
  • Loading branch information
cor3ntin committed Mar 15, 2018
1 parent a822ea6 commit 2d90564
Show file tree
Hide file tree
Showing 83 changed files with 52 additions and 54 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,3 +6,4 @@
docs/*/_build
dashel/
enki/
*.qm
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -24,6 +24,7 @@ matrix:
- qtbase5-dev
- qttools5-dev
- qtbase5-dev-tools
- qttools5-dev-tools
- libqt5help5
- libqt5svg5-dev
- libqt5x11extras5-dev
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -34,7 +34,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
find_package(Threads REQUIRED)

# Qt and Qwt
find_package(Qt5 OPTIONAL_COMPONENTS Core Gui Widgets OpenGL Network Help Concurrent Xml Svg Test)
find_package(Qt5 OPTIONAL_COMPONENTS Core Gui Widgets OpenGL Network Help Concurrent Xml Svg Test LinguistTools)

find_package(Qwt)

Expand Down
3 changes: 3 additions & 0 deletions aseba/clients/studio/CMakeLists.txt
Expand Up @@ -92,6 +92,9 @@ codesign(asebaqtcommon)
add_subdirectory(plugins)

# resources
file(GLOB TRANSLATIONS_SOURCES "asebastudio*.ts" "compiler*.ts")
set_source_files_properties(${TRANSLATIONS_SOURCES} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}")
qt5_add_translation(TRANSLATIONS ${TRANSLATIONS_SOURCES} )
qt5_add_resources(resfiles asebastudio.qrc)

include_directories (${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
Expand Down
Binary file removed aseba/clients/studio/asebastudio_de.qm
Binary file not shown.
Binary file removed aseba/clients/studio/asebastudio_el.qm
Binary file not shown.
Binary file removed aseba/clients/studio/asebastudio_es.qm
Binary file not shown.
Binary file removed aseba/clients/studio/asebastudio_fr.qm
Binary file not shown.
Binary file removed aseba/clients/studio/asebastudio_it.qm
Binary file not shown.
Binary file removed aseba/clients/studio/asebastudio_ja.qm
Binary file not shown.
Binary file removed aseba/clients/studio/asebastudio_ru.qm
Binary file not shown.
Binary file removed aseba/clients/studio/asebastudio_tl.qm
Binary file not shown.
Binary file removed aseba/clients/studio/asebastudio_tr.qm
Binary file not shown.
Binary file removed aseba/clients/studio/asebastudio_zh.qm
Binary file not shown.
Binary file removed aseba/clients/studio/compiler_de.qm
Binary file not shown.
Binary file removed aseba/clients/studio/compiler_el.qm
Binary file not shown.
Binary file removed aseba/clients/studio/compiler_es.qm
Binary file not shown.
Binary file removed aseba/clients/studio/compiler_fr.qm
Binary file not shown.
Binary file removed aseba/clients/studio/compiler_it.qm
Binary file not shown.
Binary file removed aseba/clients/studio/compiler_ja.qm
Binary file not shown.
Binary file removed aseba/clients/studio/compiler_ru.qm
Binary file not shown.
Binary file removed aseba/clients/studio/compiler_tl.qm
Binary file not shown.
1 change: 0 additions & 1 deletion aseba/clients/studio/compiler_tr.qm

This file was deleted.

Binary file removed aseba/clients/studio/compiler_zh.qm
Binary file not shown.
3 changes: 3 additions & 0 deletions aseba/clients/thymioupgrader/CMakeLists.txt
Expand Up @@ -11,6 +11,9 @@ if (Qt5Widgets_FOUND AND Qt5Concurrent_FOUND AND Qt5Network_FOUND AND Qt5Xml_FOU
ThymioUpgrader.h
)

file(GLOB TRANSLATIONS_SOURCES "thymioupgrader*.ts")
set_source_files_properties(${TRANSLATIONS_SOURCES} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}")
qt5_add_translation(TRANSLATIONS ${TRANSLATIONS_SOURCES} )
qt5_add_resources(resfiles thymioupgrader.qrc)

include_directories (${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
Expand Down
Binary file removed aseba/clients/thymioupgrader/thymioupgrader_de.qm
Binary file not shown.
Binary file removed aseba/clients/thymioupgrader/thymioupgrader_el.qm
Binary file not shown.
Binary file removed aseba/clients/thymioupgrader/thymioupgrader_es.qm
Binary file not shown.
Binary file removed aseba/clients/thymioupgrader/thymioupgrader_fr.qm
Binary file not shown.
Binary file removed aseba/clients/thymioupgrader/thymioupgrader_it.qm
Binary file not shown.
Binary file removed aseba/clients/thymioupgrader/thymioupgrader_ja.qm
Binary file not shown.
Binary file removed aseba/clients/thymioupgrader/thymioupgrader_ru.qm
Binary file not shown.
Binary file removed aseba/clients/thymioupgrader/thymioupgrader_tl.qm
Binary file not shown.
1 change: 0 additions & 1 deletion aseba/clients/thymioupgrader/thymioupgrader_tr.qm

This file was deleted.

Binary file removed aseba/clients/thymioupgrader/thymioupgrader_zh.qm
Binary file not shown.
3 changes: 3 additions & 0 deletions aseba/clients/thymiownetconfig/CMakeLists.txt
Expand Up @@ -6,6 +6,9 @@ if (Qt5Widgets_FOUND)
ThymioWNetConfig.h
)

file(GLOB TRANSLATIONS_SOURCES "thymiownetconfig*.ts")
set_source_files_properties(${TRANSLATIONS_SOURCES} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}")
qt5_add_translation(TRANSLATIONS ${TRANSLATIONS_SOURCES} )
qt5_add_resources(resfiles thymiownetconfig.qrc)

include_directories (${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed aseba/clients/thymiownetconfig/thymiownetconfig_ru.qm
Binary file not shown.
Binary file removed aseba/clients/thymiownetconfig/thymiownetconfig_tl.qm
Binary file not shown.
1 change: 0 additions & 1 deletion aseba/clients/thymiownetconfig/thymiownetconfig_tr.qm

This file was deleted.

Binary file not shown.
7 changes: 6 additions & 1 deletion aseba/common/about/CMakeLists.txt
Expand Up @@ -9,8 +9,13 @@ if (Qt5Svg_FOUND)
if (ENKI_FOUND)
add_definitions(-DHAVE_ENKI)
endif (ENKI_FOUND)

qt5_add_resources(resfiles asebaqtabout.qrc)

file(GLOB TRANSLATIONS_SOURCES "qtabout*.ts")
set_source_files_properties(${TRANSLATIONS_SOURCES} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}")
qt5_add_translation(TRANSLATIONS ${TRANSLATIONS_SOURCES} )

qt5_wrap_cpp(qt_about_MOCS AboutDialog.h)
add_library(asebaqtabout AboutDialog.cpp ${qt_about_MOCS} ${resfiles})
qt5_use_modules(asebaqtabout Core Widgets Svg)
Expand Down
Binary file removed aseba/common/about/qtabout_de.qm
Binary file not shown.
Binary file removed aseba/common/about/qtabout_el.qm
Binary file not shown.
Binary file removed aseba/common/about/qtabout_es.qm
Binary file not shown.
Binary file removed aseba/common/about/qtabout_fr.qm
Binary file not shown.
Binary file removed aseba/common/about/qtabout_it.qm
Binary file not shown.
1 change: 0 additions & 1 deletion aseba/common/about/qtabout_ja.qm

This file was deleted.

Binary file removed aseba/common/about/qtabout_ru.qm
Binary file not shown.
Binary file removed aseba/common/about/qtabout_tl.qm
Binary file not shown.
1 change: 0 additions & 1 deletion aseba/common/about/qtabout_tr.qm

This file was deleted.

Binary file removed aseba/common/about/qtabout_zh.qm
Binary file not shown.
4 changes: 4 additions & 0 deletions aseba/targets/challenge/CMakeLists.txt
Expand Up @@ -11,6 +11,10 @@ set(challenge_SRCS
objects/food_ring.cpp
)

file(GLOB TRANSLATIONS_SOURCES "asebachallenge*.ts")
set_source_files_properties(${TRANSLATIONS_SOURCES} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}")
qt5_add_translation(TRANSLATIONS ${TRANSLATIONS_SOURCES} )

qt5_add_resources(challenge_RCC_SRCS challenge-textures.qrc)

add_executable(asebachallenge WIN32 ${challenge_SRCS} ${challenge_RCC_SRCS})
Expand Down
Binary file removed aseba/targets/challenge/asebachallenge_de.qm
Binary file not shown.
Binary file removed aseba/targets/challenge/asebachallenge_el.qm
Binary file not shown.
Binary file removed aseba/targets/challenge/asebachallenge_es.qm
Binary file not shown.
Binary file removed aseba/targets/challenge/asebachallenge_fr.qm
Binary file not shown.
Binary file removed aseba/targets/challenge/asebachallenge_it.qm
Binary file not shown.
Binary file removed aseba/targets/challenge/asebachallenge_ja.qm
Binary file not shown.
Binary file removed aseba/targets/challenge/asebachallenge_ru.qm
Binary file not shown.
Binary file removed aseba/targets/challenge/asebachallenge_tl.qm
Binary file not shown.
1 change: 0 additions & 1 deletion aseba/targets/challenge/asebachallenge_tr.qm

This file was deleted.

Binary file removed aseba/targets/challenge/asebachallenge_zh.qm
Binary file not shown.
3 changes: 3 additions & 0 deletions aseba/targets/playground/CMakeLists.txt
Expand Up @@ -32,6 +32,9 @@ if (Qt5Widgets_FOUND AND Qt5OpenGL_FOUND AND Qt5Xml_FOUND)
endif ()
set(CMAKE_AUTOMOC ON)

file(GLOB TRANSLATIONS_SOURCES "asebaplayground*.ts")
set_source_files_properties(${TRANSLATIONS_SOURCES} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}")
qt5_add_translation(TRANSLATIONS ${TRANSLATIONS_SOURCES} )
qt5_add_resources(resfiles asebaplayground.qrc)

set(playground_SRCS
Expand Down
Binary file removed aseba/targets/playground/asebaplayground_de.qm
Binary file not shown.
Binary file removed aseba/targets/playground/asebaplayground_el.qm
Binary file not shown.
Binary file removed aseba/targets/playground/asebaplayground_es.qm
Binary file not shown.
Binary file removed aseba/targets/playground/asebaplayground_fr.qm
Binary file not shown.
Binary file removed aseba/targets/playground/asebaplayground_it.qm
Binary file not shown.
1 change: 0 additions & 1 deletion aseba/targets/playground/asebaplayground_ja.qm

This file was deleted.

Binary file removed aseba/targets/playground/asebaplayground_ru.qm
Binary file not shown.
Binary file removed aseba/targets/playground/asebaplayground_tl.qm
Binary file not shown.
1 change: 0 additions & 1 deletion aseba/targets/playground/asebaplayground_tr.qm

This file was deleted.

Binary file removed aseba/targets/playground/asebaplayground_zh.qm
Binary file not shown.
32 changes: 16 additions & 16 deletions maintainer/translations/01_new_language.py
Expand Up @@ -90,31 +90,31 @@ def insert_before_tag(input_file, output_file, tag_re, inserted_text):
print "Generating files...\n"
os.chdir(studio_path)

# lupdate / lrelease asebastudio_x.{ts,qm}
translation_tools.do_lupdate_lrelease("asebastudio", code, " ".join([studio_path, plugin_path, vpl_path]))
# lupdate asebastudio_x.{ts,qm}
translation_tools.do_lupdate("asebastudio", code, " ".join([studio_path, plugin_path, vpl_path]))

# lupdate / lrelease compiler_x.{ts,qm}
translation_tools.do_lupdate_lrelease("compiler", code, compiler_ts_path)
# lupdate compiler_x.{ts,qm}
translation_tools.do_lupdate("compiler", code, compiler_ts_path)

os.chdir(challenge_path)
# lupdate / lrelease asebachallenge_x.{ts,qm}
translation_tools.do_lupdate_lrelease("asebachallenge", code, challenge_cpp)
# lupdate asebachallenge_x.{ts,qm}
translation_tools.do_lupdate("asebachallenge", code, challenge_cpp)

os.chdir(playground_path)
# lupdate / lrelease asebaplayground_x.{ts,qm}
translation_tools.do_lupdate_lrelease("asebaplayground", code, playground_path)
# lupdate asebaplayground_x.{ts,qm}
translation_tools.do_lupdate("asebaplayground", code, playground_path)

os.chdir(thymioupgrader_path)
# lupdate / lrelease thymioupgrader_x.{ts,qm}
translation_tools.do_lupdate_lrelease("thymioupgrader", code, thymioupgrader_path)
# lupdate thymioupgrader_x.{ts,qm}
translation_tools.do_lupdate("thymioupgrader", code, thymioupgrader_path)

os.chdir(thymiownetconfig_path)
# lupdate / lrelease thymiownetconfig_x.{ts,qm}
translation_tools.do_lupdate_lrelease("thymiownetconfig", code, thymiownetconfig_path)
# lupdate thymiownetconfig_x.{ts,qm}
translation_tools.do_lupdate("thymiownetconfig", code, thymiownetconfig_path)

os.chdir(qtabout_path)
# lupdate / lrelease qtabout_x.{ts,qm}
translation_tools.do_lupdate_lrelease("qtabout", code, qtabout_path)
# lupdate qtabout_x.{ts,qm}
translation_tools.do_lupdate("qtabout", code, qtabout_path)


print "Modifying source files...\n"
Expand Down Expand Up @@ -213,8 +213,8 @@ def insert_before_tag(input_file, output_file, tag_re, inserted_text):
print "Done\n"


print "We are done! Now edit the .ts files with Qt Linguist, then run lrelease on them to generate valid .qm."
print "Finally, do not forget to commit the .ts and .qm files."
print "We are done! Now edit the .ts files with Qt Linguist"
print "Finally, do not forget to commit the .ts files."
print "Have fun :-)\n"
print "*****\n"

Expand Down
14 changes: 7 additions & 7 deletions maintainer/translations/03_sync_all_translations.py
Expand Up @@ -29,25 +29,25 @@
translation_tools.init_commands()

# qtabout
translation_tools.do_lupdate_lrelease_all(qtabout_path, "qtabout", qtabout_path)
translation_tools.do_lupdate_all(qtabout_path, "qtabout", qtabout_path)

# asebastudio
translation_tools.do_lupdate_lrelease_all(studio_path, "asebastudio", " ".join([studio_path, plugin_path, vpl_path]))
translation_tools.do_lupdate_all(studio_path, "asebastudio", " ".join([studio_path, plugin_path, vpl_path]))

# compiler
translation_tools.do_lupdate_lrelease_all(studio_path, "compiler", compiler_ts_path)
translation_tools.do_lupdate_all(studio_path, "compiler", compiler_ts_path)

# playground
translation_tools.do_lupdate_lrelease_all(playground_path, "asebaplayground", playground_path)
translation_tools.do_lupdate_all(playground_path, "asebaplayground", playground_path)

# challenge
translation_tools.do_lupdate_lrelease_all(challenge_path, "asebachallenge", challenge_cpp)
translation_tools.do_lupdate_all(challenge_path, "asebachallenge", challenge_cpp)

# upgrader
translation_tools.do_lupdate_lrelease_all(thymioupgrader_path, "thymioupgrader", thymioupgrader_path)
translation_tools.do_lupdate_all(thymioupgrader_path, "thymioupgrader", thymioupgrader_path)

# wnetconfig
translation_tools.do_lupdate_lrelease_all(thymiownetconfig_path, "thymiownetconfig", thymiownetconfig_path)
translation_tools.do_lupdate_all(thymiownetconfig_path, "thymiownetconfig", thymiownetconfig_path)



3 changes: 1 addition & 2 deletions maintainer/translations/README
@@ -1,4 +1,3 @@

In this directory, you will find a bunch of scripts to maintain the translation
files. When you want to add a new language, it is necessary to generate several
files, and update others as well. The script "01_new_language.py" will help
Expand All @@ -13,7 +12,7 @@ For regular updates, use the following scripts:
| corresponding C++ source file in Aseba Studio.
|
| - 03_sync_all_translations.py
| Takes all the existing .ts, then performs lupate / lrelease
| Takes all the existing .ts, then performs lupate
|
|-- - 04_translation_statistics.py
Gives some statistics about the current translations
Expand Down
22 changes: 3 additions & 19 deletions maintainer/translations/translation_tools.py
Expand Up @@ -25,7 +25,6 @@
import re

_lupdate = ""
_lrelease = ""
_git = ""

def _verbose_call(cmd):
Expand All @@ -47,26 +46,18 @@ def _find_cmd(possible_cmds, args):
print "No"
return ""

def do_lupdate_lrelease(output_name, lang_code, input_files):
def do_lupdate(output_name, lang_code, input_files):
filename = "{}_{}.ts".format(output_name, lang_code)
filename_qm = "{}_{}.qm".format(output_name, lang_code)
# _lupdate
retcode = _verbose_call("{} -no-recursive {} -target-language {} -locations relative -ts {}".format(_lupdate, input_files, lang_code, filename))
if retcode != 0:
print sys.stderr, "Ooops... Something wrong happened with lupdate {}".format(filename)
exit(3)
if _git:
_verbose_call("{} add {}".format(_git, filename))
# _lrelease
retcode = _verbose_call("{} {} -qm {}".format(_lrelease, filename, filename_qm))
if retcode != 0:
print sys.stderr, "Ooops... Something wrong happened with lrelease {}".format(filename)
exit(4)
if _git:
_verbose_call("{} add {}".format(_git, filename_qm))


def do_lupdate_lrelease_all(directory, generic_name, input_files):
def do_lupdate_all(directory, generic_name, input_files):
old_path = os.getcwd()
os.chdir(directory)
# search all the existing languages corresponding to this file
Expand All @@ -78,7 +69,7 @@ def do_lupdate_lrelease_all(directory, generic_name, input_files):
continue
# get the language
lang = match.group(1)
do_lupdate_lrelease(generic_name, lang, input_files)
do_lupdate(generic_name, lang, input_files)
os.chdir(old_path)


Expand All @@ -89,7 +80,6 @@ def do_git_add(filename):

def init_commands():
global _lupdate
global _lrelease
global _git

print "First, we will test for a valid lupdate binary..."
Expand All @@ -98,12 +88,6 @@ def init_commands():
print sys.stderr, "No valide lupdate found :-("
exit(1)

print "...and for a valid lrelease..."
_lrelease = _find_cmd(["lrelease"], "-version")
if _lrelease == "":
print sys.stderr, "No valide lrelease found :-("
exit(1)

print "Trying to find a valid git binary (not mandatory)..."
_git = _find_cmd(["git"], "--version")
if _git == "":
Expand Down

0 comments on commit 2d90564

Please sign in to comment.