Skip to content
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

Why is this line hardcoded to a path? #376

Open
Elsie19 opened this issue Dec 7, 2024 · 2 comments
Open

Why is this line hardcoded to a path? #376

Elsie19 opened this issue Dec 7, 2024 · 2 comments
Labels
bug crate:fluent-resmgr help wanted We need help making decisions or writing PRs for this.

Comments

@Elsie19
Copy link

Elsie19 commented Dec 7, 2024

let full_path = format!("./tests/resources/{}/{}", locale, res_id);

It seems that if I try to change the path in my program to something like this:

.
├── broken
│   └── resources
│       ├── en-US
│       │   └── test.ftl
│       └── pl
├── Cargo.lock
├── Cargo.toml
└── src
    └── main.rs

I get this:

thread 'main' panicked at /home/henry/.cargo/registry/src/index.crates.io-6f17d22bba15001f/fluent-resmgr-0.0.7/src/resource_manager.rs:175:56:
called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

With this code:

use fluent_fallback::Localization;
use fluent_resmgr::ResourceManager;
use unic_langid::langid;

fn main() {
    let res_mgr = ResourceManager::new("./broken/resources/{locale}/".into());

    let loc = Localization::with_env(
        vec!["test.ftl".into()],
        true,
        vec![langid!("en-US")],
        res_mgr,
    );
    let bundles = loc.bundles();

    let mut errors = vec![];
    let value = bundles
        .format_value_sync("hello-world", None, &mut errors)
        .expect("Failed to format a value");

    println!("{}", value.unwrap());
}
@pvshvp-oss
Copy link

I have been confused about this too. Wonder why this path is hardcoded. They already receive the path where sources can be found.

@alerque
Copy link
Collaborator

alerque commented Feb 17, 2025

It does look like some of the setup for the crate tests is leaking into the crate itself. If anybody has a suggestion/PR to fix this I'd facilitate it. So far I've only had time to look and confirm that this seems like an issue that should be fixed.

@alerque alerque added bug help wanted We need help making decisions or writing PRs for this. crate:fluent-resmgr labels Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug crate:fluent-resmgr help wanted We need help making decisions or writing PRs for this.
Projects
None yet
Development

No branches or pull requests

3 participants