Skip to content

Commit

Permalink
Merge pull request LinuxCNC#3192 from phillc54/qtplasmac-internationa…
Browse files Browse the repository at this point in the history
…lization

qtplasmac: fix linking and documentation for internationalization
  • Loading branch information
snowgoer540 authored Nov 27, 2024
2 parents d82dce9 + 4f59d68 commit f1da18e
Show file tree
Hide file tree
Showing 7 changed files with 2,503 additions and 1,202 deletions.
14 changes: 10 additions & 4 deletions docs/src/plasma/qtplasmac.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4182,6 +4182,8 @@ These are the files that require creating/editing for each language.

The .qm files are the compiled translation files used by pyqt.

The directories qtplasmac_4x3/languages and qtplasmac_9x16/languages are only for links to the .qm files in qtplasmac/languages.

The language is determined by an underscore plus the first two letters of the locale.
For example, if an Italian translation was being done then it would be `_it`.
It will be referred to as `_xx` in this document, so `qtplasmac_xx.ts` in this document would actually be `qtplasmac_it.ts` for an Italian translation.
Expand Down Expand Up @@ -4228,22 +4230,26 @@ The user needs to be careful with the length of strings that appear on widgets a
When editing is complete save the file: +
`File -> Save`


Then create the .qm file: +
`File -> Release`

Close linguist.

Then create links to the compiled .qm file for the other QtPlasmaC GUIs.
----
$ ln -s qtplasmac_en.qm ../../qtplasmac_4x3/languages/
$ ln -s qtplasmac_en.qm ../../qtplasmac_9x16/languages/
$ ./langlink xx
----

[NOTE]
this command is a script which creates a link in both qtplasmac_4x3/languages and qtplasmac_9x16/languages to the above .qm file and then renames the link to match the GUI name.

QtPlasmaC will be translated to the language of the current locale on the next start so long as a .qm file exists in that language.

Users are welcome to submit translation files for inclusion into QtPlasmaC.
An easy method is to post the up to date qtplasmac_xx.ts file on the forum and the maintainers will install the translations.

The preferred method is to submit a pull request from the users GitHub account as described in the https://www.linuxcnc.org/docs/html/code/contributing-to-linuxcnc.html[contributing to LinuxCNC] documentation.
The only files required to be committed are qtplasmac_xx.ts and qtplasmac_xx.qm.
The files required to be committed are qtplasmac_xx.ts and qtplasmac_xx.qm in the qtplasmc/languages directory plus the links in both the qtplasmac_4x3/languages and qtplasmac_9x16/languages directories.

== Appendix

Expand Down
14 changes: 11 additions & 3 deletions share/qtvcp/screens/qtplasmac/language_howto
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ The .ts files are the translation source files for the translations. These are t

The .qm files are the compiled translation files used by pyqt.

The directories qtplasmac_4x3/languages and qtplasmac_9x16/languages are only for links to the .qm files in qtplasmac/languages.

The language is determined by an underscore plus the first two letters of the locale, for example if an Italian translation was being done then it would be "_it". We will refer to it in the following as _xx, so "qtplasmac_xx.ts" for an Italian translation would be "qtplasmac_it.ts".

If any of the following utilities are not installed then you will need to install pyqt5-dev-tools:
Expand All @@ -24,7 +26,7 @@ $ pyuic5 ../qtplasmac.ui > qtplasmac.py
You can either create a new translation source file for a non existing language translation or modify an existing translation source file due to changes being made to some text in a QtPlasmaC source file. If modifying an existing translation that has had no source file changes then this step is not required.

Create/edit a .ts file:
$ langfile xx
$ ./langfile xx

(this command is a script which runs the following: $ pylupdate5 *.py ../*.py ../../../../../lib/python/qtvcp/lib/qtplasmac/*.py -ts qtplasmac_xx.ts)

Expand All @@ -40,9 +42,15 @@ When editing is complete save the file: File > Save

Then create the .qm file: File > Release

Close linguist.

Then create links to the compiled .qm file for the other QtPlasmaC GUIs.
$ ln -s qtplasmac_en.qm ../../qtplasmac_4x3/languages/
$ ln -s qtplasmac_en.qm ../../qtplasmac_9x16/languages/
$ ./langlink xx

QtPlasmaC will be translated to the language of the current locale on the next start so long as a .qm file exists in that language.

Users are welcome to submit translation files for inclusion into QtPlasmaC.
An easy method is to post the up to date qtplasmac_xx.ts file on the forum and the maintainers will install the translations.

The preferred method is to submit a pull request from the users GitHub account as described in the documentation: https://www.linuxcnc.org/docs/html/code/contributing-to-linuxcnc.html
The files required to be committed are qtplasmac_xx.ts and qtplasmac_xx.qm in the qtplasmc/languages directory plus the links in both the qtplasmac_4x3/languages and qtplasmac_9x16/languages directories.
8 changes: 5 additions & 3 deletions share/qtvcp/screens/qtplasmac/languages/langfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/bin/bash

# creates a .ts file for language translation using Qt Linguist

if [ $# -eq 0 ]; then
echo -e '\nlocale is missing\n'
echo -e "\nlocale is missing\n"
exit
elif [ ${#1} -ne 2 ]; then
echo -e '\nlocale needs to be two characters\n'
echo -e "\nlocale needs to be two characters\n"
exit
fi

echo -e '\ncreating language translation file qtplasmac_'$1'.ts\n'
echo -e "\ncreating language translation file qtplasmac_$1.ts\n"

pylupdate5 *.py ../*.py ../../../../../lib/python/qtvcp/lib/qtplasmac/*.py -ts qtplasmac_$1.ts
26 changes: 26 additions & 0 deletions share/qtvcp/screens/qtplasmac/languages/langlink
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# creates links to the Qt translation .qm filefor the 4x3 and 9x16 GUIs

if [ $# -eq 0 ]; then
echo -e "\nlocale is missing\n"
exit
elif [ ${#1} -ne 2 ]; then
echo -e "\nlocale needs to be two characters\n"
exit
fi


if [ ! -f "qtplasmac_$1.qm" ]
then
echo -e "\nlanguage file qtplasmac_$1.qm does not exist\n"
exit
else
echo -e "\ncreating links to qtplasmac_$1.qn translation for qtplasmac_4x3 and qtplasmac_9x16\n"
mkdir -p "../../qtplasmac_4x3/languages"
mkdir -p "../../qtplasmac_9x16/languages"
ln -rs qtplasmac_sk.qm -t ../../qtplasmac_4x3/languages
ln -rs qtplasmac_sk.qm -t ../../qtplasmac_9x16/languages
mv ../../qtplasmac_4x3/languages/qtplasmac_sk.qm ../../qtplasmac_4x3/languages/qtplasmac_4x3_sk.qm
mv ../../qtplasmac_9x16/languages/qtplasmac_sk.qm ../../qtplasmac_9x16/languages/qtplasmac_9x16_sk.qm
fi
Loading

0 comments on commit f1da18e

Please sign in to comment.