From 034f70c4915315d39e4d0bb7e0621e15c384c9e4 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 2 May 2020 22:39:56 +1000 Subject: [PATCH 1/4] Update translations --- InvenTree/locale/de/LC_MESSAGES/django.po | 55 ++++++++++++++++++----- InvenTree/locale/en/LC_MESSAGES/django.po | 47 ++++++++++++++----- InvenTree/locale/es/LC_MESSAGES/django.po | 47 ++++++++++++++----- 3 files changed, 119 insertions(+), 30 deletions(-) diff --git a/InvenTree/locale/de/LC_MESSAGES/django.po b/InvenTree/locale/de/LC_MESSAGES/django.po index f39f917874..f942bb1fb9 100644 --- a/InvenTree/locale/de/LC_MESSAGES/django.po +++ b/InvenTree/locale/de/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-02 12:11+0000\n" +"POT-Creation-Date: 2020-05-02 12:39+0000\n" "PO-Revision-Date: 2020-02-02 08:07+0100\n" "Last-Translator: Christian Schlüter \n" "Language-Team: C \n" @@ -232,7 +232,7 @@ msgstr "" #: part/templates/part/part_app_base.html:7 #: part/templates/part/set_category.html:13 templates/js/bom.html:135 #: templates/js/build.html:41 templates/js/company.html:109 -#: templates/js/part.html:111 +#: templates/js/part.html:111 templates/js/stock.html:206 msgid "Part" msgstr "Teil" @@ -311,7 +311,7 @@ msgstr "Link zu einer externen URL" #: order/templates/order/purchase_order_detail.html:200 #: order/templates/order/so_tabs.html:23 part/templates/part/tabs.html:63 #: stock/models.py:439 stock/templates/stock/tabs.html:17 -#: templates/js/bom.html:229 +#: templates/js/bom.html:229 templates/js/stock.html:290 msgid "Notes" msgstr "Notizen" @@ -407,14 +407,14 @@ msgstr "Seriennummer" #: stock/templates/stock/item_base.html:26 #: stock/templates/stock/item_base.html:154 #: stock/templates/stock/stock_adjust.html:18 templates/js/bom.html:172 -#: templates/js/build.html:52 +#: templates/js/build.html:52 templates/js/stock.html:437 msgid "Quantity" msgstr "Anzahl" #: build/templates/build/allocate.html:177 #: build/templates/build/auto_allocate.html:20 #: stock/templates/stock/item_base.html:134 -#: stock/templates/stock/stock_adjust.html:17 +#: stock/templates/stock/stock_adjust.html:17 templates/js/stock.html:277 msgid "Location" msgstr "Standort" @@ -445,7 +445,8 @@ msgstr "Keine Seriennummern gefunden" #: part/templates/part/detail.html:38 part/templates/part/set_category.html:14 #: templates/js/bom.html:157 templates/js/company.html:60 #: templates/js/order.html:157 templates/js/order.html:230 -#: templates/js/part.html:167 +#: templates/js/part.html:167 templates/js/stock.html:227 +#: templates/js/stock.html:418 msgid "Description" msgstr "Beschreibung" @@ -537,6 +538,7 @@ msgstr "Bau-Status" #: build/templates/build/detail.html:42 #: stock/templates/stock/item_base.html:221 templates/js/build.html:57 #: templates/js/order.html:162 templates/js/order.html:235 +#: templates/js/stock.html:264 msgid "Status" msgstr "Status" @@ -626,7 +628,7 @@ msgid "Stock can be taken from any available location." msgstr "Bestand kann jedem verfügbaren Lagerort entnommen werden." #: build/templates/build/detail.html:48 -#: stock/templates/stock/item_base.html:161 +#: stock/templates/stock/item_base.html:161 templates/js/stock.html:272 msgid "Batch" msgstr "Los" @@ -1275,7 +1277,7 @@ msgstr "Teile-Packaging" #: company/templates/company/supplier_part_tabs.html:8 #: company/templates/company/tabs.html:12 part/templates/part/tabs.html:17 #: stock/templates/stock/location.html:12 templates/js/part.html:194 -#: templates/navbar.html:11 +#: templates/js/stock.html:235 templates/navbar.html:11 msgid "Stock" msgstr "Lagerbestand" @@ -2275,6 +2277,7 @@ msgstr "bestellt" #: stock/templates/stock/item_base.html:52 #: stock/templates/stock/item_base.html:183 #: stock/templates/stock/stock_adjust.html:16 templates/js/build.html:106 +#: templates/js/stock.html:407 msgid "Stock Item" msgstr "Lagerobjekt" @@ -3563,7 +3566,7 @@ msgstr "" msgid "No purchase orders found" msgstr "Kaufvertrag" -#: templates/js/order.html:170 +#: templates/js/order.html:170 templates/js/stock.html:389 msgid "Date" msgstr "" @@ -3577,7 +3580,7 @@ msgstr "Keine Seriennummern gefunden" msgid "Shipment Date" msgstr "" -#: templates/js/part.html:104 +#: templates/js/part.html:104 templates/js/stock.html:196 #, fuzzy #| msgid "Select part" msgid "Select" @@ -3619,6 +3622,38 @@ msgstr "Bau" msgid "No parts found" msgstr "Keine Seriennummern gefunden" +#: templates/js/stock.html:66 +msgid "No stock items matching query" +msgstr "" + +#: templates/js/stock.html:251 +#, fuzzy +#| msgid "Stock Item to allocate to build" +msgid "StockItem has been allocated" +msgstr "Lagerobjekt dem Bau zuweisen" + +#: templates/js/stock.html:256 +#, fuzzy +#| msgid "Stock Item Details" +msgid "StockItem is lost" +msgstr "Lagerbestands-Details" + +#: templates/js/stock.html:284 +#, fuzzy +#| msgid "Edit Stock Location" +msgid "No stock location set" +msgstr "Lagerobjekt-Standort bearbeiten" + +#: templates/js/stock.html:446 +msgid "User" +msgstr "" + +#: templates/js/stock.html:455 +#, fuzzy +#| msgid "Show pricing information" +msgid "No user information" +msgstr "Kosteninformationen ansehen" + #: templates/navbar.html:14 msgid "Buy" msgstr "" diff --git a/InvenTree/locale/en/LC_MESSAGES/django.po b/InvenTree/locale/en/LC_MESSAGES/django.po index 85ebc1e513..d428be4470 100644 --- a/InvenTree/locale/en/LC_MESSAGES/django.po +++ b/InvenTree/locale/en/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-02 12:11+0000\n" +"POT-Creation-Date: 2020-05-02 12:39+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -223,7 +223,7 @@ msgstr "" #: part/templates/part/part_app_base.html:7 #: part/templates/part/set_category.html:13 templates/js/bom.html:135 #: templates/js/build.html:41 templates/js/company.html:109 -#: templates/js/part.html:111 +#: templates/js/part.html:111 templates/js/stock.html:206 msgid "Part" msgstr "" @@ -290,7 +290,7 @@ msgstr "" #: order/templates/order/purchase_order_detail.html:200 #: order/templates/order/so_tabs.html:23 part/templates/part/tabs.html:63 #: stock/models.py:439 stock/templates/stock/tabs.html:17 -#: templates/js/bom.html:229 +#: templates/js/bom.html:229 templates/js/stock.html:290 msgid "Notes" msgstr "" @@ -375,14 +375,14 @@ msgstr "" #: stock/templates/stock/item_base.html:26 #: stock/templates/stock/item_base.html:154 #: stock/templates/stock/stock_adjust.html:18 templates/js/bom.html:172 -#: templates/js/build.html:52 +#: templates/js/build.html:52 templates/js/stock.html:437 msgid "Quantity" msgstr "" #: build/templates/build/allocate.html:177 #: build/templates/build/auto_allocate.html:20 #: stock/templates/stock/item_base.html:134 -#: stock/templates/stock/stock_adjust.html:17 +#: stock/templates/stock/stock_adjust.html:17 templates/js/stock.html:277 msgid "Location" msgstr "" @@ -407,7 +407,8 @@ msgstr "" #: part/templates/part/detail.html:38 part/templates/part/set_category.html:14 #: templates/js/bom.html:157 templates/js/company.html:60 #: templates/js/order.html:157 templates/js/order.html:230 -#: templates/js/part.html:167 +#: templates/js/part.html:167 templates/js/stock.html:227 +#: templates/js/stock.html:418 msgid "Description" msgstr "" @@ -481,6 +482,7 @@ msgstr "" #: build/templates/build/detail.html:42 #: stock/templates/stock/item_base.html:221 templates/js/build.html:57 #: templates/js/order.html:162 templates/js/order.html:235 +#: templates/js/stock.html:264 msgid "Status" msgstr "" @@ -557,7 +559,7 @@ msgid "Stock can be taken from any available location." msgstr "" #: build/templates/build/detail.html:48 -#: stock/templates/stock/item_base.html:161 +#: stock/templates/stock/item_base.html:161 templates/js/stock.html:272 msgid "Batch" msgstr "" @@ -1107,7 +1109,7 @@ msgstr "" #: company/templates/company/supplier_part_tabs.html:8 #: company/templates/company/tabs.html:12 part/templates/part/tabs.html:17 #: stock/templates/stock/location.html:12 templates/js/part.html:194 -#: templates/navbar.html:11 +#: templates/js/stock.html:235 templates/navbar.html:11 msgid "Stock" msgstr "" @@ -1946,6 +1948,7 @@ msgstr "" #: stock/templates/stock/item_base.html:52 #: stock/templates/stock/item_base.html:183 #: stock/templates/stock/stock_adjust.html:16 templates/js/build.html:106 +#: templates/js/stock.html:407 msgid "Stock Item" msgstr "" @@ -3038,7 +3041,7 @@ msgstr "" msgid "No purchase orders found" msgstr "" -#: templates/js/order.html:170 +#: templates/js/order.html:170 templates/js/stock.html:389 msgid "Date" msgstr "" @@ -3050,7 +3053,7 @@ msgstr "" msgid "Shipment Date" msgstr "" -#: templates/js/part.html:104 +#: templates/js/part.html:104 templates/js/stock.html:196 msgid "Select" msgstr "" @@ -3078,6 +3081,30 @@ msgstr "" msgid "No parts found" msgstr "" +#: templates/js/stock.html:66 +msgid "No stock items matching query" +msgstr "" + +#: templates/js/stock.html:251 +msgid "StockItem has been allocated" +msgstr "" + +#: templates/js/stock.html:256 +msgid "StockItem is lost" +msgstr "" + +#: templates/js/stock.html:284 +msgid "No stock location set" +msgstr "" + +#: templates/js/stock.html:446 +msgid "User" +msgstr "" + +#: templates/js/stock.html:455 +msgid "No user information" +msgstr "" + #: templates/navbar.html:14 msgid "Buy" msgstr "" diff --git a/InvenTree/locale/es/LC_MESSAGES/django.po b/InvenTree/locale/es/LC_MESSAGES/django.po index 85ebc1e513..d428be4470 100644 --- a/InvenTree/locale/es/LC_MESSAGES/django.po +++ b/InvenTree/locale/es/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-02 12:11+0000\n" +"POT-Creation-Date: 2020-05-02 12:39+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -223,7 +223,7 @@ msgstr "" #: part/templates/part/part_app_base.html:7 #: part/templates/part/set_category.html:13 templates/js/bom.html:135 #: templates/js/build.html:41 templates/js/company.html:109 -#: templates/js/part.html:111 +#: templates/js/part.html:111 templates/js/stock.html:206 msgid "Part" msgstr "" @@ -290,7 +290,7 @@ msgstr "" #: order/templates/order/purchase_order_detail.html:200 #: order/templates/order/so_tabs.html:23 part/templates/part/tabs.html:63 #: stock/models.py:439 stock/templates/stock/tabs.html:17 -#: templates/js/bom.html:229 +#: templates/js/bom.html:229 templates/js/stock.html:290 msgid "Notes" msgstr "" @@ -375,14 +375,14 @@ msgstr "" #: stock/templates/stock/item_base.html:26 #: stock/templates/stock/item_base.html:154 #: stock/templates/stock/stock_adjust.html:18 templates/js/bom.html:172 -#: templates/js/build.html:52 +#: templates/js/build.html:52 templates/js/stock.html:437 msgid "Quantity" msgstr "" #: build/templates/build/allocate.html:177 #: build/templates/build/auto_allocate.html:20 #: stock/templates/stock/item_base.html:134 -#: stock/templates/stock/stock_adjust.html:17 +#: stock/templates/stock/stock_adjust.html:17 templates/js/stock.html:277 msgid "Location" msgstr "" @@ -407,7 +407,8 @@ msgstr "" #: part/templates/part/detail.html:38 part/templates/part/set_category.html:14 #: templates/js/bom.html:157 templates/js/company.html:60 #: templates/js/order.html:157 templates/js/order.html:230 -#: templates/js/part.html:167 +#: templates/js/part.html:167 templates/js/stock.html:227 +#: templates/js/stock.html:418 msgid "Description" msgstr "" @@ -481,6 +482,7 @@ msgstr "" #: build/templates/build/detail.html:42 #: stock/templates/stock/item_base.html:221 templates/js/build.html:57 #: templates/js/order.html:162 templates/js/order.html:235 +#: templates/js/stock.html:264 msgid "Status" msgstr "" @@ -557,7 +559,7 @@ msgid "Stock can be taken from any available location." msgstr "" #: build/templates/build/detail.html:48 -#: stock/templates/stock/item_base.html:161 +#: stock/templates/stock/item_base.html:161 templates/js/stock.html:272 msgid "Batch" msgstr "" @@ -1107,7 +1109,7 @@ msgstr "" #: company/templates/company/supplier_part_tabs.html:8 #: company/templates/company/tabs.html:12 part/templates/part/tabs.html:17 #: stock/templates/stock/location.html:12 templates/js/part.html:194 -#: templates/navbar.html:11 +#: templates/js/stock.html:235 templates/navbar.html:11 msgid "Stock" msgstr "" @@ -1946,6 +1948,7 @@ msgstr "" #: stock/templates/stock/item_base.html:52 #: stock/templates/stock/item_base.html:183 #: stock/templates/stock/stock_adjust.html:16 templates/js/build.html:106 +#: templates/js/stock.html:407 msgid "Stock Item" msgstr "" @@ -3038,7 +3041,7 @@ msgstr "" msgid "No purchase orders found" msgstr "" -#: templates/js/order.html:170 +#: templates/js/order.html:170 templates/js/stock.html:389 msgid "Date" msgstr "" @@ -3050,7 +3053,7 @@ msgstr "" msgid "Shipment Date" msgstr "" -#: templates/js/part.html:104 +#: templates/js/part.html:104 templates/js/stock.html:196 msgid "Select" msgstr "" @@ -3078,6 +3081,30 @@ msgstr "" msgid "No parts found" msgstr "" +#: templates/js/stock.html:66 +msgid "No stock items matching query" +msgstr "" + +#: templates/js/stock.html:251 +msgid "StockItem has been allocated" +msgstr "" + +#: templates/js/stock.html:256 +msgid "StockItem is lost" +msgstr "" + +#: templates/js/stock.html:284 +msgid "No stock location set" +msgstr "" + +#: templates/js/stock.html:446 +msgid "User" +msgstr "" + +#: templates/js/stock.html:455 +msgid "No user information" +msgstr "" + #: templates/navbar.html:14 msgid "Buy" msgstr "" From 979cf10c66f6963aed28e26c0a8e5486b4e4a4bc Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 2 May 2020 22:52:32 +1000 Subject: [PATCH 2/4] First pass at a translation helper script --- InvenTree/script/translate.py | 63 +++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 InvenTree/script/translate.py diff --git a/InvenTree/script/translate.py b/InvenTree/script/translate.py new file mode 100644 index 0000000000..0c4a3e7253 --- /dev/null +++ b/InvenTree/script/translate.py @@ -0,0 +1,63 @@ +""" +This script is used to simplify the translation process. + +Django provides a framework for working out which strings are "translatable", +and these strings are then dumped in a file under InvenTree/locale//LC_MESSAGES/django.po + +This script presents the translator with a list of strings which have not yet been translated, +allowing for a simpler and quicker translation process. + +If a string translation needs to be updated, this will still need to be done manually, +by editing the appropriate .po file. + +""" + +import argparse +import os +import sys + + +def manually_translate_file(filename): + """ + Manually translate a .po file. + Present any missing translation strings to the translator, + and write their responses back to the file. + """ + + print("here we go!", filename) + + +if __name__ == '__main__': + + MY_DIR = os.path.dirname(os.path.realpath(__file__)) + LOCALE_DIR = os.path.join(MY_DIR, '..', 'locale') + + if not os.path.exists(LOCALE_DIR): + print("Error: {d} does not exist!".format(d=LOCALE_DIR)) + sys.exit(1) + + parser = argparse.ArgumentParser(description="InvenTree Translation Helper") + + parser.add_argument('language', help='Language code', action='store') + + args = parser.parse_args() + + language = args.language + + LANGUAGE_DIR = os.path.abspath(os.path.join(LOCALE_DIR, language)) + + # Check that a locale directory exists for the given language! + if not os.path.exists(LANGUAGE_DIR): + print("Error: Locale directory for language '{l}' does not exist".format(l=language)) + sys.exit(1) + + # Check that a .po file exists for the given language! + PO_FILE = os.path.join(LANGUAGE_DIR, 'LC_MESSAGES', 'django.po') + + if not os.path.exists(PO_FILE): + print("Error: File '{f}' does not exist".format(f=PO_FILE)) + sys.exit(1) + + # Ok, now we run the user through the translation file + manually_translate_file(PO_FILE) + \ No newline at end of file From 88e28edba9f652bbf01479fbd589a81df82c6197 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 2 May 2020 23:10:18 +1000 Subject: [PATCH 3/4] Script now manually adjusts the translation file --- InvenTree/script/translate.py | 51 ++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/InvenTree/script/translate.py b/InvenTree/script/translate.py index 0c4a3e7253..f92567dabd 100644 --- a/InvenTree/script/translate.py +++ b/InvenTree/script/translate.py @@ -17,15 +17,58 @@ import os import sys -def manually_translate_file(filename): +def manually_translate_file(filename, save=False): """ Manually translate a .po file. Present any missing translation strings to the translator, and write their responses back to the file. """ - print("here we go!", filename) + print("Add manual translations to '{f}'".format(f=filename)) + print("For each missing translation:") + print("a) Directly enter a new tranlation in the target language") + print("b) Leave empty to skip") + + input("Press to continue") + print("") + with open(filename, 'r') as f: + lines = f.readlines() + + out = [] + + # Context data + source_line = '' + msgid = '' + + for num, line in enumerate(lines): + # Keep track of context data BEFORE an empty msgstr object + line = line.strip() + + if line.startswith("#: "): + source_line = line.replace("#: ", "") + + elif line.startswith("msgid "): + msgid = line.replace("msgid ", "") + + if line.strip() == 'msgstr ""': + # We have found an empty translation! + + if msgid and len(msgid) > 0 and not msgid == '""': + print("Source:", source_line) + print("Enter translation for {t}".format(t=msgid)) + + translation = str(input(">")) + + if translation and len(translation) > 0: + # Update the line with the new translation + line = 'msgstr "{msg}"'.format(msg=translation) + + out.append(line + "\r\n") + + if save: + with open(filename, 'w') as output_file: + output_file.writelines(out) if __name__ == '__main__': @@ -40,6 +83,8 @@ if __name__ == '__main__': parser.add_argument('language', help='Language code', action='store') + parser.add_argument('--fake', help="Do not save updated translations", action='store_true') + args = parser.parse_args() language = args.language @@ -59,5 +104,5 @@ if __name__ == '__main__': sys.exit(1) # Ok, now we run the user through the translation file - manually_translate_file(PO_FILE) + manually_translate_file(PO_FILE, save=args.fake is not True) \ No newline at end of file From 275cd063e15c371c51d19d4f9655ab7240525975 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 3 May 2020 08:59:44 +1000 Subject: [PATCH 4/4] PEP fixes --- InvenTree/script/translate.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/InvenTree/script/translate.py b/InvenTree/script/translate.py index f92567dabd..407acb93c8 100644 --- a/InvenTree/script/translate.py +++ b/InvenTree/script/translate.py @@ -70,6 +70,10 @@ def manually_translate_file(filename, save=False): with open(filename, 'w') as output_file: output_file.writelines(out) + print("Translation done: written to", filename) + print("Run 'make translate' to rebuild translation data") + + if __name__ == '__main__': MY_DIR = os.path.dirname(os.path.realpath(__file__)) @@ -105,4 +109,3 @@ if __name__ == '__main__': # Ok, now we run the user through the translation file manually_translate_file(PO_FILE, save=args.fake is not True) - \ No newline at end of file