fix(locale): create stub primary language localization assets

This commit is contained in:
Jagandeep Brar
2022-06-24 12:55:04 -04:00
parent e05b17ae5e
commit 18ef4cf1d4
6 changed files with 18 additions and 15 deletions

View File

@@ -3,7 +3,7 @@
import 'dart:convert';
import 'dart:io';
/// Simple dart script to concat all module's localization files into a single file for loading into LunaSea.
/// Simple dart script to concatenate all module's localization files into a single file for loading into LunaSea.
///
/// This script is designed to be run from the root of the project.
void main() {
@@ -38,6 +38,8 @@ void main() {
_createFile(path);
File file = File(language.path);
_writeFile(path, jsonDecode(file.readAsStringSync()));
// If required, create a stub primary language to prevent asset load failures
if (name.contains('-')) _writeStubPrimaryLanguage(_assets.path, name);
}
});
print('');
@@ -45,6 +47,12 @@ void main() {
});
}
void _writeStubPrimaryLanguage(String assets, String language) {
final primary = language.split('-').first;
final path = '$assets/$primary.json';
_createFile(path);
}
void _writeFile(String path, Map<dynamic, dynamic>? data) {
// Read the current data in the file
File file = File(path);