XAMPPRocky / fluent-templates

Easily add Fluent to your Rust project.
Apache License 2.0
136 stars 28 forks source link

ArcLoader won't work without a top level directory #41

Open alerque opened 1 year ago

alerque commented 1 year ago

I spent a while trying to figure out why I was only getting panics trying to follow examples from the docs. I finally narrowed it down to this bit of code:

https://github.com/XAMPPRocky/fluent-templates/blob/66f53a7fc1e165012897861888647f75765a1d50/tests/template.rs#L21

The path from this test tests/locales from the test and examples works, but using "./" or any other iteration I can think of to use $CWD to look for resources ends in a panic.

XAMPPRocky commented 1 year ago

Thank you for your issue! I don't have the time at the moment to fix this, but I would be able to review a PR and release a fix if someone can contribute a fix.

alerque commented 1 year ago

I've tracked this down a bit more. The issue is not with being able to use CWD per say (although that does cause extra panics), it is also with the fact that the loader blindly assumes everything in the path given (even if it is "./locales" or similar) must be a valid locale tree and have valid Fluent resource files. It doesn't matter if the locales and resource files that you use are all fine, if one exists on the file system that isn't valid things go haywire.r

XAMPPRocky commented 1 year ago

Thank you for investigating! Those errors make sense to me but they should probably not be panics and they should be more informative of what specifically is causing the problem.