Copy values from android resources to flutter assets
This commit is contained in:
@@ -11,8 +11,10 @@ import 'package:checker/screens/finish_registration.dart';
|
||||
import 'package:checker/screens/registration.dart';
|
||||
import 'package:checker/strings.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:xml/xml.dart' as xml;
|
||||
|
||||
class SplashScreen extends StatefulWidget {
|
||||
@override
|
||||
@@ -53,6 +55,11 @@ class _SplashScreenState extends BaseState<SplashScreen> {
|
||||
helper.getSettings(false).then((settings) {
|
||||
if (settings == null) {
|
||||
createSettingsTable(locale);
|
||||
getTranslates(locale).then((strings) {
|
||||
// platform.invokeMethod('pushTranslates').then((locale) {
|
||||
//
|
||||
// });
|
||||
});
|
||||
} else {
|
||||
initLocale(locale, () {
|
||||
showNext();
|
||||
@@ -62,6 +69,21 @@ class _SplashScreenState extends BaseState<SplashScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
Future<Map> getTranslates(String locale) async {
|
||||
String strings = await loadAsset(locale);
|
||||
var document = xml.parse(strings);
|
||||
Map results = new Map<String, String>();
|
||||
document.findAllElements('string').forEach((node) {
|
||||
print(node.name.toString() + node.text.toString());
|
||||
results[node.name.toString()] = node.text.toString();
|
||||
});
|
||||
return results;
|
||||
}
|
||||
|
||||
Future<String> loadAsset(String locale) async {
|
||||
return await rootBundle.loadString('assets/values-$locale/strings.xml');
|
||||
}
|
||||
|
||||
void initWithSavedValue(String locale) {
|
||||
initLocale(locale, () {
|
||||
showNext();
|
||||
|
||||
Reference in New Issue
Block a user