void readModule(String module, [String? locale]) {
locale ??= this.locale;
- var file = File(join(dataDirectory, '$module.$locale.mo'));
+ var file = File(join(dataDirectory, '$module.$locale.po'));
if (!file.existsSync() && locale.length > 2) {
locale = locale.substring(0, 2);
- file = File(join(dataDirectory, '$module.$locale.mo'));
+ file = File(join(dataDirectory, '$module.$locale.po'));
}
if (!file.existsSync()) {
+ logger.error('i18n: not found: $file');
+ } else {
+ logger.log('reading $file', LEVEL_DETAIL);
final lines = file.readAsLinesSync();
String lastKey = '';
String lastTranslation = '';
+import 'dart:io';
+
import 'package:dart_bones/dart_bones.dart';
import 'package:exhibition/base/i18n.dart';
import 'package:exhibition/setting/global_data.dart';
void main() async {
final logger = MemoryLogger(LEVEL_FINE);
ExhibitionApp.logger = logger;
+ // Preliminary I18n initialization. Will be replaced later:
I18N.internal(logger);
- final configuration = BaseConfiguration({}, logger);
+ final configuration = findConfiguration(logger);
// We create a simplified instance. The real instance will be created in StartPage
GlobalData.internal(
configuration,
logger);
runApp(ExhibitionApp());
}
+
+BaseConfiguration findConfiguration(MemoryLogger logger) {
+ String? path;
+ BaseConfiguration rc = BaseConfiguration({}, logger);
+ if (Platform.isLinux) {
+ path = '/etc/exhibition';
+ } else if (Platform.isAndroid) {
+ path = '/etc/exhibition/exhibition.yaml';
+ } else {
+ logger.error('main(): no supported platform. Empty configuration');
+ }
+ if (path != null) {
+ rc = Configuration(path, 'exhibition.yaml', logger);
+ }
+ return rc;
+}
import '../base/application_name.dart';
import '../base/defines.dart';
+import '../base/i18n_io.dart';
import '../page/page_controller_exhibition.dart';
import '../persistence/rest_persistence.dart';
import '../widget/attended_page.dart';
logger.log('Start');
_instance = this;
navigatorStack.globalData = this;
+ final i18n = I18nIo.internal(
+ configuration.asString('i18nDirectory', defaultValue: 'i18n')!, logger);
+ i18n.readModule('!global');
}
Future initializeAsync() async {
// Do customize!