Skip to content
Permalink
Browse files

Generate binary translation files at build time

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 2d90564b2e0fd84a701e4d40d6a28715addfd37e
Showing with 52 additions and 54 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 .travis.yml
  3. +1 −1 CMakeLists.txt
  4. +3 −0 aseba/clients/studio/CMakeLists.txt
  5. BIN aseba/clients/studio/asebastudio_de.qm
  6. BIN aseba/clients/studio/asebastudio_el.qm
  7. BIN aseba/clients/studio/asebastudio_es.qm
  8. BIN aseba/clients/studio/asebastudio_fr.qm
  9. BIN aseba/clients/studio/asebastudio_it.qm
  10. BIN aseba/clients/studio/asebastudio_ja.qm
  11. BIN aseba/clients/studio/asebastudio_ru.qm
  12. BIN aseba/clients/studio/asebastudio_tl.qm
  13. BIN aseba/clients/studio/asebastudio_tr.qm
  14. BIN aseba/clients/studio/asebastudio_zh.qm
  15. BIN aseba/clients/studio/compiler_de.qm
  16. BIN aseba/clients/studio/compiler_el.qm
  17. BIN aseba/clients/studio/compiler_es.qm
  18. BIN aseba/clients/studio/compiler_fr.qm
  19. BIN aseba/clients/studio/compiler_it.qm
  20. BIN aseba/clients/studio/compiler_ja.qm
  21. BIN aseba/clients/studio/compiler_ru.qm
  22. BIN aseba/clients/studio/compiler_tl.qm
  23. +0 −1 aseba/clients/studio/compiler_tr.qm
  24. BIN aseba/clients/studio/compiler_zh.qm
  25. +3 −0 aseba/clients/thymioupgrader/CMakeLists.txt
  26. BIN aseba/clients/thymioupgrader/thymioupgrader_de.qm
  27. BIN aseba/clients/thymioupgrader/thymioupgrader_el.qm
  28. BIN aseba/clients/thymioupgrader/thymioupgrader_es.qm
  29. BIN aseba/clients/thymioupgrader/thymioupgrader_fr.qm
  30. BIN aseba/clients/thymioupgrader/thymioupgrader_it.qm
  31. BIN aseba/clients/thymioupgrader/thymioupgrader_ja.qm
  32. BIN aseba/clients/thymioupgrader/thymioupgrader_ru.qm
  33. BIN aseba/clients/thymioupgrader/thymioupgrader_tl.qm
  34. +0 −1 aseba/clients/thymioupgrader/thymioupgrader_tr.qm
  35. BIN aseba/clients/thymioupgrader/thymioupgrader_zh.qm
  36. +3 −0 aseba/clients/thymiownetconfig/CMakeLists.txt
  37. BIN aseba/clients/thymiownetconfig/thymiownetconfig_de.qm
  38. BIN aseba/clients/thymiownetconfig/thymiownetconfig_el.qm
  39. BIN aseba/clients/thymiownetconfig/thymiownetconfig_es.qm
  40. BIN aseba/clients/thymiownetconfig/thymiownetconfig_fr.qm
  41. BIN aseba/clients/thymiownetconfig/thymiownetconfig_it.qm
  42. BIN aseba/clients/thymiownetconfig/thymiownetconfig_ja.qm
  43. BIN aseba/clients/thymiownetconfig/thymiownetconfig_ru.qm
  44. BIN aseba/clients/thymiownetconfig/thymiownetconfig_tl.qm
  45. +0 −1 aseba/clients/thymiownetconfig/thymiownetconfig_tr.qm
  46. BIN aseba/clients/thymiownetconfig/thymiownetconfig_zh.qm
  47. +6 −1 aseba/common/about/CMakeLists.txt
  48. BIN aseba/common/about/qtabout_de.qm
  49. BIN aseba/common/about/qtabout_el.qm
  50. BIN aseba/common/about/qtabout_es.qm
  51. BIN aseba/common/about/qtabout_fr.qm
  52. BIN aseba/common/about/qtabout_it.qm
  53. +0 −1 aseba/common/about/qtabout_ja.qm
  54. BIN aseba/common/about/qtabout_ru.qm
  55. BIN aseba/common/about/qtabout_tl.qm
  56. +0 −1 aseba/common/about/qtabout_tr.qm
  57. BIN aseba/common/about/qtabout_zh.qm
  58. +4 −0 aseba/targets/challenge/CMakeLists.txt
  59. BIN aseba/targets/challenge/asebachallenge_de.qm
  60. BIN aseba/targets/challenge/asebachallenge_el.qm
  61. BIN aseba/targets/challenge/asebachallenge_es.qm
  62. BIN aseba/targets/challenge/asebachallenge_fr.qm
  63. BIN aseba/targets/challenge/asebachallenge_it.qm
  64. BIN aseba/targets/challenge/asebachallenge_ja.qm
  65. BIN aseba/targets/challenge/asebachallenge_ru.qm
  66. BIN aseba/targets/challenge/asebachallenge_tl.qm
  67. +0 −1 aseba/targets/challenge/asebachallenge_tr.qm
  68. BIN aseba/targets/challenge/asebachallenge_zh.qm
  69. +3 −0 aseba/targets/playground/CMakeLists.txt
  70. BIN aseba/targets/playground/asebaplayground_de.qm
  71. BIN aseba/targets/playground/asebaplayground_el.qm
  72. BIN aseba/targets/playground/asebaplayground_es.qm
  73. BIN aseba/targets/playground/asebaplayground_fr.qm
  74. BIN aseba/targets/playground/asebaplayground_it.qm
  75. +0 −1 aseba/targets/playground/asebaplayground_ja.qm
  76. BIN aseba/targets/playground/asebaplayground_ru.qm
  77. BIN aseba/targets/playground/asebaplayground_tl.qm
  78. +0 −1 aseba/targets/playground/asebaplayground_tr.qm
  79. BIN aseba/targets/playground/asebaplayground_zh.qm
  80. +16 −16 maintainer/translations/01_new_language.py
  81. +7 −7 maintainer/translations/03_sync_all_translations.py
  82. +1 −2 maintainer/translations/README
  83. +3 −19 maintainer/translations/translation_tools.py
@@ -6,3 +6,4 @@
docs/*/_build
dashel/
enki/
*.qm
@@ -24,6 +24,7 @@ matrix:
- qtbase5-dev
- qttools5-dev
- qtbase5-dev-tools
- qttools5-dev-tools
- libqt5help5
- libqt5svg5-dev
- libqt5x11extras5-dev
@@ -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)

@@ -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})
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 not shown.
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 not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Oops, something went wrong.
Binary file not shown.
@@ -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})
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 not shown.
Binary file not shown.

This file was deleted.

Oops, something went wrong.
Binary file not shown.
@@ -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})
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 not shown.
Binary file not shown.

This file was deleted.

Oops, something went wrong.
Binary file not shown.
@@ -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)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Oops, something went wrong.
Binary file not shown.
Binary file not shown.

This file was deleted.

Oops, something went wrong.
Binary file not shown.
@@ -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})
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 not shown.
Binary file not shown.

This file was deleted.

Oops, something went wrong.
Binary file not shown.
@@ -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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Oops, something went wrong.
Binary file not shown.
Binary file not shown.

This file was deleted.

Oops, something went wrong.
Binary file not shown.
@@ -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"
@@ -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"

@@ -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)



@@ -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
@@ -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
@@ -25,7 +25,6 @@
import re

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

def _verbose_call(cmd):
@@ -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
@@ -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)


@@ -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..."
@@ -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 == "":

0 comments on commit 2d90564

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.