Skip to content

Commit

Permalink
Fix documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Nov 28, 2023
1 parent a866bbc commit e48fc86
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion rust/agama-dbus-server/src/locale/locale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl LocalesDatabase {

/// Loads the list of locales.
///
/// * `locale`: locale to translate the descriptions.
/// * `ui_language`: language to translate the descriptions (e.g., "en").
pub fn read(&mut self, ui_language: &str) -> Result<(), Error> {
let result = Command::new("/usr/bin/localectl")
.args(["list-locales"])
Expand Down
12 changes: 7 additions & 5 deletions rust/agama-dbus-server/src/locale/timezone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ impl TimezonesDatabase {
}

/// Initializes the list of known timezones.
///
/// * `ui_language`: language to translate the descriptions (e.g., "en").
pub fn read(&mut self, ui_language: &str) -> Result<(), Error> {
self.timezones = self.get_timezones(ui_language)?;
Ok(())
Expand All @@ -42,27 +44,27 @@ impl TimezonesDatabase {
/// Each element of the list contains a timezone identifier and a vector
/// containing the translation of each part of the language.
///
/// * `locale`: locale to use in the translations.
fn get_timezones(&self, locale: &str) -> Result<Vec<TimezoneEntry>, Error> {
/// * `ui_language`: language to translate the descriptions (e.g., "en").
fn get_timezones(&self, ui_language: &str) -> Result<Vec<TimezoneEntry>, Error> {
let timezones = agama_locale_data::get_timezones();
let tz_parts = agama_locale_data::get_timezone_parts()?;
let ret = timezones
.into_iter()
.map(|tz| {
let parts = translate_parts(&tz, &locale, &tz_parts);
let parts = translate_parts(&tz, &ui_language, &tz_parts);
TimezoneEntry { code: tz, parts }
})
.collect();
Ok(ret)
}
}

fn translate_parts(timezone: &str, locale: &str, tz_parts: &TimezoneIdParts) -> Vec<String> {
fn translate_parts(timezone: &str, ui_language: &str, tz_parts: &TimezoneIdParts) -> Vec<String> {
timezone
.split("/")
.map(|part| {
tz_parts
.localize_part(part, &locale)
.localize_part(part, &ui_language)
.unwrap_or(part.to_owned())
})
.collect()
Expand Down

0 comments on commit e48fc86

Please sign in to comment.