Skip to content

Conversation

@tronical
Copy link
Collaborator

The rspolib feature adds RSPoLibTranslator and re-exports rspolib.

The plural rules parser was originally written by Olivier Goffart olivier.goffart@slint.dev.

The rspolib feature adds `RSPoLibTranslator` and re-exports `rspolib`.

The plural rules parser was originally written by Olivier Goffart <olivier.goffart@slint.dev>.
@tronical
Copy link
Collaborator Author

As a side note: I had to do the edition upgrade for compilation, but I haven't done any other "upgrades". I'd be happy to do those, for example explicit features and using dep:foo, if desired. Similarly, I didn't change the version number but am happy to adjust in this PR if desired.

Copy link
Member

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From an API point of view, I wonder if this should belong in a rspolib_01 module.

So we'd do:

tr::set_translator!(tr::rspolib_01::RSPoLibTranslator::try_from(
    tr::rspolib_01::rspolib::pofile("....po").unwrap()
).unwrap()));

But I get that this is a bit long to use tr::rspolib_01::rspolib
But the point is trying to keep it separate.

Another idea would be to hide the rspolib API entirely, and have an API like so:

fn load_po_file(path: Path) -> impl Translator
fn po_data(data: &[u8]) -> impl Translator
fn load_mo_file(path: Path) -> impl Translator
fn mo_data(data: &[u8]) -> impl Translator

tronical and others added 4 commits June 11, 2025 13:14
Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
Instead, have mo-translator and po-translator features, that activate each opaque MoTranslator and PoTranslator types,
which can be constructed from paths or vecs.
categories = ["internationalization", "localization"]
edition = "2018"
edition = "2021"
rust-version = "1.81"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the MSRV so high?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the last failed build attempt in the CI:

error: package `half v2.6.0` cannot be built because it requires rustc 1.81 or newer, while the currently active rustc version is 1.74.1

@ogoffart ogoffart merged commit 25c7c5b into woboq:master Jun 11, 2025
4 checks passed
@ogoffart
Copy link
Member

I'm wondering how to do the dynamic language change. We would have to call set_translator but that takes ownership. Meaning we need to always reload the file.

Perhaps the trick here is to implement the Translator trait for Arc

@tronical
Copy link
Collaborator Author

are you concerned that switching say between de, fr, and back to de, the de mo file is parsed twice?

I agree that Arc would fix it, but it's an interesting tradeoff to make (memory vs performance over a rare operation).

@tronical tronical deleted the simon/rspolib branch June 12, 2025 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants