-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation
Description
Check the possibility of reading the available translation files from the assets directory by reading the manifest (just like we do for files), similar to what GettextImporter().fromAssetDirectory did
Future<Map<String, Map<String, String>>> fromAssetDirectory(
String dir) async {
var manifestContent = await rootBundle.loadString("AssetManifest.json");
Map<String, dynamic> manifestMap = json.decode(manifestContent);
Map<String, Map<String, String>> translations = HashMap();
for (String path in manifestMap.keys) {
if (!path.startsWith(dir)) continue;
var fileName = path.split("/").last;
if (!fileName.endsWith(_extension)) {
print("➜ Ignoring file $path with unexpected file type "
"(expected: $_extension).");
continue;
}
var languageCode = fileName.split(".")[0];
translations.addAll(await fromAssetFile(languageCode, path));
}
return translations;
}Or something like
// Get a list of all file paths in the asset directory.
ret = await rootBundle
.loadString('AssetManifest.json')
.then((jsonStr) => jsonDecode(jsonStr) as Map<String, dynamic>)
.then((map) => map.keys
.where((String key) => key.startsWith("assets/$dir"))
.toList());
[…](https://github.com/marcglasberg/i18n_extension/issues/153#)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation