mirror of https://codeberg.org/topola/topola.git
fix(egui): show language display names instead of codes
This commit is contained in:
parent
4b66e585c5
commit
941a271339
|
|
@ -25,9 +25,10 @@ egui = [
|
||||||
"dep:env_logger",
|
"dep:env_logger",
|
||||||
"dep:fluent-templates",
|
"dep:fluent-templates",
|
||||||
"dep:futures-lite",
|
"dep:futures-lite",
|
||||||
|
"dep:icu",
|
||||||
"dep:rfd",
|
"dep:rfd",
|
||||||
"dep:sys-locale",
|
"dep:sys-locale",
|
||||||
"dep:unic-langid"
|
"dep:unic-langid",
|
||||||
]
|
]
|
||||||
disable_contracts = ["contracts-try/disable_contracts"]
|
disable_contracts = ["contracts-try/disable_contracts"]
|
||||||
|
|
||||||
|
|
@ -74,6 +75,11 @@ features = ["macros", "serde"]
|
||||||
optional = true
|
optional = true
|
||||||
version = "0.11"
|
version = "0.11"
|
||||||
|
|
||||||
|
[dependencies.icu]
|
||||||
|
optional = true
|
||||||
|
version = "1.5.0"
|
||||||
|
features = ["experimental"]
|
||||||
|
|
||||||
[dependencies.eframe]
|
[dependencies.eframe]
|
||||||
optional = true
|
optional = true
|
||||||
version = "0.29"
|
version = "0.29"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,8 @@
|
||||||
use std::{ops::ControlFlow, path::Path, sync::mpsc::Sender};
|
use icu::{
|
||||||
|
experimental::displaynames::LocaleDisplayNamesFormatter,
|
||||||
|
locid::{locale, LanguageIdentifier, Locale},
|
||||||
|
};
|
||||||
|
use std::{borrow::Cow, ops::ControlFlow, path::Path, sync::mpsc::Sender};
|
||||||
|
|
||||||
use topola::{
|
use topola::{
|
||||||
autorouter::{
|
autorouter::{
|
||||||
|
|
@ -168,12 +172,23 @@ impl MenuBar {
|
||||||
ui.menu_button(tr.text("tr-menu-properties"), |ui| {
|
ui.menu_button(tr.text("tr-menu-properties"), |ui| {
|
||||||
ui.menu_button(tr.text("tr-menu-properties-set-language"), |ui| {
|
ui.menu_button(tr.text("tr-menu-properties-set-language"), |ui| {
|
||||||
for langid in Translator::locales() {
|
for langid in Translator::locales() {
|
||||||
ui.radio_value(
|
if let Ok(locale) =
|
||||||
tr.langid_mut(),
|
Locale::try_from_bytes(langid.to_string().as_bytes())
|
||||||
langid.clone(),
|
{
|
||||||
langid.language.as_str(),
|
if let Ok(formatter) = LocaleDisplayNamesFormatter::try_new(
|
||||||
);
|
&locale.clone().into(),
|
||||||
//ui.add(egui::RadioButton::new(true, locale.language.as_str()));
|
Default::default(),
|
||||||
|
) {
|
||||||
|
ui.radio_value(
|
||||||
|
tr.langid_mut(),
|
||||||
|
langid.clone(),
|
||||||
|
formatter.of(&locale),
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.radio_value(tr.langid_mut(), langid.clone(), langid.to_string());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue