diff options
author | Ghostkeeper <rubend@tutanota.com> | 2019-07-26 15:23:04 +0300 |
---|---|---|
committer | Ghostkeeper <rubend@tutanota.com> | 2019-07-26 15:23:04 +0300 |
commit | 58c32f97a1ff34b99962d3422d71a5641ca000a1 (patch) | |
tree | 03a7e7ba44b9a079dc605eff410cca1257589fd9 /scripts | |
parent | a3611404d62b2607c8f84599e99a4696c98f7d83 (diff) |
Add documentation
Contributes to issue CURA-6663.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lionbridge_import.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/scripts/lionbridge_import.py b/scripts/lionbridge_import.py index 2ee9c0a937..64def0a220 100644 --- a/scripts/lionbridge_import.py +++ b/scripts/lionbridge_import.py @@ -42,10 +42,12 @@ def lionbridge_import(source: str) -> None: print(result) #DEBUG! Instead we should write this to a file. ## Gets the destination path to copy the translations for Cura to. +# \return Destination path for Cura. def destination_cura() -> str: return os.path.abspath(os.path.join(__file__, "..", "..", "resources", "i18n")) ## Gets the destination path to copy the translations for Uranium to. +# \return Destination path for Uranium. def destination_uranium() -> str: try: import UM @@ -58,6 +60,10 @@ def destination_uranium() -> str: raise Exception("Can't find Uranium. Please put UM on the PYTHONPATH or put the Uranium folder next to the Cura folder.") return os.path.abspath(os.path.join(UM.__file__, "..", "..", "resources", "i18n")) +## Merges translations from the source file into the destination file if they +# were missing in the destination file. +# \param source The contents of the source .po file. +# \param destination The contents of the destination .po file. def merge(source: str, destination: str) -> str: last_destination = { "msgctxt": "", @@ -86,7 +92,11 @@ def merge(source: str, destination: str) -> str: if last_destination["msgstr"] == "" and last_destination["msgid"] != "": #No translation for this yet! translation = find_translation(source, last_destination["msgctxt"], last_destination["msgid"]) -def find_translation(source: str, msgctxt, msgid): +## Finds a translation in the source file. +# \param source The contents of the source .po file. +# \param msgctxt The ctxt of the translation to find. +# \param msgid The id of the translation to find. +def find_translation(source: str, msgctxt: str, msgid: str) -> str: last_source = { "msgctxt": "", "msgid": "", |