Skip to content

Commit

Permalink
refactor: removed path_prefix from FsTranslationsManager
Browse files Browse the repository at this point in the history
This silences Clippy warnings.
  • Loading branch information
arctic-hen7 committed Dec 21, 2021
1 parent 61aa406 commit ed48f3d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
1 change: 0 additions & 1 deletion packages/perseus/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ macro_rules! define_get_translations_manager {
$crate::internal::i18n::DFLT_TRANSLATIONS_DIR.to_string(),
all_locales,
$crate::internal::i18n::TRANSLATOR_FILE_EXT.to_string(),
$crate::internal::get_path_prefix_server(),
)
.await
}
Expand Down
10 changes: 1 addition & 9 deletions packages/perseus/src/translations_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,20 @@ pub struct FsTranslationsManager {
cached_locales: Vec<String>,
/// The file extension expected (e.g. JSON, FTL, etc). This allows for greater flexibility of translation engines (future).
file_ext: String,
/// The path prefix for the app.
path_prefix: String,
}
impl FsTranslationsManager {
/// Creates a new filesystem translations manager. You should provide a path like `/translations` here. You should also provide
/// the locales you want to cache, which will have their translations stored in memory. Any supported locales not specified here
/// will not be cached, and must have their translations read from disk on every request. If fetching translations for any of the
/// given locales fails, this will panic (locales to be cached should always be hardcoded).
// TODO performance analysis of manual caching strategy
pub async fn new(
root_path: String,
locales_to_cache: Vec<String>,
file_ext: String,
path_prefix: String,
) -> Self {
pub async fn new(root_path: String, locales_to_cache: Vec<String>, file_ext: String) -> Self {
// Initialize a new instance without any caching first
let mut manager = Self {
root_path,
cached_translations: HashMap::new(),
cached_locales: Vec::new(),
file_ext,
path_prefix,
};
// Now use that to get the translations for the locales we want to cache (all done in parallel)
let mut futs = Vec::new();
Expand Down

0 comments on commit ed48f3d

Please sign in to comment.