Name | FTL-Extract JSON |
Version |
0.5.0
JSON |
| download |
home_page | None |
Summary | Extracts FTL files from a directory and outputs them to a directory |
upload_time | 2024-12-26 23:15:18 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
ftl
ftl-extract
ftl-extractor
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# FTL-Extract
## Description
FTL-Extract is a Python package that extracts Fluent keys from .py files and generates a .ftl file with extracted keys.
***
## Installation
Use the package manager [pip](https://pip.pypa.io/en/stable) to install FTL-Extract.
```shell
$ pip install FTL-Extract
```
Or add it to your `pyproject.toml` and run `poetry update`
***
## Usage
First of all, you should create locales directory in your project.
```shell
$ mkdir project_path/locales
```
Then, you can use the following command to extract keys from your code.
```shell
$ ftl_extract project_path/code_path project_path/locales
```
By default, FTL-Extract will create a directory named `en` and put all keys into `_default.ftl` file.
In some cases, you may want to extract keys to specific `.ftl` files.
So, there is new keyword argument `_path` in `i18n.get` and `i18n.<key>`.
```python
# Before
i18n.get("key-1", arg1="value1", arg2="value2")
# After
i18n.get("key-1", arg1="value1", arg2="value2", _path="dir/ftl_file.ftl")
# Also
i18n.key_1(arg1="value1", arg2="value2", _path="dir/ftl_file.ftl")
# Or
i18n.some.key_1(arg1="value1", arg2="value2", _path="dir/ftl_file.ftl")
```
***
## 💁♂️ Explanation of the `ftl-extractor` command
```shell
$ ftl_extract project_path/code_path project_path/locales
```
- `project_path/code_path` - path to the project directory where the code is located.
- `project_path/locales` - path to the project directory where the `.ftl` files will be located.
### 📚 Additional arguments
- `-l` or `--language` - add a new language to the project.
- `-k` or `--i18n_keys` - add additional i18n keys to the extractor.
- `--ignore-attributes` - ignore specific attributes of the `i18n.*` like `i18n.set_locale`.
- `-a` or `--expand-ignore-attributes` - add more attributes to ignore to the default list.
- `--ignore-kwargs` - ignore specific kwargs of the i18n_keys like `when=...` in
`aiogram_dialog.I18nFormat(..., when=...)`.
- `--comment-junks` - comments errored translations in the `.ftl` file.
- `--default-ftl-file` - specify the default `.ftl` file name.
- `--comment-keys-mode` - specify the comment keys mode. It will comment keys that are not used in the code or print
warnings about them. Available modes: `comment`, `warn`.
***
## FAQ
#### ❓ - How to add more languages to the project ?
```shell
# Here we add 3 languages: English, Ukrainian and Polish
$ ftl_extract project_path/code_path project_path/locales -l en -l uk -l pl
```
#### ❓ - How to detect another i18n keys like `LazyProxy` or `L` ?
```shell
# Here we extract ftl keys from i18n-keys like `i18n`, `LF`, `LazyProxy` and `L`
$ ftl_extract project_path/code_path project_path/locales -k i18n -k LF -k LazyProxy -k L
```
***
## How I use FTL-Extract in most of my projects
```shell
$ ftl_extract \
'./app/bot' \
'./app/bot/locales' \
-l 'en' \
-l 'uk' \
-l 'pl' \
-l 'de' \
-l 'ja' \
-k 'i18n' \
-k 'L' \
-k 'LF' \
-k 'LazyProxy' \
-a 'core' \
--comment-junks \
--comment-keys-mode 'comment'
```
***
## Contributing
Pull requests are welcome. For major changes, please open an issue first
to discuss what you would like to change.
Please make sure to update tests as appropriate.
Raw data
{
"_id": null,
"home_page": null,
"name": "FTL-Extract",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "ftl, ftl-extract, ftl-extractor",
"author": null,
"author_email": "andrew000 <help@kusbot.com>",
"download_url": "https://files.pythonhosted.org/packages/92/83/237ef1a3052ff8447067259786270d79272707dfdd3bc99fa861699794fc/ftl_extract-0.5.0.tar.gz",
"platform": null,
"description": "# FTL-Extract\n\n## Description\n\nFTL-Extract is a Python package that extracts Fluent keys from .py files and generates a .ftl file with extracted keys.\n\n***\n\n## Installation\n\nUse the package manager [pip](https://pip.pypa.io/en/stable) to install FTL-Extract.\n\n```shell\n$ pip install FTL-Extract\n```\n\nOr add it to your `pyproject.toml` and run `poetry update`\n\n***\n\n## Usage\n\nFirst of all, you should create locales directory in your project.\n\n```shell\n$ mkdir project_path/locales\n```\n\nThen, you can use the following command to extract keys from your code.\n\n```shell\n$ ftl_extract project_path/code_path project_path/locales\n```\n\nBy default, FTL-Extract will create a directory named `en` and put all keys into `_default.ftl` file.\n\nIn some cases, you may want to extract keys to specific `.ftl` files.\nSo, there is new keyword argument `_path` in `i18n.get` and `i18n.<key>`.\n\n```python\n# Before\ni18n.get(\"key-1\", arg1=\"value1\", arg2=\"value2\")\n\n# After\ni18n.get(\"key-1\", arg1=\"value1\", arg2=\"value2\", _path=\"dir/ftl_file.ftl\")\n\n# Also\ni18n.key_1(arg1=\"value1\", arg2=\"value2\", _path=\"dir/ftl_file.ftl\")\n\n# Or\ni18n.some.key_1(arg1=\"value1\", arg2=\"value2\", _path=\"dir/ftl_file.ftl\")\n```\n\n***\n\n## \ud83d\udc81\u200d\u2642\ufe0f Explanation of the `ftl-extractor` command\n\n```shell\n$ ftl_extract project_path/code_path project_path/locales\n```\n\n- `project_path/code_path` - path to the project directory where the code is located.\n- `project_path/locales` - path to the project directory where the `.ftl` files will be located.\n\n### \ud83d\udcda Additional arguments\n\n- `-l` or `--language` - add a new language to the project.\n- `-k` or `--i18n_keys` - add additional i18n keys to the extractor.\n- `--ignore-attributes` - ignore specific attributes of the `i18n.*` like `i18n.set_locale`.\n- `-a` or `--expand-ignore-attributes` - add more attributes to ignore to the default list.\n- `--ignore-kwargs` - ignore specific kwargs of the i18n_keys like `when=...` in\n `aiogram_dialog.I18nFormat(..., when=...)`.\n- `--comment-junks` - comments errored translations in the `.ftl` file.\n- `--default-ftl-file` - specify the default `.ftl` file name.\n- `--comment-keys-mode` - specify the comment keys mode. It will comment keys that are not used in the code or print\n warnings about them. Available modes: `comment`, `warn`.\n\n***\n\n## FAQ\n\n#### \u2753 - How to add more languages to the project ?\n\n```shell\n# Here we add 3 languages: English, Ukrainian and Polish\n$ ftl_extract project_path/code_path project_path/locales -l en -l uk -l pl\n```\n\n#### \u2753 - How to detect another i18n keys like `LazyProxy` or `L` ?\n\n```shell\n# Here we extract ftl keys from i18n-keys like `i18n`, `LF`, `LazyProxy` and `L`\n$ ftl_extract project_path/code_path project_path/locales -k i18n -k LF -k LazyProxy -k L\n```\n\n***\n\n## How I use FTL-Extract in most of my projects\n\n```shell\n$ ftl_extract \\\n './app/bot' \\\n './app/bot/locales' \\\n -l 'en' \\\n -l 'uk' \\\n -l 'pl' \\\n -l 'de' \\\n -l 'ja' \\\n -k 'i18n' \\\n -k 'L' \\\n -k 'LF' \\\n -k 'LazyProxy' \\\n -a 'core' \\\n --comment-junks \\\n --comment-keys-mode 'comment'\n```\n\n***\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first\nto discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n",
"bugtrack_url": null,
"license": null,
"summary": "Extracts FTL files from a directory and outputs them to a directory",
"version": "0.5.0",
"project_urls": {
"Homepage": "https://github.com/andrew000/FTL-Extract",
"Issues": "https://github.com/andrew000/FTL-Extract/issues",
"Repository": "https://github.com/andrew000/FTL-Extract"
},
"split_keywords": [
"ftl",
" ftl-extract",
" ftl-extractor"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "230c2b7e01766772412f74c3fdb7240fa1d41ca99a5bc615df8aa44eaec8cc23",
"md5": "8267f62422e17a01278b1121fb931845",
"sha256": "e062dcd5525dbca9f897be96f7b1e7dbf97965aeb32df9fea8df438fc4276630"
},
"downloads": -1,
"filename": "ftl_extract-0.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8267f62422e17a01278b1121fb931845",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 15183,
"upload_time": "2024-12-26T23:15:16",
"upload_time_iso_8601": "2024-12-26T23:15:16.092473Z",
"url": "https://files.pythonhosted.org/packages/23/0c/2b7e01766772412f74c3fdb7240fa1d41ca99a5bc615df8aa44eaec8cc23/ftl_extract-0.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "9283237ef1a3052ff8447067259786270d79272707dfdd3bc99fa861699794fc",
"md5": "f03536263c1bf2feb57edc5398a1e510",
"sha256": "58ae161125cee0008458cf107eacac17ab7f1d399dd4c21838be5980c7cc9d51"
},
"downloads": -1,
"filename": "ftl_extract-0.5.0.tar.gz",
"has_sig": false,
"md5_digest": "f03536263c1bf2feb57edc5398a1e510",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 76747,
"upload_time": "2024-12-26T23:15:18",
"upload_time_iso_8601": "2024-12-26T23:15:18.546596Z",
"url": "https://files.pythonhosted.org/packages/92/83/237ef1a3052ff8447067259786270d79272707dfdd3bc99fa861699794fc/ftl_extract-0.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-26 23:15:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "andrew000",
"github_project": "FTL-Extract",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "ftl-extract"
}