diff --git a/packages/perseus/src/client_translations_manager.rs b/packages/perseus/src/client_translations_manager.rs index bf63a9a172..5658982ad9 100644 --- a/packages/perseus/src/client_translations_manager.rs +++ b/packages/perseus/src/client_translations_manager.rs @@ -45,8 +45,7 @@ impl ClientTranslationsManager { Ok(translations_str) => match translations_str { Some(translations_str) => { // All good, turn the translations into a translator - let translator = - Translator::new(locale.to_string(), translations_str, &path_prefix); + let translator = Translator::new(locale.to_string(), translations_str); match translator { Ok(translator) => translator, Err(err) => { @@ -78,8 +77,7 @@ impl ClientTranslationsManager { Ok(Rc::clone(self.cached_translator.as_ref().unwrap())) } else if !self.locales.using_i18n { // If we aren't even using i18n, then it would be pointless to fetch translations - let translator = - Translator::new("xx-XX".to_string(), "".to_string(), &path_prefix).unwrap(); + let translator = Translator::new("xx-XX".to_string(), "".to_string()).unwrap(); // Cache that translator self.cached_translator = Some(Rc::new(translator)); // Now return that diff --git a/packages/perseus/src/translations_manager.rs b/packages/perseus/src/translations_manager.rs index 512bab592b..4878ae905d 100644 --- a/packages/perseus/src/translations_manager.rs +++ b/packages/perseus/src/translations_manager.rs @@ -158,11 +158,12 @@ impl TranslationsManager for FsTranslationsManager { translations_str = self.get_translations_str_for_locale(locale.clone()).await?; } // We expect the translations defined there, but not the locale itself - let translator = Translator::new(locale.clone(), translations_str, &self.path_prefix) - .map_err(|err| TranslationsManagerError::SerializationFailed { + let translator = Translator::new(locale.clone(), translations_str).map_err(|err| { + TranslationsManagerError::SerializationFailed { locale: locale.clone(), source: err.into(), - })?; + } + })?; Ok(translator) } @@ -191,7 +192,7 @@ impl TranslationsManager for DummyTranslationsManager { &self, locale: String, ) -> Result { - let translator = Translator::new(locale.clone(), String::new(), "").map_err(|err| { + let translator = Translator::new(locale.clone(), String::new()).map_err(|err| { TranslationsManagerError::SerializationFailed { locale, source: err.into(), diff --git a/packages/perseus/src/translator/fluent.rs b/packages/perseus/src/translator/fluent.rs index eb024064c1..aaf7fdd367 100644 --- a/packages/perseus/src/translator/fluent.rs +++ b/packages/perseus/src/translator/fluent.rs @@ -17,16 +17,10 @@ pub struct FluentTranslator { bundle: Rc>, /// The locale for which translations are being managed by this instance. locale: String, - /// The path prefix to apply when calling the `.url()` method. - path_prefix: String, } impl FluentTranslator { /// Creates a new translator for a given locale, passing in translations in FTL syntax form. - pub fn new( - locale: String, - ftl_string: String, - path_prefix: &str, - ) -> Result { + pub fn new(locale: String, ftl_string: String) -> Result { let resource = FluentResource::try_new(ftl_string) // If this errors, we get it still and a vector of errors (wtf.) .map_err(|(_, errs)| TranslatorError::TranslationsStrSerFailed { @@ -59,12 +53,11 @@ impl FluentTranslator { Ok(Self { bundle: Rc::new(bundle), locale, - path_prefix: path_prefix.to_string(), }) } /// Gets the path to the given URL in whatever locale the instance is configured for. This also applies the path prefix. pub fn url + std::fmt::Display>(&self, url: S) -> String { - format!("{}/{}{}", self.path_prefix, self.locale, url) + format!("{}{}", self.locale, url) } /// Gets the locale for which this instancce is configured. pub fn get_locale(&self) -> String {