No project description provided
Project description
rustfluent
A Python interface to the Rust Fluent Library.
This project is a small shim around fluent-rs, so it can be used from Python.
[!WARNING] This package is under active development, and breaking changes may be released at any time. Be sure to pin to specific versions if you're using this package in a production environment.
Prerequisites
This package supports:
- Python 3.11
- Python 3.12
Installation
pip install rustfluent
Usage
import rustfluent
# First load a bundle
bundle = rustfluent.Bundle(
"en",
[
# Multiple FTL files can be specified. Entries in later
# files overwrite earlier ones.
"en.ftl",
],
)
# Fetch a translation
assert bundle.get_translation("hello-world") == "Hello World"
# Fetch a translation that includes variables
assert bundle.get_translation("hello-user", variables={"user": "Bob"}) == "Hello, \u2068Bob\u2069"
The Unicode characters around "Bob" in the above example are for Unicode bidirectional handling.
API reference
Bundle
class
A set of translations for a specific language.
import rustfluent
bundle = rustfluent.Bundle(
language="en-US",
ftl_files=[
"/path/to/messages.ftl",
"/path/to/more/messages.ftl",
],
)
Parameters
Name | Type | Description |
---|---|---|
language |
str |
Unicode Language Identifier for the language. |
ftl_files |
list[str] |
Full paths to the FTL files containing the translations. Entries in later files overwrite earlier ones. |
strict |
bool , optional |
In strict mode, a ParserError will be raised if there are any errors in the file. In non-strict mode, invalid Fluent messages will be excluded from the Bundle. |
Raises
FileNotFoundError
if any of the FTL files could not be found.rustfluent.ParserError
if any of the FTL files contain errors (strict mode only).
Bundle.get_translation
>>> bundle.get_translation(identifier="hello-world")
"Hello, world!"
>>> bundle.get_translation(identifier="hello-user", variables={"user": "Bob"})
"Hello, Bob!"
Parameters
Name | Type | Description |
---|---|---|
identifier |
str |
The identifier for the Fluent message. |
variables |
dict[str, str] , optional |
Any variables to be passed to the Fluent message. |
Return value
str
: the translated message.
Raises
ValueError
if the message could not be found or has no translation available.
Contributing
See Contributing.
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 Distribution
rustfluent-0.1.0a2.tar.gz
(15.7 kB
view hashes)
Built Distributions
Close
Hashes for rustfluent-0.1.0a2-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a360c0b4510ded55562f9fe1f5a4eb82f10cbe94b2fc8b02cb8d63fc08b76c0d |
|
MD5 | 00eed482ecda32db631bd2a88f21242b |
|
BLAKE2b-256 | 7f87ac9b3d3f4d5df3b09030c4bf84e5fdf8bd8a3d39847ad90f1259f31f59c9 |
Close
Hashes for rustfluent-0.1.0a2-cp312-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7ee37ac4d534b39ffa577c8445c7eeee611eaf519386327181ffebd8ecbeb5f |
|
MD5 | 0ff2e1f9c7a6b9ee08d672892b375d1e |
|
BLAKE2b-256 | db93747458487708c2e19fd76f673cf390af29165acbbec9c0b3979bc532305b |
Close
Hashes for rustfluent-0.1.0a2-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90f8276c43da83f652740b225c8976bc395fa782e10a397b84416ca673faba9e |
|
MD5 | 6f1e3494fdcfc492bba96b561acd9992 |
|
BLAKE2b-256 | 82ce16f1170b713d6d5aade6fd38fde28304d70212c01ad7ae5374da687a7ba4 |
Close
Hashes for rustfluent-0.1.0a2-cp312-cp312-musllinux_1_2_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d8cb7353860a0cae827573ed0b2ecaa1776853f0dc58669db9c96773e12f930 |
|
MD5 | 3567efab5862e8b31c0c9880376f624a |
|
BLAKE2b-256 | 78b0da880b2bad1f80e5ed4a6b09efb0ff3acf0004f56d107ab22995b8b9cbbd |
Close
Hashes for rustfluent-0.1.0a2-cp312-cp312-musllinux_1_2_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af7f41ae9ae267efc9572440a1fce6c31ae60374ba33fab5552e121a8d14ed70 |
|
MD5 | 377ce0ee242e4f490758ffe1e9336a4c |
|
BLAKE2b-256 | 403dd4a50ebdf36f4b2fc1a9a86693d202a3a3f8e01f1e412e55450ccc6b9859 |
Close
Hashes for rustfluent-0.1.0a2-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a403420fe2da2a90970b344962c2c1383e13cb33461cd505ce6493f1c210123 |
|
MD5 | 9109718c9e0c38af3a71bec717c5a8bc |
|
BLAKE2b-256 | 8844d0618a56a1cdfa55d62aafb68d42e6e6780cd49293f8d584a349aa3f6c15 |
Close
Hashes for rustfluent-0.1.0a2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc6eae4261563ad606c27fea4ec0d3343b9a8e77f9f032bd25956c49e7b7169d |
|
MD5 | d85368445cf4f8bf2004e51104d5f0a0 |
|
BLAKE2b-256 | 996091300798dbd3e62639f7fd55d8f4fb47581c8524a6767085441de8d1d561 |
Close
Hashes for rustfluent-0.1.0a2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3777063195b17f00fb996c6bb143b2d497794ef08141846fa2356cf5da65c87b |
|
MD5 | 93abe040909cbc8aa4235b3348617962 |
|
BLAKE2b-256 | cb7d74f3f29b6792a4522e35dc6a662fb481180f42748430df664b1b469498d3 |
Close
Hashes for rustfluent-0.1.0a2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da7170829aaaf0bfeebb8bf4bb0f3033a8d56d43f4d23534fd30f5ad633ce5eb |
|
MD5 | 910f271a32d8b786607deee0af92eee7 |
|
BLAKE2b-256 | 57ddbb0787c8760baed88d394ce1b4bae1fb0e157c1aef49c7626429adeddfd4 |
Close
Hashes for rustfluent-0.1.0a2-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97517fe41e0cae0a839a476064589b68eff50907348e94b2ecec3e938165abe7 |
|
MD5 | ae412a9d45672644da8f1419448f2caa |
|
BLAKE2b-256 | 7c4f2187b3e2cc547aab505dcfa2362242cddfab85b82645630f7c5cc33b1044 |
Close
Hashes for rustfluent-0.1.0a2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b82a65208f1a5df06fda2768aac6d42306e2f1f65bf9bf1f18d29b3bb256610 |
|
MD5 | 24333a85b06913a988ed04ed994e7b32 |
|
BLAKE2b-256 | f21c5da0db61a324b1ccf188e35f965e98e840be9dd3f26c675b440ea244d0a2 |
Close
Hashes for rustfluent-0.1.0a2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe927f7a69f2f402b8b284b2f4d66d12d84a27b908b0da64f7ced2289e5bbd02 |
|
MD5 | 24e912b66b15e565d8973a13da67ccb4 |
|
BLAKE2b-256 | c277722de2e9e25b16ae4839954606ac568bdb2b47aba78c51fc57c424187b70 |
Close
Hashes for rustfluent-0.1.0a2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4713af86eea556ef6f483e2a0a04aace01d930ddcceeb0d502c406a36ad29f15 |
|
MD5 | 83d9bac949c31524791ba746b89942a7 |
|
BLAKE2b-256 | 0ac620685931443b3f7ba8590c40eaae1bf5a504e4a8703504435c067b3c6990 |
Close
Hashes for rustfluent-0.1.0a2-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a3578e904ad6a6c428870f7432938b2c5a37538c26d0a71ef26789d1d8190a1 |
|
MD5 | 326ce6306760b1a9061d86021b0a7c61 |
|
BLAKE2b-256 | 48d5364b4f05a3af3192caac0363d18dc2035e5c053514bf1a83d37bd5b6fa63 |
Close
Hashes for rustfluent-0.1.0a2-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d357abd9a9500f45b8261fe0d4b5345961bd04aa7bfe375f85812c352bf5927c |
|
MD5 | 0177d1f67fa5466aecae9c207e0abadd |
|
BLAKE2b-256 | 3583b9ab6a7cb411250d65a2df78668784b7b446af8e8f8a327c84c35728a408 |
Close
Hashes for rustfluent-0.1.0a2-cp311-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81f2caf3478376af76796f5b073b7ef56301b566d0963521254c4d6e8e7dd409 |
|
MD5 | 2ff8b68ea0b32e33cc04fd8d72741066 |
|
BLAKE2b-256 | 681aff1cc8f17a37f11af0415dcebaaf4db7d84877be85c00eed3d1daeb58f35 |
Close
Hashes for rustfluent-0.1.0a2-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77e023915db584d00569160223ac4c03891016ec587c2af6b15342fa2fe0fab3 |
|
MD5 | be2a9c980f372f2eecc165720b4e17bd |
|
BLAKE2b-256 | a280773abcad3292c0ac0120b995d50fa5edfa44f12e71d154f19e79be4bf44f |
Close
Hashes for rustfluent-0.1.0a2-cp311-cp311-musllinux_1_2_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b09bd0534a9f01143c97ac7071019e7361817271a17fa4eec3fce2736b5384b |
|
MD5 | 8226fa76d1eb08bbc219e9f995683646 |
|
BLAKE2b-256 | af7d873fd654ea040dc942dea2c96606fd3ca362868f0c39475de545554becc2 |
Close
Hashes for rustfluent-0.1.0a2-cp311-cp311-musllinux_1_2_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30a5aaed010ee00bec7aa9d4706720b5f42b43d8f7417d5021553172b3abf359 |
|
MD5 | 7edec4a3e77ba5fdfaf261a7b292707d |
|
BLAKE2b-256 | a7cc9c12f2aa46cffe66bf16dd589b35afb915dea7321309e480ce3c282de9ea |
Close
Hashes for rustfluent-0.1.0a2-cp311-cp311-musllinux_1_2_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ef74c4a6772991011fc9803d66e00697385ef2ace54964e9230cf7f5076a056 |
|
MD5 | a5a6b249a25afc9a1df6d31d1e512f7a |
|
BLAKE2b-256 | ee326197761b68b596f5e322869035aa09376ffff96f618e0fa37663d38a664b |
Close
Hashes for rustfluent-0.1.0a2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73aa8f7ea64261bf97ab8bd8678af7d284a6afce9e04194d598807ac6de049f2 |
|
MD5 | 372d371e57364b3cbd93f0de9f71f67f |
|
BLAKE2b-256 | f129950e63e51fdedd0614a80d0830bff96cbfc075d3e30a914b9822186c3ac8 |
Close
Hashes for rustfluent-0.1.0a2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d22f43ec31005ef13cae0558e17816052f6562b56f1422d6129252a6c9db02b |
|
MD5 | f11e77f8493f202022d16a086fa39e88 |
|
BLAKE2b-256 | a33f86a8552d9f428e8e2e79e10b605ad08c9ed9fce7db653c28237345972412 |
Close
Hashes for rustfluent-0.1.0a2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 396f753d5ac17a00e5dee8606d395544c3cc5c2d0e758ea0414b9d7aa35d5bb2 |
|
MD5 | e2fabd42dbfcbd8069ae28ee470304c0 |
|
BLAKE2b-256 | be6d8526bc680f9f56dc40c1f7fd434cbe6754d4a9c9af57eeeda3244a7a2a42 |
Close
Hashes for rustfluent-0.1.0a2-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7dc9da0884cafbed5526eee9f3093a26b30599026c1637a52ca36e4e3100c53a |
|
MD5 | 25fb83186164dccb32ed1063dd6eb1a8 |
|
BLAKE2b-256 | 5602354d3f0cfa4a9176170e44d6aa042807a16d1329530a840ce1bbe4625603 |
Close
Hashes for rustfluent-0.1.0a2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 464227c392127ae1d9f2798e25f5c6fc1cd0ea6a2801463b028c4bf910645b08 |
|
MD5 | e1972a4383d9e8b4290ab5f9a079f44a |
|
BLAKE2b-256 | 4f61e71beb17142a799e759504ca605f32c8af26af012adfacfe146efcf7aea5 |
Close
Hashes for rustfluent-0.1.0a2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f578a5834627bc4a8eaa45514d6d5c1d6c1c5045aaebd2f9398d33a6b6da9e9 |
|
MD5 | 78805137dbda404fe8ce487b373555bc |
|
BLAKE2b-256 | 68dedbaf85be46f4abb3d558eb7641e59b693fe7addb1b3440135266177e4031 |
Close
Hashes for rustfluent-0.1.0a2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c664382adbf6fedc6ff90712a99a6c1a257b49f0d887e8af1448c2366f6d9986 |
|
MD5 | 9fbae82ac25705065c13d0ea49219d5f |
|
BLAKE2b-256 | 7314f226fabb54a737f77ad46487b30d15d561884ae37d6bd8c942a386212621 |
Close
Hashes for rustfluent-0.1.0a2-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97decf90bc6d594ab84d7bc39de09fec377b50cd3d6318ae1f4d7ced80a0a528 |
|
MD5 | c934c4fd21163b4ecc1cee904a0df71f |
|
BLAKE2b-256 | 1717c99a44337d90ecc70f4ffa1a154312a393a0563877c7893f458c391dbea2 |