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:fluent-templates",
|
||||
"dep:futures-lite",
|
||||
"dep:icu",
|
||||
"dep:rfd",
|
||||
"dep:sys-locale",
|
||||
"dep:unic-langid"
|
||||
"dep:unic-langid",
|
||||
]
|
||||
disable_contracts = ["contracts-try/disable_contracts"]
|
||||
|
||||
|
|
@ -74,6 +75,11 @@ features = ["macros", "serde"]
|
|||
optional = true
|
||||
version = "0.11"
|
||||
|
||||
[dependencies.icu]
|
||||
optional = true
|
||||
version = "1.5.0"
|
||||
features = ["experimental"]
|
||||
|
||||
[dependencies.eframe]
|
||||
optional = true
|
||||
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::{
|
||||
autorouter::{
|
||||
|
|
@ -168,12 +172,23 @@ impl MenuBar {
|
|||
ui.menu_button(tr.text("tr-menu-properties"), |ui| {
|
||||
ui.menu_button(tr.text("tr-menu-properties-set-language"), |ui| {
|
||||
for langid in Translator::locales() {
|
||||
if let Ok(locale) =
|
||||
Locale::try_from_bytes(langid.to_string().as_bytes())
|
||||
{
|
||||
if let Ok(formatter) = LocaleDisplayNamesFormatter::try_new(
|
||||
&locale.clone().into(),
|
||||
Default::default(),
|
||||
) {
|
||||
ui.radio_value(
|
||||
tr.langid_mut(),
|
||||
langid.clone(),
|
||||
langid.language.as_str(),
|
||||
formatter.of(&locale),
|
||||
);
|
||||
//ui.add(egui::RadioButton::new(true, locale.language.as_str()));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
ui.radio_value(tr.langid_mut(), langid.clone(), langid.to_string());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue