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

(i18n) Provide translation strings for Registry #604

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

michaeltlombardi
Copy link
Collaborator

PR Summary

This change replaces static strings in the registry app/lib with translation strings using rust_i18n.

PR Context

@@ -3,6 +3,11 @@ name = "registry"
version = "1.0.0"
edition = "2021"

[package.metadata.i18n]
available-locales = ["en"]
Copy link
Member

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
Copy link
Member

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

Copy link
Collaborator Author

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.

Copy link
Member

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

registry/src/args.rs Show resolved Hide resolved

// Init translations using the `[package.metadata.i18n]` section in `Cargo.toml`
use rust_i18n::t;
rust_i18n::i18n!("locales");
Copy link
Member

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"

Copy link
Collaborator Author

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");
Copy link
Member

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");

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