Use plugin dir for locating translations without janky path passthru from front

This commit is contained in:
NGnius (Graham) 2023-02-13 21:43:13 -05:00
parent 338a5cdb24
commit 33033f670e
2 changed files with 6 additions and 1 deletions

View file

@ -7,3 +7,7 @@ Targets x86_64 (native Steam Deck ISA).
This is a minimalist web server for handling events from the front-end.
## Translations
Translations are expected to be in `<path to plugin>/translations/`, in compiled gettext format (`.mo`).

View file

@ -250,7 +250,8 @@ fn get_all_translations(language: String) -> Vec<(String, Vec<String>)> {
#[cfg(feature = "translate")]
fn load_locale(lang: &str) -> Result<gettext_ng::Catalog, gettext_ng::Error> {
let file = std::fs::File::open(lang).map_err(|e| gettext_ng::Error::Io(e))?;
let path = crate::api::dirs::plugin().unwrap_or_else(|| "".into()).join("translations").join(format!("{}.mo", lang));
let file = std::fs::File::open(path).map_err(|e| gettext_ng::Error::Io(e))?;
gettext_ng::Catalog::parse(file)
}