Skip to main content

Extracts FTL files from a directory and outputs them to a directory

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 .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.
  • -K or --i18n-keys-append - add additional i18n keys to the extractor and append them to the default list.
  • -p or --i18n-keys-prefix - add a prefix to the i18n keys. For example, self.i18n.<key>().
  • -e or --exclude-dirs - exclude specific directories from the extraction process.
  • -E or --exclude-dirs-append - add more directories to exclude from the extraction process.
  • -i or --ignore-attributes - ignore specific attributes of the i18n.* like i18n.set_locale.
  • -I or --append-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.
  • -v or --verbose - print additional information about the process.
  • --dry-run - run the command without making any changes to the files.

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 `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

$ 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

But now I move my projects to fast-ftl-extract command.


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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ftl_extract-0.9.0a0-py3-none-win_amd64.whl (2.0 MB view details)

Uploaded Python 3Windows x86-64

ftl_extract-0.9.0a0-py3-none-musllinux_1_2_x86_64.whl (2.1 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

ftl_extract-0.9.0a0-py3-none-musllinux_1_2_aarch64.whl (1.9 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

ftl_extract-0.9.0a0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (2.1 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

ftl_extract-0.9.0a0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (1.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

ftl_extract-0.9.0a0-py3-none-macosx_11_0_arm64.whl (1.8 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

ftl_extract-0.9.0a0-py3-none-macosx_10_13_x86_64.whl (2.0 MB view details)

Uploaded Python 3macOS 10.13+ x86-64

File details

Details for the file ftl_extract-0.9.0a0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for ftl_extract-0.9.0a0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 0d8c449e8034aa09282655fe43ec4c866ddda7955422caeaa8b0ec98bd2468ff
MD5 b81b8c56d624d190d6f385df787dae01
BLAKE2b-256 dfd558e4fe3911a4c44576509c7b9b059da6343d82b9872f919367539c1a8d6a

See more details on using hashes here.

Provenance

The following attestation bundles were made for ftl_extract-0.9.0a0-py3-none-win_amd64.whl:

Publisher: pypi-release.yml on andrew000/FTL-Extract

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ftl_extract-0.9.0a0-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ftl_extract-0.9.0a0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0460aeeb0f66f7741e4d9922ce260547ceb655926c82e5897b6f5ec630e2e8d9
MD5 cf8f85c2241e420b0f45c8ced1e53efb
BLAKE2b-256 4889e75962a3bf52c03e3632a5b012ca27cfb5e53385d2eac3cd343f4f9c9158

See more details on using hashes here.

Provenance

The following attestation bundles were made for ftl_extract-0.9.0a0-py3-none-musllinux_1_2_x86_64.whl:

Publisher: pypi-release.yml on andrew000/FTL-Extract

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ftl_extract-0.9.0a0-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for ftl_extract-0.9.0a0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 147cc9bdba673cdb69c89ddaf51d02cf3086211ebf5ec9edcae01af8dd2aede7
MD5 1de5f4642543ad06d6a05f7d09ab99e7
BLAKE2b-256 d47de852ba7267602cba4bf196cd38d746505fe2bec82d637c8ec8610ca6a200

See more details on using hashes here.

Provenance

The following attestation bundles were made for ftl_extract-0.9.0a0-py3-none-musllinux_1_2_aarch64.whl:

Publisher: pypi-release.yml on andrew000/FTL-Extract

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ftl_extract-0.9.0a0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for ftl_extract-0.9.0a0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 1171aa1532776ab080ab67562ac185a8880edc8db8f6965de546dfa2a3ed6515
MD5 564460ef866271b07d0042acd6f2726b
BLAKE2b-256 a897d9da67895d7178c794586076c434ffed2bdb7c4a293759d55bd36f2fe71c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ftl_extract-0.9.0a0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl:

Publisher: pypi-release.yml on andrew000/FTL-Extract

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ftl_extract-0.9.0a0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for ftl_extract-0.9.0a0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 f02c8ed9449b88d8e34e572ee5c1f246c30d72eab35eb97448c1127c07131e50
MD5 35e580272044a98fab07cbc0e3750b02
BLAKE2b-256 51fd9d986d0569a732fbac6f97ff7da422165b27f76dd0fb50934a5938a8c29c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ftl_extract-0.9.0a0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl:

Publisher: pypi-release.yml on andrew000/FTL-Extract

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ftl_extract-0.9.0a0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ftl_extract-0.9.0a0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 76b65837902b2112ffd79dbd40051fa6fad8ee283616a750789485c954ae9156
MD5 d9dae7965d086e6d6cf85f369ad67e15
BLAKE2b-256 baf3691363e8ad89ae9d1bc694ccc4dc9dbe93bdf84ac4173d3fe914906eef33

See more details on using hashes here.

Provenance

The following attestation bundles were made for ftl_extract-0.9.0a0-py3-none-macosx_11_0_arm64.whl:

Publisher: pypi-release.yml on andrew000/FTL-Extract

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ftl_extract-0.9.0a0-py3-none-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for ftl_extract-0.9.0a0-py3-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0f2aadb6b55f874c72a3a28544a52fda9e60e82cc0cfbd2c07229934d42a390f
MD5 868bd35ad444b305cb7e308e7d5c8077
BLAKE2b-256 2dc33fa13616ba5a43d7addb8953b2f8bc15f7bca868b5554bed2ba21909d1c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for ftl_extract-0.9.0a0-py3-none-macosx_10_13_x86_64.whl:

Publisher: pypi-release.yml on andrew000/FTL-Extract

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page