mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
locale: show the error in case of issue
This commit is contained in:
parent
c332d96203
commit
42cfb3d8be
1 changed files with 15 additions and 7 deletions
|
@ -140,13 +140,21 @@ fn create_bundle(
|
||||||
path: locale_path.clone(),
|
path: locale_path.clone(),
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let resource = FluentResource::try_new(ftl_file).map_err(|_| {
|
let resource = FluentResource::try_new(ftl_file.clone()).map_err(
|
||||||
LocalizationError::Parse(format!(
|
|(_partial_resource, mut errs): (FluentResource, Vec<ParserError>)| {
|
||||||
"Failed to parse localization resource for {}: {}",
|
let first_err = errs.remove(0);
|
||||||
locale,
|
// Attempt to extract the snippet from the original ftl_file
|
||||||
locale_path.display()
|
let snippet = if let Some(range) = first_err.slice.clone() {
|
||||||
))
|
ftl_file.get(range).unwrap_or("").to_string()
|
||||||
})?;
|
} else {
|
||||||
|
String::new()
|
||||||
|
};
|
||||||
|
LocalizationError::ParseResource {
|
||||||
|
error: first_err,
|
||||||
|
snippet,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
let mut bundle = FluentBundle::new(vec![locale.clone()]);
|
let mut bundle = FluentBundle::new(vec![locale.clone()]);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue