Skip to content

ResourceManager::get_bundle and get_bundles is inconsistent and confusing #279

Open
@gregtatum

Description

@gregtatum

get_bundle will only load the resources for a single locale, but supports fallback behavior for i18n formatters like date time format (at least it claims to). This bundle will provide no fallback behavior for missing messages.

let res = self.get_resource(res_id, &locales[0].to_string());

get_bundles will iterate over bundles for each locale in the list. I guess you could implement your own fallback behavior for messages here, but the i18n formatters are not provided with a list of locales to fallback upon, so the behavior is different than get_bundle. This seems a bit weird and inconsistent. Firefox is not using this crate, but as an example resource manager, the behavior is a bit odd and inconsistent.

let mut bundle = FluentBundle::new(vec![locale.clone()]);

To make them consistent you would either:

A. Remove fallbacking for get_bundle and only provide a single locale, not a Vec of locales.
B. Pass the locale fallbacks to FluentBundle.

For B I'm unsure which behavior should provided for the fallback list, given:

Locale list: ["en-US", "en-CA", "pl", "es-ES"]
And en-CA as the iteration step.

Would the locale list be:

i. A slice of the remaining;["en-CA", "pl", "es-ES"]
ii. A rearranged list:["en-CA", "en-US", "pl", "es-ES"]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions