Open Chaloemphisit opened 8 months ago
That would be very useful. My white-label app needs to override some stings on server-side, but others can be used with the defaults from the RootBundle.
@Chaloemphisit Here's my draft, you may use it:
class CombinedAssetLoader extends SmartNetworkAssetLoader {
final AssetLoader parent;
CombinedAssetLoader({
required this.parent,
required super.localeUrl,
super.timeout = const Duration(seconds: 30),
required super.assetsPath,
super.localCacheDuration = const Duration(days: 1),
});
@override
Future<Map<String, dynamic>> load(String localePath, Locale locale) async {
final smartData = await super.load(localePath, locale);
final parentData = await parent.load(localePath, locale);
parentData?.addAll(smartData);
return parentData ?? {};
}
}
I could rewrite this and open a Pull Request on the easy_localization_loader
repository. Maybe create kinda class CombinedAssetLoader
extending AssetLoader, that requires arguments with base loader and override loader, and creates merged Map with localized strings.
Sorry, but i think this logic will not work for nested map.
Hmmm, that's true. I did this for my project and didn't need it :) You need to add something like "deep merge": https://gist.github.com/niusounds/30ba030c084ccd11faaab0bf2ecd81cf
Use difference source for fallback translations.
Issue
Question