tradlib


Nametradlib JSON
Version 0.4 PyPI version JSON
download
home_pagehttps://github.com/Disk-MTH/Tradlib
SummaryA python library designed to allow an easy translation system for other projects
upload_time2023-05-28 13:25:13
maintainer
docs_urlNone
authorDisk_MTH
requires_python>=2.7
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Tradlib

For the overview of the library check [here](https://github.com/Disk-MTH/Tradlib/blob/master/README.md).

## Make translation files

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!

## Functions

 1. set_translations_files_path(full_path, flat_build, build_architecture)
 
This function is used to define the access path to the translation files  
Args:  
 - full_path (required): The full path to the folder containing the uncompiled translation files:
	 ```python
	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)

2. get_translations_files_path()

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.

3. set_translation_files_extension(extension)

This function set the extension to use for translations files.  The default extension is ".lang".
Args:  
 - extension (required): The extension you want to set

4. get_translation_files_extension()

This function return your selected extension for translation files. Default is ".lang".

5. load_translations_files()

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.

6. get_available_languages()

This function returns the list of available languages. If you don't have executed `load_translations_files`,  this will return an empty list.

7. get_translation(language, keys_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"
		}
	]
}
```


## License

All the files in this repository are completely free of rights (see the  [license](https://github.com/Disk-MTH/Tradlib/blob/master/diskmth/LICENSE.txt)) so you can grab the code and do whatever you want with them (just respect the  [license](https://github.com/Disk-MTH/Tradlib/blob/master/diskmth/LICENSE.txt)).

Thanks for reading and good development!

Disk_MTH

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Disk-MTH/Tradlib",
    "name": "tradlib",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=2.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Disk_MTH",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/96/3e/52c668ec746cc774c787181cd4c8b34b6a57839498295fb7f438032ffab7/tradlib-0.4.tar.gz",
    "platform": null,
    "description": "# Tradlib\r\n\r\nFor the overview of the library check [here](https://github.com/Disk-MTH/Tradlib/blob/master/README.md).\r\n\r\n## Make translation files\r\n\r\nTranslation 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:\r\n```\r\nexample.lang\r\n{\r\n\t\"language\": \"english\"\r\n}\r\n```\r\nIn the example above, after setting the path to the translation file and loading the file, the `get_available_languages` function will return ['english'].\r\n\r\n/!\\ If this key is missing, the translation file will be not detected!\r\n\r\n## Functions\r\n\r\n 1. set_translations_files_path(full_path, flat_build, build_architecture)\r\n \r\nThis function is used to define the access path to the translation files  \r\nArgs:  \r\n - full_path (required): The full path to the folder containing the uncompiled translation files:\r\n\t ```python\r\n\tfull_path=\"C:\\\\Users\\\\some_user\\\\Desktop\\\\dev\\\\Tradlib\"\r\n\t ```\r\n/!\\ 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)\r\n\r\n - flat_build (optional): Put true if all your translation files are at the root of your project when compiling otherwise leave false.\r\n \r\n - build_architecture (optional): The full path for your translation files from the compiled project root:\r\n\r\nIf you have this structure (bellow) the right argument will be `\"resources\\\\lang\"`\r\n```\r\nyour_project.exe\r\n\u2502   *.ddl\r\n\u2502   some_required_files  \r\n\u2502\r\n\u2514\u2500\u2500\u2500resources\r\n\t\u2502   some_picture.png\r\n\t\u2502   some_sounds.mp3\r\n\t\u2502\r\n\t\u2514\u2500\u2500\u2500lang\r\n\t\t\u2502   english.lang\r\n\r\n```\r\n/!\\ 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)\r\n\r\n2. get_translations_files_path()\r\n\r\nThis 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.\r\n\r\n3. set_translation_files_extension(extension)\r\n\r\nThis function set the extension to use for translations files.  The default extension is \".lang\".\r\nArgs:  \r\n - extension (required): The extension you want to set\r\n\r\n4. get_translation_files_extension()\r\n\r\nThis function return your selected extension for translation files. Default is \".lang\".\r\n\r\n5. load_translations_files()\r\n\r\nThis 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.\r\n\r\n6. get_available_languages()\r\n\r\nThis function returns the list of available languages. If you don't have executed `load_translations_files`,  this will return an empty list.\r\n\r\n7. get_translation(language, keys_list)\r\n\r\nThis 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.\r\nArgs:  \r\n - language (required): The language (among the list of available languages) in which you want a translation.\r\n\r\n - keys_list (required): The list of keys (in order) allowing access to the desired translation.\r\n\r\nFor the example bellow:\r\nfor  `quit` the right arg is `[\"text\", 0, \"quit\"]`\r\nfor  `title` the right arg is `[\"text\", 1, \"title\"]`\r\nfor  `button_reduce` the right arg is `[\"button\", 0, \"button_reduce\"]`\r\n```\r\nenglish.lang\r\n{\r\n\t\"language\": \"english\",\r\n\r\n\t\"text\": [\r\n\t\t{\r\n\t\t\t\"quit\": \"Quit\"\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"title\": \"Tradlib\"\r\n\t\t}\r\n\t],\r\n\t\r\n\t\"button\": [\r\n\t\t{\r\n\t\t\t\"button_reduce\": \"Reduce\"\r\n\t\t}\r\n\t]\r\n}\r\n```\r\n\r\n\r\n## License\r\n\r\nAll the files in this repository are completely free of rights (see the  [license](https://github.com/Disk-MTH/Tradlib/blob/master/diskmth/LICENSE.txt)) so you can grab the code and do whatever you want with them (just respect the  [license](https://github.com/Disk-MTH/Tradlib/blob/master/diskmth/LICENSE.txt)).\r\n\r\nThanks for reading and good development!\r\n\r\nDisk_MTH\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A python library designed to allow an easy translation system for other projects",
    "version": "0.4",
    "project_urls": {
        "Bug Tracker": "https://github.com/Disk-MTH/Tradlib/issues",
        "Homepage": "https://github.com/Disk-MTH/Tradlib"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bc272019c988b2b2264611c7ca2c5e558dcd190b272efa7e8cd7d4d3931b5897",
                "md5": "30b4db68a21774bbe37366d9ede8dbf9",
                "sha256": "5b327f0a591da2a4224df24878f368e0b9775846ac334541211ac180def5c371"
            },
            "downloads": -1,
            "filename": "tradlib-0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "30b4db68a21774bbe37366d9ede8dbf9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=2.7",
            "size": 5427,
            "upload_time": "2023-05-28T13:25:12",
            "upload_time_iso_8601": "2023-05-28T13:25:12.047489Z",
            "url": "https://files.pythonhosted.org/packages/bc/27/2019c988b2b2264611c7ca2c5e558dcd190b272efa7e8cd7d4d3931b5897/tradlib-0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "963e52c668ec746cc774c787181cd4c8b34b6a57839498295fb7f438032ffab7",
                "md5": "bb662ca7bb24bc0dfb01213178cbd386",
                "sha256": "fbc1fadd3cd2886d0813f42661a4449f83faaaa7d2190dd4a871da0a253b1945"
            },
            "downloads": -1,
            "filename": "tradlib-0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "bb662ca7bb24bc0dfb01213178cbd386",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.7",
            "size": 4523,
            "upload_time": "2023-05-28T13:25:13",
            "upload_time_iso_8601": "2023-05-28T13:25:13.759498Z",
            "url": "https://files.pythonhosted.org/packages/96/3e/52c668ec746cc774c787181cd4c8b34b6a57839498295fb7f438032ffab7/tradlib-0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-28 13:25:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Disk-MTH",
    "github_project": "Tradlib",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "tradlib"
}
        
Elapsed time: 0.06942s