Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization #59

Open
tertsdiepraam opened this issue Dec 12, 2023 · 0 comments
Open

Localization #59

tertsdiepraam opened this issue Dec 12, 2023 · 0 comments

Comments

@tertsdiepraam
Copy link
Member

This library has the potential to have localization built-in. Currently, all strings are hardcoded in this library, especially in the derive part, but with localized strings, they have to live in some data structure providing strings per language.

The "obvious" crate for localization is fluent.

To tackle the design there are several issues that we need to address:

  • Localized description from the markdown file.
  • Localized help string for arguments.
  • Localized error messages.

Markdown file

Recall that a command is documented in a markdown file, which is referenced like this:

#[derive(Arguments)]
#[arguments(file = "some/path/to/the/help/file.md")]
enum Arg { ... }

That works great for a single file, but we might need some more flexibility.

Instead, we need some regex-like / glob-like pattern:

#[derive(Arguments)]
#[arguments(file = "some/path/to/the/help/file-{LOCALE}.md")]
enum Arg { ... }

or

#[derive(Arguments)]
#[arguments(file = "some/{LOCALE}/path/to/the/help/file.md")]
enum Arg { ... }

Every file with that pattern would be included in the binary and the right text would be selected at runtime.

Options

The help text for the options could be written in fluent files. Ideally, this would be parsed at compile-time, somehow.

Errors

Errors would also need to be written in fluent. This goes for all errors in the coreutils, but also for the errors produced by this library.

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

No branches or pull requests

1 participant