From 3e77e24b1f7cfd220498f44f6b261a673003f46f Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sat, 1 May 2021 17:12:59 +0200 Subject: [PATCH 1/4] The i18n files are no read from assets, while the ts files remain in the root folder --- .gitignore | 4 +++ {i18n => nw/assets/i18n}/project_de.json | 0 {i18n => nw/assets/i18n}/project_en.json | 0 {i18n => nw/assets/i18n}/project_fr.json | 0 {i18n => nw/assets/i18n}/project_nb_NO.json | 0 {i18n => nw/assets/i18n}/project_nn_NO.json | 0 {i18n => nw/assets/i18n}/project_pt.json | 0 nw/config.py | 2 +- setup.py | 33 +++++++++++++++++++++ 9 files changed, 38 insertions(+), 1 deletion(-) rename {i18n => nw/assets/i18n}/project_de.json (100%) rename {i18n => nw/assets/i18n}/project_en.json (100%) rename {i18n => nw/assets/i18n}/project_fr.json (100%) rename {i18n => nw/assets/i18n}/project_nb_NO.json (100%) rename {i18n => nw/assets/i18n}/project_nn_NO.json (100%) rename {i18n => nw/assets/i18n}/project_pt.json (100%) diff --git a/.gitignore b/.gitignore index 7873a701..f07eb4f8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,10 @@ setup.iss novelwriter.desktop novelWriter.pyw + +# Translations +/nw/assets/i18n/*.qm +.qmake.stash i18n/*.qm i18n/*.qph diff --git a/i18n/project_de.json b/nw/assets/i18n/project_de.json similarity index 100% rename from i18n/project_de.json rename to nw/assets/i18n/project_de.json diff --git a/i18n/project_en.json b/nw/assets/i18n/project_en.json similarity index 100% rename from i18n/project_en.json rename to nw/assets/i18n/project_en.json diff --git a/i18n/project_fr.json b/nw/assets/i18n/project_fr.json similarity index 100% rename from i18n/project_fr.json rename to nw/assets/i18n/project_fr.json diff --git a/i18n/project_nb_NO.json b/nw/assets/i18n/project_nb_NO.json similarity index 100% rename from i18n/project_nb_NO.json rename to nw/assets/i18n/project_nb_NO.json diff --git a/i18n/project_nn_NO.json b/nw/assets/i18n/project_nn_NO.json similarity index 100% rename from i18n/project_nn_NO.json rename to nw/assets/i18n/project_nn_NO.json diff --git a/i18n/project_pt.json b/nw/assets/i18n/project_pt.json similarity index 100% rename from i18n/project_pt.json rename to nw/assets/i18n/project_pt.json diff --git a/nw/config.py b/nw/config.py index bea508bc..b2703d77 100644 --- a/nw/config.py +++ b/nw/config.py @@ -307,7 +307,7 @@ class Config: self.appIcon = os.path.join(self.iconPath, "novelwriter.svg") # Internationalisation - self.nwLangPath = os.path.join(self.appRoot, "i18n") + self.nwLangPath = os.path.join(self.assetPath, "i18n") logger.verbose("App path: %s" % self.appPath) logger.verbose("Last path: %s" % self.lastPath) diff --git a/setup.py b/setup.py index 25703109..4075bd55 100755 --- a/setup.py +++ b/setup.py @@ -217,12 +217,36 @@ def buildQtDocs(): def buildQtI18n(): """Build the lang.qm files for Qt Linguist. """ + print("") + print("Building Qt Localisation Files") + print("==============================") + print("") + try: subprocess.call(["lrelease", "-verbose", "novelWriter.pro"]) except Exception as e: print("QtI18n Release Error:") print(str(e)) + print("") + print("Copying Files to nw/assets") + print("") + + langDir = os.path.join("nw", "assets", "i18n") + for langFile in os.listdir("i18n"): + langPath = os.path.join("i18n", langFile) + if not os.path.isfile(langPath): + continue + + if langFile.endswith(".qm"): + destPath = os.path.join(langDir, langFile) + os.rename(langPath, destPath) + print("Moved: %s -> %s" % (langPath, destPath)) + + print("") + + return + ## # Qt Linguist TS Builder (qtlupdate) ## @@ -230,12 +254,21 @@ def buildQtI18n(): def buildQtI18nTS(): """Build the lang.ts files for Qt Linguist. """ + print("") + print("Building Qt Translation Files") + print("=============================") + print("") + try: subprocess.call(["pylupdate5", "-verbose", "-noobsolete", "novelWriter.pro"]) except Exception as e: print("QtI18n Release Error:") print(str(e)) + print("") + + return + ## # Sample Project ZIP File Builder (sample) ## From 03e9fb93c7ce76f589a258e8807144e227eaef13 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sat, 1 May 2021 17:14:04 +0200 Subject: [PATCH 2/4] Update readmes --- README.md | 4 +++ i18n/README.md | 66 ++++++++++++++++++++++++-------------------------- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 5f4e7ff3..29434c87 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,10 @@ Contributions to this project are welcome. However, please read the [Contributing Guide](https://github.com/vkbo/novelWriter/blob/main/CONTRIBUTING.md) before submitting larger additions or changes. +If you want to help translating novelWriter into another language, please see the +[README](https://github.com/vkbo/novelWriter/blob/main/i18n/README.md) in the `nw/assets/i18n` +folder. + ## Key Features Some key features of novelWriter are listed below. Consult the diff --git a/i18n/README.md b/i18n/README.md index 400cd8b8..0b053248 100644 --- a/i18n/README.md +++ b/i18n/README.md @@ -1,58 +1,56 @@ # novelWriter Internationalisation -The `i18n` folder contains the internationalisation files for novelWriter. -There are two types of files. The `nw_XX.ts` / `nw_XX.qm` files are for -localisation of the main GUI, and the `project_XX.json` files are JSON files -with translation maps for the novelWriter projects, used by the Build Novel -Project tool. +The `i18n` folder contains the translation files for the Qt5 GUI. There are two types of files +involved: the `nw_XX.ts` and the `nw_XX.qm` files. The `nw_XX.ts` files are located in the `i18n` +folder at the root of the repository, and the `nw_XX.qm` together with the `project_XX.json` files +are located in `nw/assets/i18n`. The latter are JSON files translation maps for the novelWriter +projects, used by the Build Novel Project tool. -## GUI Localisation +## Qt GUI Localisation -The `.qm` files are the actual files used by the application to translate the -GUI into another language other than the default British English. The files are -not generated by default. They can be built with: +The `.qm` files are the actual files used by the application to translate the GUI into another +language other than the default British English. The files are not generated by default. They can +be built with: ```bash python3 setup.py qtlrelease ``` -To add a new translation file, first add a new entry in the `novelWriter.pro` -file under the `TRANSLATIONS` variable. Please use the underscore syntax for -file names as the importer expects this format. +To add a new translation file, first add a new entry in the `novelWriter.pro` file under the +`TRANSLATIONS` variable. Please use the underscore syntax for file names as the importer expects +this format. After adding the entry in the `.pro` file, run: ```bash python3 setup.py qtlupdate ``` -This will build a new `nw_XX.ts` file for the language you just added. The file -can then be edited with the Qt 5 Linguist application provided by Qt. This is -by far easier than manually editing the `.ts` file. Please select "English" and -"United Kingdom" as the source langauge when prompted by Qt 5 Linguist. +This will build a new `i18n/nw_XX.ts` file for the language you just added. The file can then be +edited with the Qt 5 Linguist application provided by Qt. This is by far easier than manually +editing the `.ts` file. Please select "English" and "United Kingdom" as the source langauge when +prompted by Qt 5 Linguist. -When you're done editing, you can build the `nw_XX.qm` file and test it in -novelWriter. The Preferences dialog should list the newly added language, and -you can select it and test it. +When you're done editing, you can build the `nw/assets/i18n/nw_XX.qm` file and test it in +novelWriter. The Preferences dialog should list the newly added language, and you can select it and +test it. -Please do not submit the `.qm` files to the repository. Only the `.ts` files +Please do not submit the `.qm` files to the repository. Only the `.ts` files in the `i18n` folder are needed. -**Note:** This requires that you have the tools Qt 5 Linguist and `pylupdate5` +**Note:** This requires that you have the tools Qt 5 Linguist and the PyQt5 tool `pylupdate5` installed on your system. ## Project Localisation -Projects can have a different language setting than the GUI itself. The files -with format `project_XX.json` are simple translation maps for text that goes -into the exported documents generated by the Build Novel Project tool. +Projects can have a different language setting than the GUI itself. The files with format +`project_XX.json` in `nw/assets/i18n` are simple translation maps for text that goes into the +exported documents generated by the Build Novel Project tool. -The files are loaded based on the language setting on the build tool. At the -present time, no other parts of the application use these files. Since these -are used as replacement lookups, they are maintained as plain JSON files. The -main usage is to generate chapter headers as number words. +The files are loaded based on the language setting in the build tool. At the present time, no other +parts of the application use these files. Since these are used as replacement lookups, they are +maintained as plain JSON files. The main usage is to generate chapter headers as number words. -There is no trick to using these files. Just copy the `project_en.json` file, -rename it to the appropriate language coded filename, and edit it. Please use -the underscore as separator if a language needs to be localised to a specific -country under a language. The importer will for instance look for `en_US` -first, then use `en` if it is not found. If there are no matching files, the -project falls back to using English. +Adding new translations for these files is easy. Just copy the `project_en.json` file, rename it to +the appropriate language coded filename, and edit it. Please use the underscore as separator if a +language needs to be localised to a specific country under a language. The importer will for +instance look for `en_US` first, then use `en` if it is not found. If there are no matching files, +the project falls back to using English. From fb5e4a5f17438964db294b4a239eda6e5b73a57c Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sat, 1 May 2021 17:14:13 +0200 Subject: [PATCH 3/4] Update translations --- i18n/nw_en_US.ts | 17 ++++++----------- i18n/nw_fr.ts | 17 ++++++----------- i18n/nw_nb_NO.ts | 17 ++++++----------- i18n/nw_pt.ts | 17 ++++++----------- 4 files changed, 24 insertions(+), 44 deletions(-) diff --git a/i18n/nw_en_US.ts b/i18n/nw_en_US.ts index 404338ef..31f2e286 100644 --- a/i18n/nw_en_US.ts +++ b/i18n/nw_en_US.ts @@ -757,22 +757,17 @@ - + Save Document As - - Unknown format - - - - + {0} file successfully written to: - + Failed to write {0} file. {1} @@ -780,17 +775,17 @@ GuiBuildNovelDocView - + This area will show the content of the document to be exported or printed. Press the "Build Preview" button to generate content. - + Unknown - + <b>Build Time:</b> {0} diff --git a/i18n/nw_fr.ts b/i18n/nw_fr.ts index 8761c05d..9bad5160 100644 --- a/i18n/nw_fr.ts +++ b/i18n/nw_fr.ts @@ -757,22 +757,17 @@ PDF - + Save Document As Enregistrer le document sous - - Unknown format - Format inconnu - - - + {0} file successfully written to: Fichier {0} écrit dans : - + Failed to write {0} file. {1} Erreur lors de l'écriture du fichier {0}. {1} @@ -780,17 +775,17 @@ GuiBuildNovelDocView - + This area will show the content of the document to be exported or printed. Press the "Build Preview" button to generate content. Dans cette zone s'affichera le contenu du document à exporter ou à imprimer. Utilisez le bouton "Construire l'aperçu" pour générer le contenu. - + Unknown Inconnu - + <b>Build Time:</b> {0} <b>Durée de construction :</b> {0} diff --git a/i18n/nw_nb_NO.ts b/i18n/nw_nb_NO.ts index d27e4cfa..b3467bdf 100644 --- a/i18n/nw_nb_NO.ts +++ b/i18n/nw_nb_NO.ts @@ -742,22 +742,17 @@ - + Save Document As Lagre dokumentet som - - Unknown format - Ukjent format - - - + {0} file successfully written to: Lagring av {0} var vellykket, og filen ble skrevet til: - + Failed to write {0} file. {1} Misslykkes i å skrive {0} til. {1} @@ -780,17 +775,17 @@ GuiBuildNovelDocView - + This area will show the content of the document to be exported or printed. Press the "Build Preview" button to generate content. Dette området vil vise innholdet av dokumentet som skal eksporteres. Trykk på knappen merket med "Lag forhåndsvisning" for å oppdatere innholdet. - + Unknown Ukjent - + <b>Build Time:</b> {0} <b>Generert den:</b> {0} diff --git a/i18n/nw_pt.ts b/i18n/nw_pt.ts index ec69bf37..6a370a45 100644 --- a/i18n/nw_pt.ts +++ b/i18n/nw_pt.ts @@ -451,11 +451,6 @@ Plain HTML HTML Simples - - - Unknown format - Formato desconhecido - novelWriter HTML (.htm) @@ -592,17 +587,17 @@ Fechar - + Save Document As Salvar Documento Como - + {0} file successfully written to: Arquivo {0} escrito com sucesso para: - + Failed to write {0} file. {1} Falhou para escrever o arquivo {0}. {1} @@ -780,17 +775,17 @@ GuiBuildNovelDocView - + Unknown Desconhecido - + This area will show the content of the document to be exported or printed. Press the "Build Preview" button to generate content. Esta área vai mostrar o conteúdo do documento a ser exportado ou impresso. Clique no botão "Construir Prévia" para gerar o conteúdo. - + <b>Build Time:</b> {0} <b>Tempo de Construção:</b> {0} From 754863e42cb210f7febac6997766e3ac7d794f20 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sat, 1 May 2021 17:18:15 +0200 Subject: [PATCH 4/4] Fix setup message --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4075bd55..83644bb6 100755 --- a/setup.py +++ b/setup.py @@ -229,7 +229,7 @@ def buildQtI18n(): print(str(e)) print("") - print("Copying Files to nw/assets") + print("Moving QM Files to Assets") print("") langDir = os.path.join("nw", "assets", "i18n")