Skip to content

Latest commit

 

History

History
72 lines (72 loc) · 6.55 KB

TRANSLATING.md

File metadata and controls

72 lines (72 loc) · 6.55 KB

I changed all of my Python modules and created new classes as utilities to use in them.
The classes are these:
Date
File
Folder
Global_Switches
Input
Language
Text

I also changed the way that the language works and added a "Texts.json" file on each of the module folders in the "App Text Files" folder.
You can now translate my modules, translate them by adding the ISO 639-1 language code to the "Texts.json" of the module you want to translate.

Each text key has its English text in lowercase with spaces replaced by underscores and is a JSON dictionary containing the text in the languages with the ISO 639-1 language code as the key.
Example:

"this_is_a_text": {
	"en": "This is a text",
	"pt": "Isto é um texto",
	"es": "Este es un texto",
	"fr": "Établi",
	"it": "Creato",
	"jp": "提起されました (Teiki sa remashita)",
	"no": "ble reist"
}

The "Texts.json" files contain the text of each module in the two languages that I know, Portuguese and English.
If you want to translate my modules, simply clone this repository, and create a text file called "Settings.txt" on the root folder of the clone folder.
Open the "Texts.json" file of the module that you want to translate, and start translating the JSON lines to your language, using the ISO 639-1 language code of the language of the translated text as a key.
The translated texts must follow the exact capitalization and spaces of the English text, and have other characters that are not letters or numbers too, like the format one "{}".
Some texts have ", title()" in them, which means that it is only a word, and it will have its first letter in uppercase, if ", title()" is not present, then the first letter is in lowercase.
Phrases do not need ", title()" in their text key, they can have lower or uppercase first letters.

Some texts are lists, they have "type: list" after their text key, in this case, copy the whole English text list, change the key to the language you are translating to, and translate all items.
Some text lists can have two mixed languages, like "text_key, type: list, en - pt", in that case, the text is the English text followed by a space, dash, space, and then the text of the translated language.
The two language codes are always at the end of the whole text key.
You need to copy the whole text dictionary, and modify the "pt" part of the text key to the ISO 639-1 language code of the language you are translating to.
Some texts are dicts (dictionaries), like this: "text_key, type: dict, en: pt", in this case, the "en" part is the keys, and the "pt" part is the values.
You need to copy the whole text dictionary, like in lists, and change the "pt" part to the ISO 639-1 language of the language you are translating to.
If the English text contains "{}", those characters can exist in the text key, but no other non-letter and non-number characters may exist in the text key, such as "(", or ")".
There can also be texts of type "format" and type "regex", to better describe the purpose of the text.
The texts must contain no dots at the end of the text, except those with the "explanation" type.
Those texts with the "explanation" type can be long, have the "\n" text to add line breaks, and can have dots at the end.
They always have the first line of the text as their text key.
Some languages can have "masculine" and "feminine" text for each word, such as in Portuguese, "created" translates to "criado" (masculine) and "criada" (feminine).
If the language you are translating my module to also has words for each gender, you can make the key of your language code a dictionary, like this:

"created": {
	"en": "created",
	"pt": {
		"masculine": "criado",
		"feminine": "criada"
	}
}

The key "pt" is a dictionary, containing the "masculine" key for the masculine text, and the "feminine" key for the feminine text.
The Language class will always choose the "masculine" key as the default text when creating the "language_texts" dictionary.
And can be accessed like this: "language_texts["text_key"]", the class will create two gender keys on the language_texts dictionary.
language_texts["text_key, masculine"]
language_texts["text_key, feminine"]

And the masculine and feminine keys can also be accessed as the sub-key of the text key, like this: language_texts["text_key"]["masculine"].

All of the utility classes are imported at the start of the main class of each module.
The main class have the name of the module name, and is a sub-folder of the module folder, like "Watch_History.Watch_History".
All main classes of all of the modules have three main methods, "Define_Basic_Variables()", to define Global_Switches, import languages, user language, folders from Folder class, and current date from Date class.
"Define_Module_Folder", to define the module folder on the "App Text Files" folder and its "Texts.json" file.
And "Define_Texts", to use the "JSON_To_Python" method of the Language class to read the "Texts.json" file, and use the "Item" method of the "Language" class to create the "language_texts" dictionary.

Soon I will make a module on the root folder called "Translator_Helper.py", to help you translate my modules to your language.
Allowing you to choose your native language or the language you know, to translate to, choose a module to translate, and show all of the English texts for you to translate.
For you to translate my modules, you need to know English first, to understand the English texts of the modules and translate them.