Skip to content

Commit

Permalink
2-digit locale file
Browse files Browse the repository at this point in the history
  • Loading branch information
shevernitskiy committed Feb 28, 2024
1 parent b61c786 commit 0958282
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/localization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const LOCALES: Dir<'_> = include_dir!("./locale");

#[static_init::dynamic]
pub static mut LOCALE: Localization = {
let locale = sys_locale::get_locale().unwrap_or("en-US".to_owned());
let locale = sys_locale::get_locale().unwrap_or("en-US".to_string()).split('-').collect::<Vec<&str>>()[0].to_owned();
Localization::new(locale)
};

Expand Down Expand Up @@ -37,7 +37,7 @@ impl Localization {
pub fn new(locale: String) -> Self {
let translation: HashMap<String, String> = match TRANSLATIONS.get(&locale) {
Some(v) => serde_json::from_str(v).unwrap(),
None => serde_json::from_str(TRANSLATIONS.get("en-US").unwrap()).unwrap(),
None => serde_json::from_str(TRANSLATIONS.get("en").unwrap()).unwrap(),
};

Self {
Expand All @@ -54,7 +54,7 @@ impl Localization {
self.locale = s.to_owned();
self.map = match TRANSLATIONS.get(s) {
Some(v) => serde_json::from_str(v).unwrap(),
None => serde_json::from_str(TRANSLATIONS.get("en-US").unwrap()).unwrap(),
None => serde_json::from_str(TRANSLATIONS.get("en").unwrap()).unwrap(),
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub fn is_dfhack_installed(df_dir: &Option<PathBuf>) -> bool {

pub fn fetch_manifest<T: for<'de> serde::Deserialize<'de>>(url: &str) -> Result<Vec<T>> {
let manifests: Vec<T> = ureq::get(url).call()?.into_json()?;
return Ok(manifests);
Ok(manifests)
}

pub fn get_manifest_by_df(df_checksum: u32, manifests: Vec<HookManifest>) -> Option<HookManifest> {
Expand Down

0 comments on commit 0958282

Please sign in to comment.