Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
For the overview of the library check here.
Translation files must follow JSON formatting (which you can easily find on the internet). The name of the file is not important (it does not serve the identification of the language) on the other hand the extension of the file must correspond to that indicated with the function set_translation_files_extension
or be ".lang" (by default). To identify the language, a specific key must be present and the name of the language must be associated with it. Here is the minimum configuration for detecting a translation file:
example.lang
{
"language": "english"
}
In the example above, after setting the path to the translation file and loading the file, the get_available_languages
function will return ['english'].
/!\ If this key is missing, the translation file will be not detected!
This function is used to define the access path to the translation files
Args:
full_path="C:\\Users\\some_user\\Desktop\\dev\\Tradlib"
/!\ I recommend putting the path with "\\"
rather than "\"
because with "\"
python can believe that you are trying to put unicode characters. In addition, your paths may or may not end with "\\"
or "\"
it will not change anything ("C:\\Users\\some_user\\Desktop\\dev\\Tradlib"
and "C:\\Users\\some_user\\Desktop\\dev\\Tradlib\\"
are equal)
flat_build (optional): Put true if all your translation files are at the root of your project when compiling otherwise leave false.
build_architecture (optional): The full path for your translation files from the compiled project root:
If you have this structure (bellow) the right argument will be "resources\\lang"
your_project.exe
│ *.ddl
│ some_required_files
│
└───resources
│ some_picture.png
│ some_sounds.mp3
│
└───lang
│ english.lang
/!\ I recommend putting the path with "\\"
rather than "\"
because with "\"
python can believe that you are trying to put unicode characters. In addition, your paths may or may not end with "\\"
or "\"
it will not change anything ("resources\\lang"
and "resources\\lang\\"
are equal)
This function returns the path of your translation files. If you haven't setup this path with the set_translations_files_path
function, this will return the current work directory.
This function set the extension to use for translations files. The default extension is ".lang". Args:
This function return your selected extension for translation files. Default is ".lang".
This function loads your translation files. If you don't have executed set_translations_files_path
, translations files in the current work directory will be load.
This function returns the list of available languages. If you don't have executed load_translations_files
, this will return an empty list.
This function returns the translation associated with the list of keys given with arguments. To work, this function requires the execution of load_translations_files
otherwise you are looking in an empty list.
Args:
language (required): The language (among the list of available languages) in which you want a translation.
keys_list (required): The list of keys (in order) allowing access to the desired translation.
For the example bellow:
for quit
the right arg is ["text", 0, "quit"]
for title
the right arg is ["text", 1, "title"]
for button_reduce
the right arg is ["button", 0, "button_reduce"]
english.lang
{
"language": "english",
"text": [
{
"quit": "Quit"
},
{
"title": "Tradlib"
}
],
"button": [
{
"button_reduce": "Reduce"
}
]
}
All the files in this repository are completely free of rights (see the license) so you can grab the code and do whatever you want with them (just respect the license).
Thanks for reading and good development!
Disk_MTH
FAQs
A python library designed to allow an easy translation system for other projects
We found that tradlib demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.