<div align="center">
<h1>pycord-i18n</h1>
<h2>Internationalization for Pycord</h2>
</div>
## Key Features
- Translated responses
- Command name, description & option localization
- Based on user & server locale (no need for storage!)
## Installation
To install this extension, run the corresponding command:
```sh
# linux / macOS
python3 -m pip install pycord-i18n
# windows
python -m pip install pycord-i18n
```
## Usage
1. Setup your internationalization files just like [sample-german.json](https://github.com/Dorukyum/pycord-i18n/blob/main/sample-german.json).
Note that **all fields are optional** and **you can use whichever file format you want** as long as you pass the translations into I18n in the given format.
2. Load your files:
```py
import json
with open("sample-german.json", "r") as f:
german = json.load(f)
...
```
3. Create an I18n object:
```py
from pycord.i18n import I18n, _
i18n = I18n(bot, de=german)
# de is the locale code for German
# response translations will be based on the guild's locale, you can make the bot consider the user's locale too by using the following:
i18n = I18n(bot, consider_user_locale=True, de=german)
# all valid locales: da, de, en_GB, en_US, es_ES, fr, hr, it, lt, hu, nl, no, pl, pt_BR, ro, fi, sv_SE, vi, tr, cs, el, bg, ru, uk, hi, th, zh_CN, ja, zh_TW, ko
```
4. Internationalize your commands:
```py
@i18n.localize # command name and description localization
@bot.slash_command()
async def hello(ctx):
await ctx.respond(_("Hello, this sentence is in English"))
# "_()" does the translation
# if you don't want to use `@localize` on every command, simply use the following method after adding the commands to the bot:
i18n.localize_commands()
```
## Changelog
### v1.2.1
- Fixed an issue with Pycord v2.5 compatibility
### v1.2.0
- Added formatting support
### v1.1.0
- Added option localization support
Raw data
{
"_id": null,
"home_page": "https://github.com/Dorukyum/pycord-i18n",
"name": "pycord-i18n",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "Pycord",
"author": "Dorukyum",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/9e/91/fb127364195cf7365ebf82f0d4223adee5c40ca69e92266ad72629406692/pycord-i18n-1.2.1.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n <h1>pycord-i18n</h1>\n <h2>Internationalization for Pycord</h2>\n</div>\n\n## Key Features\n- Translated responses\n- Command name, description & option localization\n- Based on user & server locale (no need for storage!)\n\n## Installation\nTo install this extension, run the corresponding command:\n```sh\n# linux / macOS\npython3 -m pip install pycord-i18n\n\n# windows\npython -m pip install pycord-i18n\n```\n\n## Usage\n1. Setup your internationalization files just like [sample-german.json](https://github.com/Dorukyum/pycord-i18n/blob/main/sample-german.json).\nNote that **all fields are optional** and **you can use whichever file format you want** as long as you pass the translations into I18n in the given format.\n\n2. Load your files:\n```py\nimport json\n\nwith open(\"sample-german.json\", \"r\") as f:\n german = json.load(f)\n...\n```\n\n3. Create an I18n object:\n```py\nfrom pycord.i18n import I18n, _\n\ni18n = I18n(bot, de=german)\n# de is the locale code for German\n# response translations will be based on the guild's locale, you can make the bot consider the user's locale too by using the following:\ni18n = I18n(bot, consider_user_locale=True, de=german)\n\n# all valid locales: da, de, en_GB, en_US, es_ES, fr, hr, it, lt, hu, nl, no, pl, pt_BR, ro, fi, sv_SE, vi, tr, cs, el, bg, ru, uk, hi, th, zh_CN, ja, zh_TW, ko\n```\n\n4. Internationalize your commands:\n```py\n@i18n.localize # command name and description localization\n@bot.slash_command()\nasync def hello(ctx):\n await ctx.respond(_(\"Hello, this sentence is in English\"))\n # \"_()\" does the translation\n\n# if you don't want to use `@localize` on every command, simply use the following method after adding the commands to the bot:\ni18n.localize_commands()\n```\n\n## Changelog\n### v1.2.1\n- Fixed an issue with Pycord v2.5 compatibility\n\n### v1.2.0\n- Added formatting support\n\n### v1.1.0\n- Added option localization support\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Internationalization for Pycord",
"version": "1.2.1",
"project_urls": {
"Homepage": "https://github.com/Dorukyum/pycord-i18n",
"Source": "https://github.com/Dorukyum/pycord-i18n"
},
"split_keywords": [
"pycord"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "03faab5214a99e41be9ebbda442d706d5e80cadfaf948694718f56b53e4cac23",
"md5": "c9ddd86e9cd4cccbf5a4170b0d34be7b",
"sha256": "0e561b26d6a08e4d90a8bf20c2ca287ffa28353b7c44f9827d975847cc71c55f"
},
"downloads": -1,
"filename": "pycord_i18n-1.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c9ddd86e9cd4cccbf5a4170b0d34be7b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5095,
"upload_time": "2024-03-08T05:54:00",
"upload_time_iso_8601": "2024-03-08T05:54:00.427583Z",
"url": "https://files.pythonhosted.org/packages/03/fa/ab5214a99e41be9ebbda442d706d5e80cadfaf948694718f56b53e4cac23/pycord_i18n-1.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9e91fb127364195cf7365ebf82f0d4223adee5c40ca69e92266ad72629406692",
"md5": "3864dd61253af2fabc75e6dd1e97df4a",
"sha256": "3d2f5d2d53421d8efb00021ec6c27546aa7b243a8451159d6bb89c368739b9c7"
},
"downloads": -1,
"filename": "pycord-i18n-1.2.1.tar.gz",
"has_sig": false,
"md5_digest": "3864dd61253af2fabc75e6dd1e97df4a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4860,
"upload_time": "2024-03-08T05:54:02",
"upload_time_iso_8601": "2024-03-08T05:54:02.039655Z",
"url": "https://files.pythonhosted.org/packages/9e/91/fb127364195cf7365ebf82f0d4223adee5c40ca69e92266ad72629406692/pycord-i18n-1.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-08 05:54:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Dorukyum",
"github_project": "pycord-i18n",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pycord-i18n"
}