-
Notifications
You must be signed in to change notification settings - Fork 4
adding localisation logic #49
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
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,62 @@ | ||||||
| use { | ||||||
| serde::{ | ||||||
| Deserialize, | ||||||
| Serialize, | ||||||
| }, std::fmt | ||||||
| }; | ||||||
|
|
||||||
| #[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, clap::ValueEnum)] | ||||||
| #[clap(rename_all = "lower")] | ||||||
| pub enum Locale { | ||||||
| #[default] | ||||||
| EN, | ||||||
| FR, | ||||||
| } | ||||||
|
|
||||||
| impl Locale { | ||||||
| pub const ALL: [Locale; 2] = [ | ||||||
| Locale::EN, | ||||||
| Locale::FR, | ||||||
| ]; | ||||||
|
||||||
|
|
||||||
| pub fn message(&self, message: Message) -> &str { | ||||||
|
||||||
| pub fn message(&self, message: Message) -> &str { | |
| pub fn message(&self, message: Message) -> Cow<'static, str> { |
You can then use Cow::Borrowed("...") for string literals and Cow::Owned(format!("...")) for formatted strings.
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.
This text should probably be kept as simple as possible, so someone with minimal knowledge of English can understand it: