Extract fluent keys from python code and organize them in .ftl files
Project description
FTL-Extract
Description
FTL-Extract is a Python package that extracts Fluent keys from .py files and generates .ftl file with extracted
keys.
🔥 Try fast-ftl-extract command.
It's Rust version of ftl extract command, that is 10-20 times faster than Python version.
Installation
Use the package manager pip to install FTL-Extract.
$ pip install FTL-Extract
Or use modern tool like UV to install FTL-Extract.
$ uv add --dev FTL-Extract
Usage
First of all, you should create locales directory in your project.
$ mkdir project_path/locales
Then, you can use the following command to extract keys from your code.
$ 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>.
# 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 extract command
$ 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.ftlfiles will be located.
📚 Additional arguments
-lor--language- add a new language to the project.-kor--i18n-keys- add additional i18n keys to the extractor.-Kor--i18n-keys-append- add additional i18n keys to the extractor and append them to the default list.-por--i18n-keys-prefix- add a prefix to the i18n keys. For example,self.i18n.<key>().-eor--exclude-dirs- exclude specific directories from the extraction process.-Eor--exclude-dirs-append- add more directories to exclude from the extraction process.-ior--ignore-attributes- ignore specific attributes of thei18n.*likei18n.set_locale.-Ior--append-ignore-attributes- add more attributes to ignore to the default list.--ignore-kwargs- ignore specific kwargs of the i18n_keys likewhen=...inaiogram_dialog.I18nFormat(..., when=...).--comment-junks- comments errored translations in the.ftlfile.--default-ftl-file- specify the default.ftlfile 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.-vor--verbose- print additional information about the process.--dry-run- run the command without making any changes to the files.
💁♂️ Explanation of the ftl stub command
$ ftl stub 'project_path/locales/<locale>' 'project_path/code_path'
project_path/locales/<locale>- path to the locales directory where the<locale>directory (e.g.en) contains.ftlfiles located.project_path/code_path- path to the directory where thestub.pyiwill be located.
FAQ
❓ - How to add more languages to the project ?
# 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 ?
# Here we extract ftl keys from i18n-keys like `LF`, `LazyProxy` and `L`
$ ftl extract project_path/code_path project_path/locales -K LF -K LazyProxy -K L
How I use FTL-Extract in most of my projects
$ fast-ftl-extract \
'app/bot' \
'app/bot/locales' \
-l 'en' \
-l 'uk' \
-K 'LF' \
-I 'core' \
-E './tests/*' \
--ignore-kwargs 'when' \
--comment-junks \
--comment-keys-mode 'comment' \
--verbose
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ftl_extract-0.9.0a5-py3-none-win_amd64.whl.
File metadata
- Download URL: ftl_extract-0.9.0a5-py3-none-win_amd64.whl
- Upload date:
- Size: 1.7 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a7d78b37f8c9f966580d1e2f77d3029e379ed75717b22d32dbb9250268568bd
|
|
| MD5 |
03449a4c95b74ab072c30144b58f8ed9
|
|
| BLAKE2b-256 |
c781b45583890cf1c6215b33b7ff42aaac9770fd55c5e130aba5513af6e90d68
|
Provenance
The following attestation bundles were made for ftl_extract-0.9.0a5-py3-none-win_amd64.whl:
Publisher:
pypi-release.yml on andrew000/FTL-Extract
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ftl_extract-0.9.0a5-py3-none-win_amd64.whl -
Subject digest:
3a7d78b37f8c9f966580d1e2f77d3029e379ed75717b22d32dbb9250268568bd - Sigstore transparency entry: 265278887
- Sigstore integration time:
-
Permalink:
andrew000/FTL-Extract@7910d645ae763dda6ba63804a622427640a7bd2e -
Branch / Tag:
refs/tags/v0.9.0a5 - Owner: https://github.com/andrew000
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@7910d645ae763dda6ba63804a622427640a7bd2e -
Trigger Event:
release
-
Statement type:
File details
Details for the file ftl_extract-0.9.0a5-py3-none-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: ftl_extract-0.9.0a5-py3-none-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.8 MB
- Tags: Python 3, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fc73fa8cca57198233cc5f7b4f38f457c995ab81134b41c75f53f56f83a29d6
|
|
| MD5 |
98a5b4d4f5b1486121e20143bd286003
|
|
| BLAKE2b-256 |
4997e8fdc4614c9b193043365f8febfae0c4567659dd9fd58a7dc22115c9b525
|
Provenance
The following attestation bundles were made for ftl_extract-0.9.0a5-py3-none-musllinux_1_2_x86_64.whl:
Publisher:
pypi-release.yml on andrew000/FTL-Extract
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ftl_extract-0.9.0a5-py3-none-musllinux_1_2_x86_64.whl -
Subject digest:
0fc73fa8cca57198233cc5f7b4f38f457c995ab81134b41c75f53f56f83a29d6 - Sigstore transparency entry: 265278913
- Sigstore integration time:
-
Permalink:
andrew000/FTL-Extract@7910d645ae763dda6ba63804a622427640a7bd2e -
Branch / Tag:
refs/tags/v0.9.0a5 - Owner: https://github.com/andrew000
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@7910d645ae763dda6ba63804a622427640a7bd2e -
Trigger Event:
release
-
Statement type:
File details
Details for the file ftl_extract-0.9.0a5-py3-none-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: ftl_extract-0.9.0a5-py3-none-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 1.7 MB
- Tags: Python 3, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f607958487ac5af20042b2f5ed481146d07dc6514bf6c2764a55237ffe3d31e
|
|
| MD5 |
87d389867eed92701eca35d613b76649
|
|
| BLAKE2b-256 |
fbb015fd41557f1ce4f94ee6850934d31f47945b3fae2070602420033f994cae
|
Provenance
The following attestation bundles were made for ftl_extract-0.9.0a5-py3-none-musllinux_1_2_aarch64.whl:
Publisher:
pypi-release.yml on andrew000/FTL-Extract
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ftl_extract-0.9.0a5-py3-none-musllinux_1_2_aarch64.whl -
Subject digest:
9f607958487ac5af20042b2f5ed481146d07dc6514bf6c2764a55237ffe3d31e - Sigstore transparency entry: 265278895
- Sigstore integration time:
-
Permalink:
andrew000/FTL-Extract@7910d645ae763dda6ba63804a622427640a7bd2e -
Branch / Tag:
refs/tags/v0.9.0a5 - Owner: https://github.com/andrew000
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@7910d645ae763dda6ba63804a622427640a7bd2e -
Trigger Event:
release
-
Statement type:
File details
Details for the file ftl_extract-0.9.0a5-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: ftl_extract-0.9.0a5-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 1.8 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
895a08fef28c22c91ae5dfae26597e8ed19fa9c4f1a8db2176708c258d823cfd
|
|
| MD5 |
074864d92b17c21e9bce5e053994b5f9
|
|
| BLAKE2b-256 |
338c45cc0b78b24ca81196c7a5952526f239459b68d2affc5f0202fc84c6d9ef
|
Provenance
The following attestation bundles were made for ftl_extract-0.9.0a5-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl:
Publisher:
pypi-release.yml on andrew000/FTL-Extract
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ftl_extract-0.9.0a5-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl -
Subject digest:
895a08fef28c22c91ae5dfae26597e8ed19fa9c4f1a8db2176708c258d823cfd - Sigstore transparency entry: 265278885
- Sigstore integration time:
-
Permalink:
andrew000/FTL-Extract@7910d645ae763dda6ba63804a622427640a7bd2e -
Branch / Tag:
refs/tags/v0.9.0a5 - Owner: https://github.com/andrew000
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@7910d645ae763dda6ba63804a622427640a7bd2e -
Trigger Event:
release
-
Statement type:
File details
Details for the file ftl_extract-0.9.0a5-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl.
File metadata
- Download URL: ftl_extract-0.9.0a5-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
- Upload date:
- Size: 1.7 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
782070d4f1655d61e6c15e67b8474e905fbddf4602cfbd3f3f7dfb91e2350a6b
|
|
| MD5 |
c5ddfee561422d138f2b7501ced8a963
|
|
| BLAKE2b-256 |
8f505ff8f7826048388931a428e95c804cb71343df8482f1785ddd54e0927cc7
|
Provenance
The following attestation bundles were made for ftl_extract-0.9.0a5-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl:
Publisher:
pypi-release.yml on andrew000/FTL-Extract
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ftl_extract-0.9.0a5-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl -
Subject digest:
782070d4f1655d61e6c15e67b8474e905fbddf4602cfbd3f3f7dfb91e2350a6b - Sigstore transparency entry: 265278891
- Sigstore integration time:
-
Permalink:
andrew000/FTL-Extract@7910d645ae763dda6ba63804a622427640a7bd2e -
Branch / Tag:
refs/tags/v0.9.0a5 - Owner: https://github.com/andrew000
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@7910d645ae763dda6ba63804a622427640a7bd2e -
Trigger Event:
release
-
Statement type:
File details
Details for the file ftl_extract-0.9.0a5-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: ftl_extract-0.9.0a5-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.6 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afacfce1403463f7ecdd9756b0b2bc1065848217b8cf76db38de5baeec716c3c
|
|
| MD5 |
5276d0d64eb6a4c2f3c404100f3827a2
|
|
| BLAKE2b-256 |
174f5df7d62fed86f840b752885566feffdd48146532b77bd98ab70249a5806c
|
Provenance
The following attestation bundles were made for ftl_extract-0.9.0a5-py3-none-macosx_11_0_arm64.whl:
Publisher:
pypi-release.yml on andrew000/FTL-Extract
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ftl_extract-0.9.0a5-py3-none-macosx_11_0_arm64.whl -
Subject digest:
afacfce1403463f7ecdd9756b0b2bc1065848217b8cf76db38de5baeec716c3c - Sigstore transparency entry: 265278907
- Sigstore integration time:
-
Permalink:
andrew000/FTL-Extract@7910d645ae763dda6ba63804a622427640a7bd2e -
Branch / Tag:
refs/tags/v0.9.0a5 - Owner: https://github.com/andrew000
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@7910d645ae763dda6ba63804a622427640a7bd2e -
Trigger Event:
release
-
Statement type:
File details
Details for the file ftl_extract-0.9.0a5-py3-none-macosx_10_13_x86_64.whl.
File metadata
- Download URL: ftl_extract-0.9.0a5-py3-none-macosx_10_13_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: Python 3, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f194582f7aeed9ddd1e7e66121dcc8f710eeb83f2907c588d41d110907cedf36
|
|
| MD5 |
11ff5f84eb59cdc541ad38cb22ed14ec
|
|
| BLAKE2b-256 |
51a2b1d127c478ec5041cf82dd8e1f3c25cf275aca2914692cd208b4ea0f314f
|
Provenance
The following attestation bundles were made for ftl_extract-0.9.0a5-py3-none-macosx_10_13_x86_64.whl:
Publisher:
pypi-release.yml on andrew000/FTL-Extract
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ftl_extract-0.9.0a5-py3-none-macosx_10_13_x86_64.whl -
Subject digest:
f194582f7aeed9ddd1e7e66121dcc8f710eeb83f2907c588d41d110907cedf36 - Sigstore transparency entry: 265278900
- Sigstore integration time:
-
Permalink:
andrew000/FTL-Extract@7910d645ae763dda6ba63804a622427640a7bd2e -
Branch / Tag:
refs/tags/v0.9.0a5 - Owner: https://github.com/andrew000
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@7910d645ae763dda6ba63804a622427640a7bd2e -
Trigger Event:
release
-
Statement type: