Skip to content

Inherit path spec to bundle iterator in resource manager #387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions fluent-resmgr/src/resource_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ pub enum ResourceManagerError {
pub struct BundleIter {
locales: <Vec<LanguageIdentifier> as IntoIterator>::IntoIter,
res_ids: FxHashSet<ResourceId>,
path_scheme: String,
}

impl Iterator for BundleIter {
Expand All @@ -171,7 +172,10 @@ impl Iterator for BundleIter {
let mut bundle = FluentBundle::new(vec![locale.clone()]);

for res_id in self.res_ids.iter() {
let full_path = format!("./tests/resources/{}/{}", locale, res_id);
let full_path = self
.path_scheme
.replace("{locale}", &locale.to_string())
.replace("{res_id}", &res_id.to_string());
let source = fs::read_to_string(full_path).unwrap();
let res = FluentResource::try_new(source).unwrap();
bundle.add_resource(res).unwrap();
Expand Down Expand Up @@ -206,7 +210,11 @@ impl BundleGenerator for ResourceManager {
locales: Self::LocalesIter,
res_ids: FxHashSet<ResourceId>,
) -> Self::Iter {
BundleIter { locales, res_ids }
BundleIter {
locales,
res_ids,
path_scheme: self.path_scheme.clone(),
}
}

fn bundles_stream(
Expand Down
Loading