-
Notifications
You must be signed in to change notification settings - Fork 31
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
(i18n) Provide translation strings for Registry #604
base: main
Are you sure you want to change the base?
(i18n) Provide translation strings for Registry #604
Conversation
bc7ed23
to
a86dea4
Compare
@@ -3,6 +3,11 @@ name = "registry" | |||
version = "1.0.0" | |||
edition = "2021" | |||
|
|||
[package.metadata.i18n] | |||
available-locales = ["en"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use en-us
for the locale
@@ -0,0 +1,87 @@ | |||
_version: 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe Windows resources are typically one folder/file per locale, so we may want to stick with version 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not strictly opposed to that convention, especially if it's more familiar to contributors—I went with v2 because of how I was organizing the translations and believe that they'll be easier to maintain compared to replicating the structure across each file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other thing to consider is that I've been using toml
and organizing it by source files and keeping it in order with the source file to make it a bit easier to map later
|
||
// Init translations using the `[package.metadata.i18n]` section in `Cargo.toml` | ||
use rust_i18n::t; | ||
rust_i18n::i18n!("locales"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should specify fallback = "en-us"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that gets pulled from he package metadata, but can explicitly set it here.
@@ -135,19 +142,24 @@ pub fn enable_tracing() { | |||
let subscriber = tracing_subscriber::Registry::default().with(fmt).with(filter); | |||
|
|||
if tracing::subscriber::set_global_default(subscriber).is_err() { | |||
eprintln!("Unable to set global default tracing subscriber. Tracing is diabled."); | |||
let msg = t!("error.eprint.tracing_init"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can just be:
eprintln!("{}", t!("error.eprint.tracing_init");
PR Summary
This change replaces static strings in the registry app/lib with translation strings using
rust_i18n
.PR Context