Skip to content

Commit

Permalink
Fix generic colon spacing for French
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed May 19, 2023
1 parent 28289f7 commit 3c77618
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/lang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ impl ToString for Language {
#[derive(Clone, Copy, Debug, Default)]
pub struct Translator {}

static LANGUAGE: Mutex<Language> = Mutex::new(Language::English);

static BUNDLE: Lazy<Mutex<FluentBundle<FluentResource, IntlLangMemoizer>>> = Lazy::new(|| {
let ftl = include_str!("../lang/en-US.ftl").to_owned();
let res = FluentResource::try_new(ftl).expect("Failed to parse Fluent file content.");
Expand Down Expand Up @@ -195,6 +197,9 @@ fn set_language(language: Language) {
bundle.locales = vec![language.id()];

bundle.add_resource_overriding(res);

let mut last_language = LANGUAGE.lock().unwrap();
*last_language = language;
}

static RE_EXTRA_SPACES: Lazy<Regex> = Lazy::new(|| Regex::new(r#"([^\r\n ]) {2,}"#).unwrap());
Expand Down Expand Up @@ -399,7 +404,11 @@ impl Translator {
}

fn field(&self, text: &str) -> String {
format!("{}:", text)
let language = LANGUAGE.lock().unwrap();
match *language {
Language::French => format!("{} :", text),
_ => format!("{}:", text),
}
}

pub fn field_language(&self) -> String {
Expand Down

0 comments on commit 3c77618

Please sign in to comment.