kgv / bevy_fluent

Bevy plugin for localization using Fluent.
Apache License 2.0
122 stars 16 forks source link

Loading folders is not supported on Android and Web #43

Open inodentry opened 8 months ago

inodentry commented 8 months ago

Older (before Bevy 0.12) versions of bevy_fluent supported providing a Vec of asset handles for the locale bundles.

The current (Bevy 0.12) version switched to using LoadedFolder (new API that came with the Bevy 0.12 assets rework).

However, some platforms do not support the asset_server.load_folder API. Notably Web/WASM and Android.

I can no longer run projects that use bevy_fluent on these platforms.

I want to make a mobile port of my game, but it seems like it is no longer possible, because LocalizationBuilder requires LoadedFolder.

Can you please also support using a simple Vec of asset handles instead?

It would also have the benefit that it would allow me to organize my locale assets differently if I want, instead of requiring them to be all in a single folder.

quinnromanek commented 7 months ago

Wanted to +1 this - bevy_asset_loader (a common loading state plugin) also doesn't support loading LoadedFolders, only Vec<UntypedHandle>.

kgv commented 7 months ago

I plan to address this issue in the new API (#37). Loading will be done using Asset settings. Waiting:

Selene-Amanita commented 5 months ago

A way to get around it with bevy_asset_loader is to have a Vec<UntypedHandle> and then have a system/resource like that when it finishes loading the vec (OnExit(LoadedState)):

fn create_locales_loaded_folder_handle(
    mut commands: Commands,
    assets: Res<LocalizationAssets>,
    mut loaded_folders: ResMut<Assets<LoadedFolder>>,
) {
    commands.insert_resource(LocalesLoadedFolderHandle(loaded_folders.add(
        LoadedFolder {
            handles: assets.locales.clone(),
        },
    )));
}

I think if you load every file one by one in the vec using a list of path: https://github.com/NiklasEi/bevy_asset_loader?tab=readme-ov-file#list-of-paths you can do that for the android and web build, but that's tedious.