From 36fa0c5a2f370a2952086d8bb3bae074bfd65f9a Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 16 Mar 2020 17:24:06 +0200 Subject: [PATCH] first step form translation --- lib/i18n/ar.i18n.dart | 25 +++++++++++++++++++++++++ lib/i18n/ar.i18n.yaml | 3 +++ lib/i18n/en.i18n.dart | 25 +++++++++++++++++++++++++ lib/i18n/en.i18n.yaml | 4 ++++ lib/main.dart | 1 - lib/widgets/shared/app.drawer.dart | 8 ++++++++ pubspec.lock | 21 +++++++++++++++++++++ pubspec.yaml | 1 + 8 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 lib/i18n/ar.i18n.dart create mode 100644 lib/i18n/ar.i18n.yaml create mode 100644 lib/i18n/en.i18n.dart create mode 100644 lib/i18n/en.i18n.yaml diff --git a/lib/i18n/ar.i18n.dart b/lib/i18n/ar.i18n.dart new file mode 100644 index 00000000..2b768d19 --- /dev/null +++ b/lib/i18n/ar.i18n.dart @@ -0,0 +1,25 @@ +// GENERATED FILE, do not edit! +import 'package:i18n/i18n.dart' as i18n; + +String get _languageCode => 'en'; +String get _localeName => 'en'; + +String _plural(int count, {String zero, String one, String two, String few, String many, String other}) => + i18n.plural(count, _languageCode, zero:zero, one:one, two:two, few:few, many:many, other:other); +String _ordinal(int count, {String zero, String one, String two, String few, String many, String other}) => + i18n.ordinal(count, _languageCode, zero:zero, one:one, two:two, few:few, many:many, other:other); +String _cardinal(int count, {String zero, String one, String two, String few, String many, String other}) => + i18n.cardinal(count, _languageCode, zero:zero, one:one, two:two, few:few, many:many, other:other); + +class Ar { + const Ar(); + ButtonAr get button => ButtonAr(this); +} + +class ButtonAr { + final Ar _parent; + const ButtonAr(this._parent); + String get save => "حفظ"; + String get load => "تحميل"; +} + diff --git a/lib/i18n/ar.i18n.yaml b/lib/i18n/ar.i18n.yaml new file mode 100644 index 00000000..c59964df --- /dev/null +++ b/lib/i18n/ar.i18n.yaml @@ -0,0 +1,3 @@ +button: + save: حفظ + load: تحميل \ No newline at end of file diff --git a/lib/i18n/en.i18n.dart b/lib/i18n/en.i18n.dart new file mode 100644 index 00000000..9f06a223 --- /dev/null +++ b/lib/i18n/en.i18n.dart @@ -0,0 +1,25 @@ +// GENERATED FILE, do not edit! +import 'package:i18n/i18n.dart' as i18n; + +String get _languageCode => 'en'; +String get _localeName => 'en'; + +String _plural(int count, {String zero, String one, String two, String few, String many, String other}) => + i18n.plural(count, _languageCode, zero:zero, one:one, two:two, few:few, many:many, other:other); +String _ordinal(int count, {String zero, String one, String two, String few, String many, String other}) => + i18n.ordinal(count, _languageCode, zero:zero, one:one, two:two, few:few, many:many, other:other); +String _cardinal(int count, {String zero, String one, String two, String few, String many, String other}) => + i18n.cardinal(count, _languageCode, zero:zero, one:one, two:two, few:few, many:many, other:other); + +class En { + const En(); + ButtonEn get button => ButtonEn(this); +} + +class ButtonEn { + final En _parent; + const ButtonEn(this._parent); + String get save => "Save"; + String get load => "Load"; +} + diff --git a/lib/i18n/en.i18n.yaml b/lib/i18n/en.i18n.yaml new file mode 100644 index 00000000..a4c26572 --- /dev/null +++ b/lib/i18n/en.i18n.yaml @@ -0,0 +1,4 @@ +button: + save: Save + load: Load + diff --git a/lib/main.dart b/lib/main.dart index 3d692ae2..8b07dab4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; import './routes.dart'; - void main() => runApp(MyApp()); class MyApp extends StatelessWidget { diff --git a/lib/widgets/shared/app.drawer.dart b/lib/widgets/shared/app.drawer.dart index afcc48b2..971804fe 100644 --- a/lib/widgets/shared/app.drawer.dart +++ b/lib/widgets/shared/app.drawer.dart @@ -1,9 +1,17 @@ import '../../routes.dart'; import 'package:flutter/material.dart'; +import '../../i18n/ar.i18n.dart' as ar; +import '../../i18n/en.i18n.dart' as en; class AppDrawer extends StatelessWidget { + ar.Ar arLang = ar.Ar(); + en.En enLang = en.En(); @override Widget build(BuildContext context) { + + print(arLang.button.save); + print(enLang.button.save); + return Drawer( child: Column( children: [ diff --git a/pubspec.lock b/pubspec.lock index 99856f32..befdb1a1 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -256,6 +256,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.3" + i18n: + dependency: "direct main" + description: + name: i18n + url: "https://pub.dartlang.org" + source: hosted + version: "0.9.10" image: dependency: transitive description: @@ -403,6 +410,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.5" + quick_log: + dependency: transitive + description: + name: quick_log + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.0" quiver: dependency: transitive description: @@ -410,6 +424,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.5" + rxdart: + dependency: transitive + description: + name: rxdart + url: "https://pub.dartlang.org" + source: hosted + version: "0.23.1" scratch_space: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index cfea4cc2..86dc2163 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -24,6 +24,7 @@ dependencies: intl: ^0.16.1 http: ^0.12.0+4 provider: ^3.0.0 + i18n: any # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.