Merge Portuguese translations by terry #1036
Terry Yiu (5):
Export strings for translation
Add human-readable names to locales in settings
Internationalize ShowNoteClientOptions labels
Import translations
Add Portuguese (Brazil) language and translations
This commit is contained in:
@@ -103,6 +103,39 @@ impl<'a> SettingsView<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the localized name for a language identifier
|
||||
fn get_selected_language_name(&mut self) -> String {
|
||||
if let Ok(lang_id) = self.selected_language.parse::<LanguageIdentifier>() {
|
||||
self.i18n
|
||||
.get_locale_native_name(&lang_id)
|
||||
.map(|s| s.to_owned())
|
||||
.unwrap_or_else(|| lang_id.to_string())
|
||||
} else {
|
||||
self.selected_language.clone()
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the localized label for ShowNoteClientOptions
|
||||
fn get_show_note_client_label(&mut self, option: ShowNoteClientOptions) -> String {
|
||||
match option {
|
||||
ShowNoteClientOptions::Hide => tr!(
|
||||
self.i18n,
|
||||
"Hide",
|
||||
"Option in settings section to hide the source client label in note display"
|
||||
),
|
||||
ShowNoteClientOptions::Top => tr!(
|
||||
self.i18n,
|
||||
"Top",
|
||||
"Option in settings section to show the source client label at the top of the note"
|
||||
),
|
||||
ShowNoteClientOptions::Bottom => tr!(
|
||||
self.i18n,
|
||||
"Bottom",
|
||||
"Option in settings section to show the source client label at the bottom of the note"
|
||||
),
|
||||
}.to_string()
|
||||
}
|
||||
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui) -> Option<SettingsAction> {
|
||||
let id = ui.id();
|
||||
let mut action = None;
|
||||
@@ -190,19 +223,22 @@ impl<'a> SettingsView<'a> {
|
||||
.text_style(NotedeckTextStyle::Small.text_style()),
|
||||
);
|
||||
ComboBox::from_label("")
|
||||
.selected_text(self.selected_language.to_owned())
|
||||
.selected_text(self.get_selected_language_name())
|
||||
.show_ui(ui, |ui| {
|
||||
for lang in self.i18n.get_available_locales() {
|
||||
let name = self.i18n
|
||||
.get_locale_native_name(lang)
|
||||
.map(|s| s.to_owned())
|
||||
.unwrap_or_else(|| lang.to_string());
|
||||
if ui
|
||||
.selectable_value(
|
||||
self.selected_language,
|
||||
lang.to_string(),
|
||||
lang.to_string(),
|
||||
&name,
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
action =
|
||||
Some(SettingsAction::SetLocale(lang.to_owned()))
|
||||
action = Some(SettingsAction::SetLocale(lang.to_owned()))
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -387,7 +423,7 @@ impl<'a> SettingsView<'a> {
|
||||
ShowNoteClientOptions::Top,
|
||||
ShowNoteClientOptions::Bottom,
|
||||
] {
|
||||
let label = option.clone().to_string();
|
||||
let label = self.get_show_note_client_label(option);
|
||||
|
||||
if ui
|
||||
.selectable_value(
|
||||
|
||||
Reference in New Issue
Block a user