Skip to content

Commit 5b0a71c

Browse files
committed
Rename argument from namespace to language
1 parent f3badac commit 5b0a71c

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ struct Bundle {
2121
#[pymethods]
2222
impl Bundle {
2323
#[new]
24-
fn new(namespace: &str, ftl_filenames: &'_ Bound<'_, PyList>) -> PyResult<Self> {
25-
let langid_en: LanguageIdentifier = namespace.parse().expect("Parsing failed");
26-
let mut bundle = FluentBundle::new_concurrent(vec![langid_en]);
24+
fn new(language: &str, ftl_filenames: &'_ Bound<'_, PyList>) -> PyResult<Self> {
25+
let langid: LanguageIdentifier = language.parse().expect("Parsing failed");
26+
let mut bundle = FluentBundle::new_concurrent(vec![langid]);
2727

2828
for file_path in ftl_filenames.iter() {
2929
let path_string = file_path.to_string();

src/rustfluent.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class Bundle:
2-
def __init__(self, namespace: str, ftl_filenames: list[str]) -> None: ...
2+
def __init__(self, language: str, ftl_filenames: list[str]) -> None: ...
33
def get_translation(self, identifier: str, **kwargs: str) -> str: ...

tests/test_python_interface.py

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ def test_en_basic():
1515
assert bundle.get_translation("hello-world") == "Hello World"
1616

1717

18+
def test_en_basic_with_named_arguments():
19+
bundle = fluent.Bundle(
20+
language="en",
21+
ftl_filenames=[str(data_dir / "en.ftl")],
22+
)
23+
assert bundle.get_translation("hello-world") == "Hello World"
24+
25+
1826
def test_en_with_args():
1927
bundle = fluent.Bundle("en", [str(data_dir / "en.ftl")])
2028
assert bundle.get_translation("hello-user", user="Bob") == "Hello, \u2068Bob\u2069"

0 commit comments

Comments
 (0)