From 8c4287a21b898ce55797acb4a92a8b882b2dca25 Mon Sep 17 00:00:00 2001 From: Ivan Murashov Date: Mon, 5 Feb 2018 23:33:57 +0300 Subject: [PATCH] Copy values from android resources to flutter assets --- .../src/main/res/layout/f_logout_dialog.xml | 60 ---- assets/values-ru/strings.xml | 12 + assets/values-ua/strings.xml | 12 + ios/{.gitignore => .hgignore} | 11 - lib/screens/splash.dart | 22 ++ pubspec.lock | 309 ++++++++++++++++++ pubspec.yaml | 3 + 7 files changed, 358 insertions(+), 71 deletions(-) delete mode 100644 android/app/src/main/res/layout/f_logout_dialog.xml create mode 100644 assets/values-ru/strings.xml create mode 100644 assets/values-ua/strings.xml rename ios/{.gitignore => .hgignore} (82%) create mode 100644 pubspec.lock diff --git a/android/app/src/main/res/layout/f_logout_dialog.xml b/android/app/src/main/res/layout/f_logout_dialog.xml deleted file mode 100644 index e318ba1..0000000 --- a/android/app/src/main/res/layout/f_logout_dialog.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/assets/values-ru/strings.xml b/assets/values-ru/strings.xml new file mode 100644 index 0000000..4f5a97b --- /dev/null +++ b/assets/values-ru/strings.xml @@ -0,0 +1,12 @@ + + Dinect + Сканер карты + Сканировать + Справка + Закрыть приложение + Настройки + "Идентификатор %s не найден" + Введите номер карты + Телефон 79XXXXXXXXX + Можете воспользоваться ручным вводом или позвонить на номер:%s + diff --git a/assets/values-ua/strings.xml b/assets/values-ua/strings.xml new file mode 100644 index 0000000..805694c --- /dev/null +++ b/assets/values-ua/strings.xml @@ -0,0 +1,12 @@ + + Dinect + Сканер карти + Сканувати + Допомога + Закрыть приложение + Налаштування + "Ідентифікатор %s не знайден" + Введіть штрихкод вручну + Телефон 79XXXXXXXXX + Можете скористатися ручним введенням або зателефонувати на номер:\n%s + diff --git a/ios/.gitignore b/ios/.hgignore similarity index 82% rename from ios/.gitignore rename to ios/.hgignore index 38864ee..b2d233e 100644 --- a/ios/.gitignore +++ b/ios/.hgignore @@ -4,7 +4,6 @@ .svn/ .DS_Store -*.swp profile DerivedData/ @@ -12,22 +11,12 @@ build/ GeneratedPluginRegistrant.h GeneratedPluginRegistrant.m -*.pbxuser -*.mode1v3 -*.mode2v3 -*.perspectivev3 - !default.pbxuser !default.mode1v3 !default.mode2v3 !default.perspectivev3 xcuserdata - -*.moved-aside - -*.pyc -*sync/ Icon? .tags* diff --git a/lib/screens/splash.dart b/lib/screens/splash.dart index b007733..2b52de8 100644 --- a/lib/screens/splash.dart +++ b/lib/screens/splash.dart @@ -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 { 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 { }); } + Future getTranslates(String locale) async { + String strings = await loadAsset(locale); + var document = xml.parse(strings); + Map results = new Map(); + document.findAllElements('string').forEach((node) { + print(node.name.toString() + node.text.toString()); + results[node.name.toString()] = node.text.toString(); + }); + return results; + } + + Future loadAsset(String locale) async { + return await rootBundle.loadString('assets/values-$locale/strings.xml'); + } + void initWithSavedValue(String locale) { initLocale(locale, () { showNext(); diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..e903e1b --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,309 @@ +# Generated by pub +# See http://pub.dartlang.org/doc/glossary.html#lockfile +packages: + analyzer: + dependency: transitive + description: + name: analyzer + url: "https://pub.dartlang.org" + source: hosted + version: "0.30.0+4" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "0.13.7" + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" + barback: + dependency: transitive + description: + name: barback + url: "https://pub.dartlang.org" + source: hosted + version: "0.15.2+14" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + cli_util: + dependency: transitive + description: + name: cli_util + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.2+1" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.14.5" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2+1" + csslib: + dependency: transitive + description: + name: csslib + url: "https://pub.dartlang.org" + source: hosted + version: "0.14.1" + dart_style: + dependency: transitive + description: + name: dart_style + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.9+1" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + front_end: + dependency: transitive + description: + name: front_end + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.0-alpha.4.1" + glob: + dependency: transitive + description: + name: glob + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.5" + html: + dependency: transitive + description: + name: html + url: "https://pub.dartlang.org" + source: hosted + version: "0.13.2+2" + http: + dependency: "direct main" + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.11.3+16" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.1" + image_picker: + dependency: "direct main" + description: + name: image_picker + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.5" + intl: + dependency: "direct main" + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.15.2" + intl_translation: + dependency: "direct main" + description: + name: intl_translation + url: "https://pub.dartlang.org" + source: hosted + version: "0.15.0" + isolate: + dependency: transitive + description: + name: isolate + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + kernel: + dependency: transitive + description: + name: kernel + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0-alpha.1.1" + logging: + dependency: transitive + description: + name: logging + url: "https://pub.dartlang.org" + source: hosted + version: "0.11.3+1" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.1+4" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + package_config: + dependency: transitive + description: + name: package_config + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.1" + path_provider: + dependency: "direct main" + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.2" + petitparser: + dependency: transitive + description: + name: petitparser + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + plugin: + dependency: transitive + description: + name: plugin + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0+2" + pool: + dependency: transitive + description: + name: pool + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.4" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.0" + sprintf: + dependency: "direct main" + description: + name: sprintf + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.2" + sqflite: + dependency: "direct main" + description: + name: sqflite + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.2+1" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + synchronized: + dependency: transitive + description: + name: synchronized + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.4" + utf: + dependency: transitive + description: + name: utf + url: "https://pub.dartlang.org" + source: hosted + version: "0.9.0+3" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + watcher: + dependency: transitive + description: + name: watcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.9.7+6" + xml: + dependency: "direct main" + description: + name: xml + url: "https://pub.dartlang.org" + source: hosted + version: "2.6.0" + yaml: + dependency: transitive + description: + name: yaml + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.13" +sdks: + dart: ">=2.0.0-dev.15.0 <=2.0.0-dev.19.0" diff --git a/pubspec.yaml b/pubspec.yaml index 357839f..7918200 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -9,6 +9,7 @@ dependencies: path_provider: "^0.2.1+1" sqflite: any image_picker: '^0.1.3' # use for ask permissions @ iOS + xml: "^2.6.0" flutter: sdk: flutter @@ -46,6 +47,8 @@ flutter: - assets/powered_by_dinect_splash.png - assets/powered_by_dinect.png - assets/splash_text.png + - assets/values-ru/strings.xml + - assets/values-ua/strings.xml # To add assets from package dependencies, first ensure the asset # is in the lib/ directory of the dependency. Then,