-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
_version: 2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. The other thing to consider is that I've been using |
||
cli: | ||
about: | ||
en: Manage state of Windows registry | ||
# config command help | ||
config: | ||
about: | ||
en: Manage registry configuration. | ||
args: | ||
input: | ||
help: | ||
en: The registry JSON input. | ||
what_if: | ||
help: | ||
en: Run as a what-if operation instead of applying the registry configuration. | ||
get: | ||
about: | ||
en: Retrieve registry configuration. | ||
set: | ||
about: | ||
en: Apply registry configuration. | ||
delete: | ||
about: | ||
en: Delete registry configuration. | ||
# query command help | ||
query: | ||
about: | ||
en: Query a registry key or value. | ||
args: | ||
key_path: | ||
help: | ||
en: The registry key path to query. | ||
value_name: | ||
help: | ||
en: The name of the value to query. | ||
recurse: | ||
help: | ||
en: Recursively query subkeys. | ||
# set command help | ||
set: | ||
about: | ||
en: Set a registry key or value. | ||
args: | ||
key_path: | ||
help: | ||
en: The registry key path to set. | ||
value: | ||
help: | ||
en: The value to set. | ||
# remove command help | ||
remove: | ||
about: | ||
en: Remove a registry key or value. | ||
args: | ||
key_path: | ||
help: | ||
en: The registry key path to remove. | ||
value_name: | ||
help: | ||
en: The name of the value to remove. | ||
recurse: | ||
help: | ||
en: Recursively remove subkeys. | ||
# find command help | ||
find: | ||
about: | ||
en: Find a registry key or value. | ||
args: | ||
key_path: | ||
help: | ||
en: The registry key path to start find. | ||
find: | ||
help: | ||
en: The string to find. | ||
recurse: | ||
help: | ||
en: Recursively find. | ||
keys_only: | ||
help: | ||
en: Only find keys. | ||
values_only: | ||
help: | ||
en: Only find values. | ||
# schema command help | ||
schema: | ||
about: | ||
en: Retrieve JSON schema. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
_version: 2 | ||
errors: | ||
InvalidHive: | ||
en: Invalid hive | ||
Json: | ||
en: JSON | ||
Registry: | ||
en: Registry | ||
RegistryKey: | ||
en: Registry key | ||
RegistryKeyNotFound: | ||
en: Registry key not found | ||
RegistryValue: | ||
en: Registry value | ||
Utf16Conversion: | ||
en: UTF-16 conversion failed due to interior NULL values for | ||
UnsupportedValueDataType: | ||
en: Unsupported registry value data type | ||
# internal, not an enum | ||
eprint: | ||
tracing_init: | ||
en: Unable to set global default tracing subscriber. Tracing is diabled. | ||
debug: | ||
attach: | ||
en: attach debugger to pid %{pid} and press any key to continue | ||
event: | ||
read: | ||
en: "Error: Failed to read event: %{err}" | ||
unexpexted: | ||
en: "Unexpected event: %{e:?}" | ||
remove: | ||
key_not_exist: | ||
en: Key already does not exist | ||
deleting_subkey: | ||
en: Deleting subkey '%{name}' using %{parent} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
_version: 2 | ||
resource: | ||
what_if: | ||
create_key: | ||
en: "key: %{subkey} not found, would create it" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
use rust_i18n::t; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
#[allow(clippy::module_name_repetitions)] | ||
pub enum RegistryError { | ||
#[error("Invalid hive: {0}.")] | ||
#[error("{t}: {0}", t = t!("errors.InvalidHive"))] | ||
InvalidHive(String), | ||
|
||
#[error("JSON: {0}")] | ||
#[error("{t}: {0}", t = t!("errors.Json"))] | ||
Json(#[from] serde_json::Error), | ||
|
||
#[error("Registry: {0}")] | ||
#[error("{t}: {0}", t = t!("errors.Registry"))] | ||
Registry(#[from] registry::Error), | ||
|
||
#[error("Registry key: {0}")] | ||
#[error("{t}: {0}", t = t!("errors.RegistryKey"))] | ||
RegistryKey(#[from] registry::key::Error), | ||
|
||
#[error("Registry key not found: {0}")] | ||
#[error("{t}: {0}", t = t!("errors.RegistryKeyNotFound"))] | ||
RegistryKeyNotFound(String), | ||
|
||
#[error("Registry value: {0}")] | ||
#[error("{t}: {0}", t = t!("errors.RegistryValue"))] | ||
RegistryValue(#[from] registry::value::Error), | ||
|
||
#[error("UTF-16 conversion of {0} failed due to interior NULL values")] | ||
#[error("{t}: {0}", t = t!("errors.Utf16Conversion"))] | ||
Utf16Conversion(String), | ||
|
||
#[error("Unsupported registry value data type")] | ||
#[error("{t}", t = t!("errors.UnsupportedValueDataType"))] | ||
UnsupportedValueDataType, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,13 @@ use crossterm::event; | |
#[cfg(debug_assertions)] | ||
use std::env; | ||
|
||
// #[macro_use] | ||
// extern crate rust_i18n; | ||
|
||
// 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 commentThe reason will be displayed to describe this comment to others. Learn more. Should specify There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
use args::Arguments; | ||
use clap::Parser; | ||
use registry_helper::RegistryHelper; | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. These can just be: eprintln!("{}", t!("error.eprint.tracing_init"); |
||
eprintln!("{msg}"); | ||
} | ||
} | ||
|
||
#[cfg(debug_assertions)] | ||
fn check_debug() { | ||
if env::var("DEBUG_REGISTRY").is_ok() { | ||
eprintln!("attach debugger to pid {} and press any key to continue", std::process::id()); | ||
let msg = t!("error.eprint.debug.attach", pid = std::process::id()); | ||
eprintln!("{msg}"); | ||
// eprintln!("attach debugger to pid {} and press any key to continue", std::process::id()); | ||
loop { | ||
let event = match event::read() { | ||
Ok(event) => event, | ||
Err(err) => { | ||
eprintln!("Error: Failed to read event: {err}"); | ||
let msg = t!("error.eprint.debug.event.read", "err" => err); | ||
eprintln!("{msg}"); | ||
// eprintln!("Error: Failed to read event: {err}"); | ||
break; | ||
} | ||
}; | ||
|
@@ -157,7 +169,9 @@ fn check_debug() { | |
break; | ||
} | ||
} else { | ||
eprintln!("Unexpected event: {event:?}"); | ||
let msg = t!("error.eprint.debug.event.unexpected", e = event : {:?}); | ||
eprintln!("{msg}"); | ||
// eprintln!("Unexpected event: {event:?}"); | ||
continue; | ||
} | ||
} | ||
|
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