diff --git a/flutter-init.sh b/flutter-init.sh index 12ca6ea0..74486ecd 100755 --- a/flutter-init.sh +++ b/flutter-init.sh @@ -12,9 +12,7 @@ flutter config --no-analytics flutter pub get -flutter pub global activate intl_utils -flutter --no-color pub global run intl_utils:generate - +flutter gen-l10n flutter pub run flutter_oss_licenses:generate.dart mv lib/oss_licenses.dart lib/generated diff --git a/src/ui/flutter_app/l10n.yaml b/src/ui/flutter_app/l10n.yaml index 7675e023..2eea93ed 100644 --- a/src/ui/flutter_app/l10n.yaml +++ b/src/ui/flutter_app/l10n.yaml @@ -1,4 +1,20 @@ +# see https://flutter.dev/go/i18n-user-guide +# https://docs.google.com/document/d/10e0saTfAv32OZLRmONy866vnaw0I2jwL8zukykpgWBc/edit# +# +# WARNING: DO NOT translate app_XX.arb files directly here. For translations please see: +# https://weblate.rimikis.de/projects/bierverkostung/ +# (only the source language, app_en.arb is edited manually here). +# +# We are now using synthetic packages, so to use `AppLocalizations` inside the code +# you have to add the following import: +# import 'package:yahtzee_counter/l10n/app_localizations.g.dart'; + arb-dir: lib/l10n template-arb-file: intl_en.arb -output-localization-file: app_localizations.dart -untranslated-messages-file: untranslated-messages-file.txt \ No newline at end of file +output-dir: lib/generated/intl/ +output-localization-file: l10n.dart +output-class: S +untranslated-messages-file: untranslated-messages-file.txt +# use-deferred-loading: true #enable for web support +synthetic-package: false +nullable-getter: false diff --git a/src/ui/flutter_app/lib/l10n/intl_ar.arb b/src/ui/flutter_app/lib/l10n/intl_ar.arb index d4e9bf88..548af57e 100644 --- a/src/ui/flutter_app/lib/l10n/intl_ar.arb +++ b/src/ui/flutter_app/lib/l10n/intl_ar.arb @@ -1248,5 +1248,9 @@ "hollow": "أجوف", "@hollow": { "description": "Hollow" + }, + "languageName": "عربى", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_bg.arb b/src/ui/flutter_app/lib/l10n/intl_bg.arb index 19b63ddd..696c58cb 100644 --- a/src/ui/flutter_app/lib/l10n/intl_bg.arb +++ b/src/ui/flutter_app/lib/l10n/intl_bg.arb @@ -1248,5 +1248,9 @@ "hollow": "Куха", "@hollow": { "description": "Hollow" + }, + "languageName": "български", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_bn.arb b/src/ui/flutter_app/lib/l10n/intl_bn.arb index 7e452c8c..170e3d98 100644 --- a/src/ui/flutter_app/lib/l10n/intl_bn.arb +++ b/src/ui/flutter_app/lib/l10n/intl_bn.arb @@ -1248,5 +1248,9 @@ "hollow": "ফাঁপা", "@hollow": { "description": "Hollow" + }, + "languageName": "বাংলা", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_cs.arb b/src/ui/flutter_app/lib/l10n/intl_cs.arb index 41a3989c..46e4b068 100644 --- a/src/ui/flutter_app/lib/l10n/intl_cs.arb +++ b/src/ui/flutter_app/lib/l10n/intl_cs.arb @@ -1248,5 +1248,9 @@ "hollow": "Dutý", "@hollow": { "description": "Hollow" + }, + "languageName": "Čeština", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_da.arb b/src/ui/flutter_app/lib/l10n/intl_da.arb index 123a55f6..81466d9f 100644 --- a/src/ui/flutter_app/lib/l10n/intl_da.arb +++ b/src/ui/flutter_app/lib/l10n/intl_da.arb @@ -1248,5 +1248,9 @@ "hollow": "Hul", "@hollow": { "description": "Hollow" + }, + "languageName": "Dansk", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_de.arb b/src/ui/flutter_app/lib/l10n/intl_de.arb index 5c91a1bc..ac57e742 100644 --- a/src/ui/flutter_app/lib/l10n/intl_de.arb +++ b/src/ui/flutter_app/lib/l10n/intl_de.arb @@ -1248,5 +1248,9 @@ "hollow": "Hohle", "@hollow": { "description": "Hollow" + }, + "languageName": "Deutsch", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_de_ch.arb b/src/ui/flutter_app/lib/l10n/intl_de_ch.arb index 0d53f2b8..8d1f427f 100644 --- a/src/ui/flutter_app/lib/l10n/intl_de_ch.arb +++ b/src/ui/flutter_app/lib/l10n/intl_de_ch.arb @@ -1248,5 +1248,9 @@ "hollow": "Hohle", "@hollow": { "description": "Hollow" + }, + "languageName": "Schweizerdeutsch", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_el.arb b/src/ui/flutter_app/lib/l10n/intl_el.arb index a235e735..075c4a8c 100644 --- a/src/ui/flutter_app/lib/l10n/intl_el.arb +++ b/src/ui/flutter_app/lib/l10n/intl_el.arb @@ -1248,5 +1248,9 @@ "hollow": "Κοίλος", "@hollow": { "description": "Hollow" + }, + "languageName": "Ελληνικά", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_en.arb b/src/ui/flutter_app/lib/l10n/intl_en.arb index 54b08094..6633608a 100644 --- a/src/ui/flutter_app/lib/l10n/intl_en.arb +++ b/src/ui/flutter_app/lib/l10n/intl_en.arb @@ -1248,5 +1248,9 @@ "hollow": "Hollow", "@hollow": { "description": "Hollow" + }, + "languageName": "English", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_es.arb b/src/ui/flutter_app/lib/l10n/intl_es.arb index 220eedea..42b49f0a 100644 --- a/src/ui/flutter_app/lib/l10n/intl_es.arb +++ b/src/ui/flutter_app/lib/l10n/intl_es.arb @@ -1248,5 +1248,9 @@ "hollow": "Hueco", "@hollow": { "description": "Hollow" + }, + "languageName": "Español", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_et.arb b/src/ui/flutter_app/lib/l10n/intl_et.arb index 67217bee..3fffe2ae 100644 --- a/src/ui/flutter_app/lib/l10n/intl_et.arb +++ b/src/ui/flutter_app/lib/l10n/intl_et.arb @@ -1248,5 +1248,9 @@ "hollow": "Õõnes", "@hollow": { "description": "Hollow" + }, + "languageName": "Eestlane", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_fa.arb b/src/ui/flutter_app/lib/l10n/intl_fa.arb index 73fee674..0cf9a95c 100644 --- a/src/ui/flutter_app/lib/l10n/intl_fa.arb +++ b/src/ui/flutter_app/lib/l10n/intl_fa.arb @@ -1248,5 +1248,9 @@ "hollow": "توخالی", "@hollow": { "description": "Hollow" + }, + "languageName": "فارسی", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_fi.arb b/src/ui/flutter_app/lib/l10n/intl_fi.arb index 973703d1..87828700 100644 --- a/src/ui/flutter_app/lib/l10n/intl_fi.arb +++ b/src/ui/flutter_app/lib/l10n/intl_fi.arb @@ -1248,5 +1248,9 @@ "hollow": "Ontto", "@hollow": { "description": "Hollow" + }, + "languageName": "Suomalainen", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_fr.arb b/src/ui/flutter_app/lib/l10n/intl_fr.arb index 5cfe85c0..413b732b 100644 --- a/src/ui/flutter_app/lib/l10n/intl_fr.arb +++ b/src/ui/flutter_app/lib/l10n/intl_fr.arb @@ -1248,5 +1248,9 @@ "hollow": "Creux", "@hollow": { "description": "Hollow" + }, + "languageName": "Français", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_gu.arb b/src/ui/flutter_app/lib/l10n/intl_gu.arb index 8424f4b7..ff803f09 100644 --- a/src/ui/flutter_app/lib/l10n/intl_gu.arb +++ b/src/ui/flutter_app/lib/l10n/intl_gu.arb @@ -1248,5 +1248,9 @@ "hollow": "હોલો", "@hollow": { "description": "Hollow" + }, + "languageName": "ગુજરાતી", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_hi.arb b/src/ui/flutter_app/lib/l10n/intl_hi.arb index 4264869c..63b50aa0 100644 --- a/src/ui/flutter_app/lib/l10n/intl_hi.arb +++ b/src/ui/flutter_app/lib/l10n/intl_hi.arb @@ -1248,5 +1248,9 @@ "hollow": "खोखला", "@hollow": { "description": "Hollow" + }, + "languageName": "हिंदी", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_hr.arb b/src/ui/flutter_app/lib/l10n/intl_hr.arb index 21caf8d7..c73d5808 100644 --- a/src/ui/flutter_app/lib/l10n/intl_hr.arb +++ b/src/ui/flutter_app/lib/l10n/intl_hr.arb @@ -1248,5 +1248,9 @@ "hollow": "Šuplje", "@hollow": { "description": "Hollow" + }, + "languageName": "Hrvatski", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_hu.arb b/src/ui/flutter_app/lib/l10n/intl_hu.arb index 1e84a4bf..42d52f07 100644 --- a/src/ui/flutter_app/lib/l10n/intl_hu.arb +++ b/src/ui/flutter_app/lib/l10n/intl_hu.arb @@ -1248,5 +1248,9 @@ "hollow": "Üreges", "@hollow": { "description": "Hollow" + }, + "languageName": "Magyar", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_id.arb b/src/ui/flutter_app/lib/l10n/intl_id.arb index 04f71567..f8b15ef5 100644 --- a/src/ui/flutter_app/lib/l10n/intl_id.arb +++ b/src/ui/flutter_app/lib/l10n/intl_id.arb @@ -1248,5 +1248,9 @@ "hollow": "Kosong", "@hollow": { "description": "Hollow" + }, + "languageName": "Indonesia", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_it.arb b/src/ui/flutter_app/lib/l10n/intl_it.arb index d2ff57de..06ea5322 100644 --- a/src/ui/flutter_app/lib/l10n/intl_it.arb +++ b/src/ui/flutter_app/lib/l10n/intl_it.arb @@ -1248,5 +1248,9 @@ "hollow": "Vuoto", "@hollow": { "description": "Hollow" + }, + "languageName": "Italiano", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_ja.arb b/src/ui/flutter_app/lib/l10n/intl_ja.arb index cc0e3f7a..2d6736bc 100644 --- a/src/ui/flutter_app/lib/l10n/intl_ja.arb +++ b/src/ui/flutter_app/lib/l10n/intl_ja.arb @@ -1248,5 +1248,9 @@ "hollow": "中空円", "@hollow": { "description": "Hollow" + }, + "languageName": "日本語", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_kn.arb b/src/ui/flutter_app/lib/l10n/intl_kn.arb index b471ccbf..6157fc65 100644 --- a/src/ui/flutter_app/lib/l10n/intl_kn.arb +++ b/src/ui/flutter_app/lib/l10n/intl_kn.arb @@ -1248,5 +1248,9 @@ "hollow": "ಟೊಳ್ಳು", "@hollow": { "description": "Hollow" + }, + "languageName": "ಕನ್ನಡ", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_ko.arb b/src/ui/flutter_app/lib/l10n/intl_ko.arb index b804fd65..53d16170 100644 --- a/src/ui/flutter_app/lib/l10n/intl_ko.arb +++ b/src/ui/flutter_app/lib/l10n/intl_ko.arb @@ -1248,5 +1248,9 @@ "hollow": "구멍", "@hollow": { "description": "Hollow" + }, + "languageName": "한국어", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_lt.arb b/src/ui/flutter_app/lib/l10n/intl_lt.arb index 5b877afa..2fece777 100644 --- a/src/ui/flutter_app/lib/l10n/intl_lt.arb +++ b/src/ui/flutter_app/lib/l10n/intl_lt.arb @@ -1248,5 +1248,9 @@ "hollow": "Tuščiaviduriai", "@hollow": { "description": "Hollow" + }, + "languageName": "Lietuvis", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_lv.arb b/src/ui/flutter_app/lib/l10n/intl_lv.arb index a7ca5f79..9583a915 100644 --- a/src/ui/flutter_app/lib/l10n/intl_lv.arb +++ b/src/ui/flutter_app/lib/l10n/intl_lv.arb @@ -1248,5 +1248,9 @@ "hollow": "Dobis", "@hollow": { "description": "Hollow" + }, + "languageName": "Latvietis", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_mk.arb b/src/ui/flutter_app/lib/l10n/intl_mk.arb index 7577241c..3f2ce959 100644 --- a/src/ui/flutter_app/lib/l10n/intl_mk.arb +++ b/src/ui/flutter_app/lib/l10n/intl_mk.arb @@ -1248,5 +1248,9 @@ "hollow": "Шупливи", "@hollow": { "description": "Hollow" + }, + "languageName": "Македонски", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_ms.arb b/src/ui/flutter_app/lib/l10n/intl_ms.arb index 9f333f0d..9b70ec7e 100644 --- a/src/ui/flutter_app/lib/l10n/intl_ms.arb +++ b/src/ui/flutter_app/lib/l10n/intl_ms.arb @@ -1248,5 +1248,9 @@ "hollow": "Berongga", "@hollow": { "description": "Hollow" + }, + "languageName": "Melayu", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_nl.arb b/src/ui/flutter_app/lib/l10n/intl_nl.arb index e6268b59..71bc9f76 100644 --- a/src/ui/flutter_app/lib/l10n/intl_nl.arb +++ b/src/ui/flutter_app/lib/l10n/intl_nl.arb @@ -1248,5 +1248,9 @@ "hollow": "Hol", "@hollow": { "description": "Hollow" + }, + "languageName": "Nederlands", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_nn.arb b/src/ui/flutter_app/lib/l10n/intl_nn.arb index 4b6699bb..8984e50e 100644 --- a/src/ui/flutter_app/lib/l10n/intl_nn.arb +++ b/src/ui/flutter_app/lib/l10n/intl_nn.arb @@ -1248,5 +1248,9 @@ "hollow": "Hul", "@hollow": { "description": "Hollow" + }, + "languageName": "Norsk", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_pl.arb b/src/ui/flutter_app/lib/l10n/intl_pl.arb index 1f7ef535..40a87c0b 100644 --- a/src/ui/flutter_app/lib/l10n/intl_pl.arb +++ b/src/ui/flutter_app/lib/l10n/intl_pl.arb @@ -1248,5 +1248,9 @@ "hollow": "Dziurawy", "@hollow": { "description": "Hollow" + }, + "languageName": "Polskie", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_pt.arb b/src/ui/flutter_app/lib/l10n/intl_pt.arb index cd09ce01..74fd83b1 100644 --- a/src/ui/flutter_app/lib/l10n/intl_pt.arb +++ b/src/ui/flutter_app/lib/l10n/intl_pt.arb @@ -1248,5 +1248,9 @@ "hollow": "Oco", "@hollow": { "description": "Hollow" + }, + "languageName": "Português", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_ro.arb b/src/ui/flutter_app/lib/l10n/intl_ro.arb index f37cdbc2..b46d0263 100644 --- a/src/ui/flutter_app/lib/l10n/intl_ro.arb +++ b/src/ui/flutter_app/lib/l10n/intl_ro.arb @@ -1248,5 +1248,9 @@ "hollow": "Gol", "@hollow": { "description": "Hollow" + }, + "languageName": "Română", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_ru.arb b/src/ui/flutter_app/lib/l10n/intl_ru.arb index 51b20362..c9c44b30 100644 --- a/src/ui/flutter_app/lib/l10n/intl_ru.arb +++ b/src/ui/flutter_app/lib/l10n/intl_ru.arb @@ -1248,5 +1248,9 @@ "hollow": "Пустой", "@hollow": { "description": "Hollow" + }, + "languageName": "Pусский", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_sk.arb b/src/ui/flutter_app/lib/l10n/intl_sk.arb index d633dc40..9112eb35 100644 --- a/src/ui/flutter_app/lib/l10n/intl_sk.arb +++ b/src/ui/flutter_app/lib/l10n/intl_sk.arb @@ -1248,5 +1248,9 @@ "hollow": "Dutý", "@hollow": { "description": "Hollow" + }, + "languageName": "Slovák", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_sl.arb b/src/ui/flutter_app/lib/l10n/intl_sl.arb index cfe15194..60693992 100644 --- a/src/ui/flutter_app/lib/l10n/intl_sl.arb +++ b/src/ui/flutter_app/lib/l10n/intl_sl.arb @@ -1248,5 +1248,9 @@ "hollow": "Votlo", "@hollow": { "description": "Hollow" + }, + "languageName": "Slovenščina", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_sq.arb b/src/ui/flutter_app/lib/l10n/intl_sq.arb index 32e3ce0b..0c88cd51 100644 --- a/src/ui/flutter_app/lib/l10n/intl_sq.arb +++ b/src/ui/flutter_app/lib/l10n/intl_sq.arb @@ -1248,5 +1248,9 @@ "hollow": "Zgavër", "@hollow": { "description": "Hollow" + }, + "languageName": "Shqiptare", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_sr.arb b/src/ui/flutter_app/lib/l10n/intl_sr.arb index 634f9592..a6d6c860 100644 --- a/src/ui/flutter_app/lib/l10n/intl_sr.arb +++ b/src/ui/flutter_app/lib/l10n/intl_sr.arb @@ -1248,5 +1248,9 @@ "hollow": "Холлов", "@hollow": { "description": "Hollow" + }, + "languageName": "Српски", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_sv.arb b/src/ui/flutter_app/lib/l10n/intl_sv.arb index f038672f..7ef61339 100644 --- a/src/ui/flutter_app/lib/l10n/intl_sv.arb +++ b/src/ui/flutter_app/lib/l10n/intl_sv.arb @@ -1248,5 +1248,9 @@ "hollow": "Ihålig", "@hollow": { "description": "Hollow" + }, + "languageName": "Svenska", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_te.arb b/src/ui/flutter_app/lib/l10n/intl_te.arb index 91526e45..d8b56bf1 100644 --- a/src/ui/flutter_app/lib/l10n/intl_te.arb +++ b/src/ui/flutter_app/lib/l10n/intl_te.arb @@ -1248,5 +1248,9 @@ "hollow": "బోలు", "@hollow": { "description": "Hollow" + }, + "languageName": "తెలుగు", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_th.arb b/src/ui/flutter_app/lib/l10n/intl_th.arb index 798ef3a4..129168b0 100644 --- a/src/ui/flutter_app/lib/l10n/intl_th.arb +++ b/src/ui/flutter_app/lib/l10n/intl_th.arb @@ -1248,5 +1248,9 @@ "hollow": "กลวง", "@hollow": { "description": "Hollow" + }, + "languageName": "ไทย", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_tr.arb b/src/ui/flutter_app/lib/l10n/intl_tr.arb index 759f6962..cbf149a1 100644 --- a/src/ui/flutter_app/lib/l10n/intl_tr.arb +++ b/src/ui/flutter_app/lib/l10n/intl_tr.arb @@ -1248,5 +1248,9 @@ "hollow": "Oyuk", "@hollow": { "description": "Hollow" + }, + "languageName": "Türk", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_uz.arb b/src/ui/flutter_app/lib/l10n/intl_uz.arb index 17459547..8bf19166 100644 --- a/src/ui/flutter_app/lib/l10n/intl_uz.arb +++ b/src/ui/flutter_app/lib/l10n/intl_uz.arb @@ -1248,5 +1248,9 @@ "hollow": "Ichi bo'sh", "@hollow": { "description": "Hollow" + }, + "languageName": "O'zbek", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_vi.arb b/src/ui/flutter_app/lib/l10n/intl_vi.arb index 8a1568e0..5c608e01 100644 --- a/src/ui/flutter_app/lib/l10n/intl_vi.arb +++ b/src/ui/flutter_app/lib/l10n/intl_vi.arb @@ -1248,5 +1248,9 @@ "hollow": "Rỗng", "@hollow": { "description": "Hollow" + }, + "languageName": "Tiếng Việt", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_zh.arb b/src/ui/flutter_app/lib/l10n/intl_zh.arb index 7e4f89f2..30eefb0c 100644 --- a/src/ui/flutter_app/lib/l10n/intl_zh.arb +++ b/src/ui/flutter_app/lib/l10n/intl_zh.arb @@ -1248,5 +1248,9 @@ "hollow": "空心圆", "@hollow": { "description": "Hollow" + }, + "languageName": "简体中文", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/intl_zh_Hant.arb b/src/ui/flutter_app/lib/l10n/intl_zh_Hant.arb index ab8a73ef..b728b3a7 100644 --- a/src/ui/flutter_app/lib/l10n/intl_zh_Hant.arb +++ b/src/ui/flutter_app/lib/l10n/intl_zh_Hant.arb @@ -1248,5 +1248,9 @@ "hollow": "空心圓", "@hollow": { "description": "Hollow" + }, + "languageName": "繁體中文", + "@languageName": { + "description": "The name of the current language" } -} \ No newline at end of file +} diff --git a/src/ui/flutter_app/lib/l10n/resources.dart b/src/ui/flutter_app/lib/l10n/resources.dart deleted file mode 100644 index 3c39e79b..00000000 --- a/src/ui/flutter_app/lib/l10n/resources.dart +++ /dev/null @@ -1,598 +0,0 @@ -/* - This file is part of Sanmill. - Copyright (C) 2019-2021 The Sanmill developers (see AUTHORS file) - - Sanmill is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Sanmill is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -import 'dart:io'; - -import 'package:flutter/material.dart'; -import 'package:sanmill/generated/l10n.dart'; -import 'package:sanmill/services/storage/storage.dart'; -import 'package:sanmill/shared/constants.dart'; -import 'package:sanmill/shared/list_item_divider.dart'; -import 'package:sanmill/shared/theme/app_theme.dart'; - -Map languageCodeToStrings = { - const Locale("ar"): ArabicStrings(), - const Locale("bg"): BulgarianStrings(), - const Locale("bn"): BengaliStrings(), - const Locale("cs"): CzechStrings(), - const Locale("da"): DanishStrings(), - const Locale("de"): GermanStrings(), - const Locale("de_CH"): SwissGermanStrings(), - const Locale("el"): GreekStrings(), - const Locale("en"): EnglishStrings(), - const Locale("es"): SpanishStrings(), - const Locale("et"): EstonianStrings(), - const Locale("fa"): FarsiStrings(), - const Locale("fi"): FinnishStrings(), - const Locale("fr"): FrenchStrings(), - const Locale("gu"): GujaratiStrings(), - const Locale("hi"): HindiStrings(), - const Locale("hr"): CroatianStrings(), - const Locale("hu"): HungarianStrings(), - const Locale("id"): IndonesianStrings(), - const Locale("it"): ItalianStrings(), - const Locale("ja"): JapaneseStrings(), - const Locale("kn"): KannadaStrings(), - const Locale("ko"): KoreanStrings(), - const Locale("lt"): LithuanianStrings(), - const Locale("lv"): LatvianStrings(), - const Locale("mk"): MacedonianStrings(), - const Locale("ms"): MalayStrings(), - const Locale("nl"): DutchStrings(), - const Locale("nn"): NorwegianStrings(), - const Locale("pl"): PolishStrings(), - const Locale("pt"): PortugueseStrings(), - const Locale("ro"): RomanianStrings(), - const Locale("ru"): RussianStrings(), - const Locale("sk"): SlovakStrings(), - const Locale("sl"): SlovenianStrings(), - const Locale("sq"): AlbanianStrings(), - const Locale("sr"): SerbianStrings(), - const Locale("sv"): SwedishStrings(), - const Locale("te"): TeluguStrings(), - const Locale("th"): ThaiStrings(), - const Locale("tr"): TurkishStrings(), - const Locale("uz"): UzbekStrings(), - const Locale("vi"): VietnameseStrings(), - const Locale("zh"): ChineseStrings(), - const Locale("zh_Hant"): TraditionalChineseStrings(), -}; - -/// Interface strings -abstract class Strings { - String get languageName; - String get tapBackAgainToLeave; -} - -/// ar -class ArabicStrings extends Strings { - @override - String get languageName => 'عربى'; - - @override - String get tapBackAgainToLeave => 'انقر مرة أخرى للمغادرة.'; -} - -/// bg -class BulgarianStrings extends Strings { - @override - String get languageName => 'български'; - - @override - String get tapBackAgainToLeave => 'Докоснете отново назад, за да излезете.'; -} - -/// bn -class BengaliStrings extends Strings { - @override - String get languageName => 'বাংলা'; - - @override - String get tapBackAgainToLeave => 'ছেড়ে যেতে আবার আলতো চাপুন।'; -} - -/// cs -class CzechStrings extends Strings { - @override - String get languageName => 'Čeština'; - - @override - String get tapBackAgainToLeave => 'Opětovným klepnutím zpět odejdete.'; -} - -/// da -class DanishStrings extends Strings { - @override - String get languageName => 'Dansk'; - - @override - String get tapBackAgainToLeave => 'Tryk tilbage igen for at gå.'; -} - -/// de -class GermanStrings extends Strings { - @override - String get languageName => 'Deutsch'; - - @override - String get tapBackAgainToLeave => 'Nochmal drücken um zu Beenden.'; -} - -/// de-ch -class SwissGermanStrings extends Strings { - @override - String get languageName => 'Schweizerdeutsch'; - - @override - String get tapBackAgainToLeave => 'Nochmal drücken um zu Beenden.'; -} - -/// el -class GreekStrings extends Strings { - @override - String get languageName => 'Ελληνικά'; - - @override - String get tapBackAgainToLeave => 'Πατήστε ξανά πίσω για να φύγετε.'; -} - -/// en -class EnglishStrings extends Strings { - @override - String get languageName => 'English'; - - @override - String get tapBackAgainToLeave => 'Tap back again to leave.'; -} - -/// es -class SpanishStrings extends Strings { - @override - String get languageName => 'Español'; - - @override - String get tapBackAgainToLeave => 'Vuelva a tocar para salir.'; -} - -/// et -class EstonianStrings extends Strings { - @override - String get languageName => 'Eestlane'; - - @override - String get tapBackAgainToLeave => 'Koputage uuesti tagasi, et lahkuda.'; -} - -/// fa -class FarsiStrings extends Strings { - @override - String get languageName => 'فارسی'; - - @override - String get tapBackAgainToLeave => - 'برای خروج از برنامه ، دوباره روی دکمه برگشت ضربه بزنید.'; -} - -/// fi -class FinnishStrings extends Strings { - @override - String get languageName => 'Suomalainen'; - - @override - String get tapBackAgainToLeave => 'Poistu napauttamalla uudelleen takaisin.'; -} - -/// fr -class FrenchStrings extends Strings { - @override - String get languageName => 'Français'; - - @override - String get tapBackAgainToLeave => 'Tapez à nouveau pour quitter.'; -} - -/// gu -class GujaratiStrings extends Strings { - @override - String get languageName => 'ગુજરાતી'; - - @override - String get tapBackAgainToLeave => 'જવા માટે ફરીથી ટેપ કરો.'; -} - -/// hi -class HindiStrings extends Strings { - @override - String get languageName => 'हिंदी'; - - @override - String get tapBackAgainToLeave => 'जाने के लिए फिर से टैप करें।'; -} - -/// hr -class CroatianStrings extends Strings { - @override - String get languageName => 'Hrvatski'; - - @override - String get tapBackAgainToLeave => 'Ponovno dodirnite za napuštanje.'; -} - -/// hu -class HungarianStrings extends Strings { - @override - String get languageName => 'Magyar'; - - @override - String get tapBackAgainToLeave => - 'A kilépéshez kattintson ismételten a Vissza gombra.'; -} - -/// id -class IndonesianStrings extends Strings { - @override - String get languageName => 'Indonesia'; - - @override - String get tapBackAgainToLeave => 'Ketuk kembali lagi untuk pergi.'; -} - -/// it -class ItalianStrings extends Strings { - @override - String get languageName => 'Italiano'; - - @override - String get tapBackAgainToLeave => 'Tocca di nuovo per uscire.'; -} - -/// ja -class JapaneseStrings extends Strings { - @override - String get languageName => '日本語'; - - @override - String get tapBackAgainToLeave => 'もう一度returnを押してアプリケーションを終了する'; -} - -/// kn -class KannadaStrings extends Strings { - @override - String get languageName => 'ಕನ್ನಡ'; - - @override - String get tapBackAgainToLeave => 'ಬಿಡಲು ಮತ್ತೆ ಟ್ಯಾಪ್ ಮಾಡಿ.'; -} - -/// ko -class KoreanStrings extends Strings { - @override - String get languageName => '한국어'; - - @override - String get tapBackAgainToLeave => '애플리케이션을 종료하려면 리턴 키를 다시 누르십시오.'; -} - -/// lt -class LithuanianStrings extends Strings { - @override - String get languageName => 'Lietuvis'; - - @override - String get tapBackAgainToLeave => - 'Dar kartą bakstelėkite atgal, kad išeitumėte.'; -} - -/// lv -class LatvianStrings extends Strings { - @override - String get languageName => 'Latvietis'; - - @override - String get tapBackAgainToLeave => 'Pieskarieties atpakaļ, lai izietu.'; -} - -/// mk -class MacedonianStrings extends Strings { - @override - String get languageName => 'Македонски'; - - @override - String get tapBackAgainToLeave => 'Допрете назад за да заминете.'; -} - -/// ms -class MalayStrings extends Strings { - @override - String get languageName => 'Melayu'; - - @override - String get tapBackAgainToLeave => 'Ketik kembali sekali lagi untuk pergi.'; -} - -/// nl -class DutchStrings extends Strings { - @override - String get languageName => 'Nederlands'; - - @override - String get tapBackAgainToLeave => 'Tik opnieuw om te vertrekken.'; -} - -/// nn -class NorwegianStrings extends Strings { - @override - String get languageName => 'Norsk'; - - @override - String get tapBackAgainToLeave => 'Trykk tilbake for å dra.'; -} - -/// pl -class PolishStrings extends Strings { - @override - String get languageName => 'Polskie'; - - @override - String get tapBackAgainToLeave => 'Stuknij ponownie w tył, aby wyjść.'; -} - -/// pt -class PortugueseStrings extends Strings { - @override - String get languageName => 'Português'; - - @override - String get tapBackAgainToLeave => 'Toque novamente para sair.'; -} - -/// ro -class RomanianStrings extends Strings { - @override - String get languageName => 'Română'; - - @override - String get tapBackAgainToLeave => 'Atingeți din nou pentru a putea muta.'; -} - -/// ru -class RussianStrings extends Strings { - @override - String get languageName => 'Pусский'; - - @override - String get tapBackAgainToLeave => 'Нажмите назад еще раз, чтобы выйти.'; -} - -/// sk -class SlovakStrings extends Strings { - @override - String get languageName => 'Slovák'; - - @override - String get tapBackAgainToLeave => 'Ťuknutím na tlačidlo späť znova odíďte.'; -} - -/// sl -class SlovenianStrings extends Strings { - @override - String get languageName => 'Slovenščina'; - - @override - String get tapBackAgainToLeave => - 'Ponovno se dotaknite nazaj, če želite oditi.'; -} - -/// sq -class AlbanianStrings extends Strings { - @override - String get languageName => 'Shqiptare'; - - @override - String get tapBackAgainToLeave => 'Trokit përsëri përsëri për t\'u larguar.'; -} - -/// sr -class SerbianStrings extends Strings { - @override - String get languageName => 'Српски'; - - @override - String get tapBackAgainToLeave => 'Додирните поново да бисте изашли.'; -} - -/// sv -class SwedishStrings extends Strings { - @override - String get languageName => 'Svenska'; - - @override - String get tapBackAgainToLeave => 'Tryck tillbaka igen för att gå vidare.'; -} - -/// te -class TeluguStrings extends Strings { - @override - String get languageName => 'తెలుగు'; - - @override - String get tapBackAgainToLeave => 'బయలుదేరడానికి మళ్ళీ నొక్కండి.'; -} - -/// th -class ThaiStrings extends Strings { - @override - String get languageName => 'ไทย'; - - @override - String get tapBackAgainToLeave => 'แตะกลับอีกครั้งเพื่อออก'; -} - -/// tr -class TurkishStrings extends Strings { - @override - String get languageName => 'Türk'; - - @override - String get tapBackAgainToLeave => 'Tocca di nuovo per uscire.'; -} - -/// uz -class UzbekStrings extends Strings { - @override - String get languageName => 'O\'zbek'; - - @override - String get tapBackAgainToLeave => 'Ketish uchun yana bir marta bosing.'; -} - -/// vi -class VietnameseStrings extends Strings { - @override - String get languageName => 'Tiếng Việt'; - - @override - String get tapBackAgainToLeave => - 'Nhấn phím quay lại một lần nữa để thoát ứng dụng.'; -} - -/// zh -class ChineseStrings extends Strings { - @override - String get languageName => '简体中文'; - - @override - String get tapBackAgainToLeave => '再次按返回键退出应用'; -} - -/// zh-Hant -class TraditionalChineseStrings extends Strings { - @override - String get languageName => '繁體中文'; - - @override - String get tapBackAgainToLeave => '再次按 Back 鍵退出'; -} - -final List supportedLocales = [ - ...languageCodeToStrings.keys, -]; - -class Resources { - Resources(); - - String get languageCode { - if (LocalDatabaseService.display.languageCode == Constants.defaultLocale) { - return Platform.localeName.substring(0, 2); - } - - return LocalDatabaseService.display.languageCode.languageCode; - } - - Strings get strings { - final Strings? ret = languageCodeToStrings[languageCode]; - - if (ret == null) { - return EnglishStrings(); - } - - return ret; - } - - // ignore: prefer_constructors_over_static_methods - static Resources of() { - return Resources(); - } -} - -Future setLanguage( - BuildContext context, - Function(Locale?)? callback, -) async { - final languageColumn = Column( - mainAxisSize: MainAxisSize.min, - children: [ - RadioListTile( - activeColor: AppTheme.switchListTileActiveColor, - title: Text(S.of(context).defaultLanguage), - groupValue: LocalDatabaseService.display.languageCode, - value: Constants.defaultLocale, - onChanged: callback, - ), - const ListItemDivider(), - for (var i in languageCodeToStrings.keys) - RadioListTile( - activeColor: AppTheme.switchListTileActiveColor, - title: Text(languageCodeToStrings[i]!.languageName), - groupValue: LocalDatabaseService.display.languageCode, - value: i, - onChanged: callback, - ), - ], - ); - - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - scrollable: true, - content: StatefulBuilder( - builder: (BuildContext context, StateSetter setState) { - return languageColumn; - }, - ), - ); - }, - ); -} - -enum Bidirectionality { - leftToRight, - rightToLeft, -} - -Bidirectionality getBidirectionality(BuildContext context) { - final Locale currentLocale = Localizations.localeOf(context); - if (currentLocale.languageCode == "ar" || - currentLocale.languageCode == "fa" || - currentLocale.languageCode == "he" || - currentLocale.languageCode == "ps" || - currentLocale.languageCode == "ur") { - debugPrint("bidirectionality: RTL"); - return Bidirectionality.rightToLeft; - } else { - return Bidirectionality.leftToRight; - } -} - -String specialCountryAndRegion = ""; - -void setSpecialCountryAndRegion(BuildContext context) { - final Locale currentLocale = Localizations.localeOf(context); - - switch (currentLocale.countryCode) { - case "IR": - specialCountryAndRegion = "Iran"; - break; - default: - specialCountryAndRegion = ""; - break; - } - - debugPrint("Set Special Country and Region to $specialCountryAndRegion."); -} diff --git a/src/ui/flutter_app/lib/main.dart b/src/ui/flutter_app/lib/main.dart index 57e3ef3b..6a999b5e 100644 --- a/src/ui/flutter_app/lib/main.dart +++ b/src/ui/flutter_app/lib/main.dart @@ -24,12 +24,13 @@ import 'package:double_back_to_close_app/double_back_to_close_app.dart'; import 'package:feedback/feedback.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:hive_flutter/hive_flutter.dart' show Box; import 'package:path_provider/path_provider.dart'; -import 'package:sanmill/generated/l10n.dart'; -import 'package:sanmill/l10n/resources.dart'; +import 'package:sanmill/generated/intl/l10n.dart'; +import 'package:sanmill/models/display.dart'; import 'package:sanmill/screens/navigation_home_screen.dart'; import 'package:sanmill/services/audios.dart'; +import 'package:sanmill/services/language_info.dart'; import 'package:sanmill/services/storage/storage.dart'; import 'package:sanmill/services/storage/storage_v1.dart'; import 'package:sanmill/shared/constants.dart'; @@ -84,38 +85,44 @@ class SanmillApp extends StatelessWidget { setSpecialCountryAndRegion(context); - return MaterialApp( - /// Add navigator key from Catcher. - /// It will be used to navigate user to report page or to show dialog. - navigatorKey: Catcher.navigatorKey, - key: globalScaffoldKey, - navigatorObservers: [routeObserver], - localizationsDelegates: const [ - // ... app-specific localization delegate[s] here - S.delegate, - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - GlobalCupertinoLocalizations.delegate, - ], - supportedLocales: supportedLocales, - theme: AppTheme.lightThemeData, - darkTheme: AppTheme.darkThemeData, - debugShowCheckedModeBanner: false, - home: Scaffold( - body: DoubleBackToCloseApp( - snackBar: SnackBar( - content: Text(Resources.of().strings.tapBackAgainToLeave), - ), - child: NavigationHomeScreen(), - ), - ), - /* - WillPopScope( - onWillPop: () async { - Audios.disposePool(); - return true; - }, - */ + return ValueListenableBuilder( + valueListenable: LocalDatabaseService.listenDisplay, + builder: (BuildContext context, Box displayBox, _) { + final Display _display = displayBox.get( + LocalDatabaseService.displayKey, + defaultValue: Display(), + )!; + return MaterialApp( + /// Add navigator key from Catcher. + /// It will be used to navigate user to report page or to show dialog. + navigatorKey: Catcher.navigatorKey, + key: globalScaffoldKey, + navigatorObservers: [routeObserver], + localizationsDelegates: S.localizationsDelegates, + supportedLocales: S.supportedLocales, + locale: _display.languageCode, + theme: AppTheme.lightThemeData, + darkTheme: AppTheme.darkThemeData, + debugShowCheckedModeBanner: false, + home: const _Home(), + ); + }, + ); + } +} + +class _Home extends StatelessWidget { + const _Home({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: DoubleBackToCloseApp( + snackBar: SnackBar( + content: Text(S.of(context).tapBackAgainToLeave), + ), + child: const NavigationHomeScreen(), + ), ); } } diff --git a/src/ui/flutter_app/lib/mill/rule.dart b/src/ui/flutter_app/lib/mill/rule.dart index a9e9c39b..b6073fac 100644 --- a/src/ui/flutter_app/lib/mill/rule.dart +++ b/src/ui/flutter_app/lib/mill/rule.dart @@ -16,7 +16,7 @@ along with this program. If not, see . */ -import 'package:sanmill/l10n/resources.dart'; +import 'package:sanmill/services/language_info.dart'; // TODO: deprecate this thingy. No reason to keep it class Rule { diff --git a/src/ui/flutter_app/lib/models/display.dart b/src/ui/flutter_app/lib/models/display.dart index 1473cfe9..303e4781 100644 --- a/src/ui/flutter_app/lib/models/display.dart +++ b/src/ui/flutter_app/lib/models/display.dart @@ -30,7 +30,7 @@ part 'display.g.dart'; /// holds the data needed for the Display Settings @HiveType(typeId: 1) @JsonSerializable() -@CopyWith() +@CopyWith(generateCopyWithNull: true) @immutable class Display { Display({ @@ -57,7 +57,7 @@ class Display { fromJson: LocaleAdapter.colorFromJson, toJson: LocaleAdapter.colorToJson, ) - final Locale languageCode; + final Locale? languageCode; @HiveField(1) final bool standardNotationEnabled; diff --git a/src/ui/flutter_app/lib/models/rules.dart b/src/ui/flutter_app/lib/models/rules.dart index 4fec4507..ea8bf8af 100644 --- a/src/ui/flutter_app/lib/models/rules.dart +++ b/src/ui/flutter_app/lib/models/rules.dart @@ -20,7 +20,7 @@ import 'package:copy_with_extension/copy_with_extension.dart'; import 'package:flutter/foundation.dart' show immutable; import 'package:hive_flutter/adapters.dart'; import 'package:json_annotation/json_annotation.dart'; -import 'package:sanmill/l10n/resources.dart'; +import 'package:sanmill/services/language_info.dart'; part 'rules.g.dart'; diff --git a/src/ui/flutter_app/lib/screens/about_page.dart b/src/ui/flutter_app/lib/screens/about_page.dart index 90794b11..bd9e9551 100644 --- a/src/ui/flutter_app/lib/screens/about_page.dart +++ b/src/ui/flutter_app/lib/screens/about_page.dart @@ -23,7 +23,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:sanmill/generated/flutter_version.dart'; -import 'package:sanmill/generated/l10n.dart'; +import 'package:sanmill/generated/intl/l10n.dart'; import 'package:sanmill/screens/license_page.dart'; import 'package:sanmill/screens/oss_license_page.dart'; import 'package:sanmill/shared/constants.dart'; diff --git a/src/ui/flutter_app/lib/screens/env_page.dart b/src/ui/flutter_app/lib/screens/env_page.dart index 6dda2136..424a8f89 100644 --- a/src/ui/flutter_app/lib/screens/env_page.dart +++ b/src/ui/flutter_app/lib/screens/env_page.dart @@ -18,7 +18,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart' show rootBundle; -import 'package:sanmill/generated/l10n.dart'; +import 'package:sanmill/generated/intl/l10n.dart'; import 'package:sanmill/shared/constants.dart'; class EnvironmentVariablesPage extends StatelessWidget { diff --git a/src/ui/flutter_app/lib/screens/game_page/board.dart b/src/ui/flutter_app/lib/screens/game_page/board.dart index 39ac0d9c..426430f0 100644 --- a/src/ui/flutter_app/lib/screens/game_page/board.dart +++ b/src/ui/flutter_app/lib/screens/game_page/board.dart @@ -240,8 +240,8 @@ class Board extends StatelessWidget { 1 ]; - final bool ltr = - getBidirectionality(context) == Bidirectionality.leftToRight; + final bool ltr = Directionality.of(context) == TextDirection.ltr; + if (ltr) { for (final file in ['a', 'b', 'c', 'd', 'e', 'f', 'g']) { diff --git a/src/ui/flutter_app/lib/screens/game_page/game_page.dart b/src/ui/flutter_app/lib/screens/game_page/game_page.dart index 608ea8d0..7993de7a 100644 --- a/src/ui/flutter_app/lib/screens/game_page/game_page.dart +++ b/src/ui/flutter_app/lib/screens/game_page/game_page.dart @@ -23,8 +23,7 @@ import 'dart:async'; import 'package:fluentui_system_icons/fluentui_system_icons.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:sanmill/generated/l10n.dart'; -import 'package:sanmill/l10n/resources.dart'; +import 'package:sanmill/generated/intl/l10n.dart'; import 'package:sanmill/main.dart'; import 'package:sanmill/mill/game.dart'; import 'package:sanmill/mill/position.dart'; @@ -36,7 +35,6 @@ import 'package:sanmill/services/audios.dart'; import 'package:sanmill/services/engine/engine.dart'; import 'package:sanmill/services/engine/native_engine.dart'; import 'package:sanmill/services/storage/storage.dart'; -import 'package:sanmill/shared/constants.dart'; import 'package:sanmill/shared/dialog.dart'; import 'package:sanmill/shared/picker.dart'; import 'package:sanmill/shared/snack_bar.dart'; @@ -1793,10 +1791,12 @@ class _GamePageState extends State _initAnimation(); - LocalDatabaseService.listenPreferences.addListener(() async { - await _engine.setOptions(); - debugPrint("$tag reloaded engine options"); - }); + LocalDatabaseService.listenPreferences.addListener(_refeshEngine); + } + + Future _refeshEngine() async { + await _engine.setOptions(); + debugPrint("$tag reloaded engine options"); } @override @@ -1807,7 +1807,7 @@ class _GamePageState extends State ModalRoute.of(context)! as PageRoute, ); screenPaddingH = _screenPaddingH; - ltr = getBidirectionality(context) == Bidirectionality.leftToRight; + ltr = Directionality.of(context) == TextDirection.ltr; } @override @@ -1851,39 +1851,27 @@ class _GamePageState extends State disposed = true; _engine.shutdown(); _animationController.dispose(); - super.dispose(); routeObserver.unsubscribe(this); + LocalDatabaseService.listenPreferences.removeListener(_refeshEngine); + super.dispose(); } @override - Future didPush() async { + void didPush() { final route = ModalRoute.of(context)!.settings.name; debugPrint('$tag Game Page didPush route: $route'); - await _engine.setOptions(); - if (LocalDatabaseService.display.languageCode != Constants.defaultLocale) { - S.load(LocalDatabaseService.display.languageCode); - setState(() {}); - } } @override - Future didPopNext() async { + void didPopNext() { final route = ModalRoute.of(context)!.settings.name; debugPrint('$tag Game Page didPopNext route: $route'); - await _engine.setOptions(); - if (LocalDatabaseService.display.languageCode != Constants.defaultLocale) { - S.load(LocalDatabaseService.display.languageCode); - } } @override - Future didPushNext() async { + void didPushNext() { final route = ModalRoute.of(context)!.settings.name; debugPrint('$tag Game Page didPushNext route: $route'); - await _engine.setOptions(); - if (LocalDatabaseService.display.languageCode != Constants.defaultLocale) { - S.load(LocalDatabaseService.display.languageCode); - } } @override diff --git a/src/ui/flutter_app/lib/screens/game_settings/game_settings_page.dart b/src/ui/flutter_app/lib/screens/game_settings/game_settings_page.dart index 767990e2..bfe2e9aa 100644 --- a/src/ui/flutter_app/lib/screens/game_settings/game_settings_page.dart +++ b/src/ui/flutter_app/lib/screens/game_settings/game_settings_page.dart @@ -21,7 +21,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:hive_flutter/hive_flutter.dart' show Box; -import 'package:sanmill/generated/l10n.dart'; +import 'package:sanmill/generated/intl/l10n.dart'; import 'package:sanmill/models/preferences.dart'; import 'package:sanmill/models/temporary.dart'; import 'package:sanmill/screens/env_page.dart'; diff --git a/src/ui/flutter_app/lib/screens/help_screen.dart b/src/ui/flutter_app/lib/screens/help_screen.dart index c1053f9e..8361f2fd 100644 --- a/src/ui/flutter_app/lib/screens/help_screen.dart +++ b/src/ui/flutter_app/lib/screens/help_screen.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:sanmill/generated/l10n.dart'; +import 'package:sanmill/generated/intl/l10n.dart'; import 'package:sanmill/services/storage/storage.dart'; import 'package:sanmill/shared/theme/app_theme.dart'; diff --git a/src/ui/flutter_app/lib/screens/home_drawer.dart b/src/ui/flutter_app/lib/screens/home_drawer.dart index 1aca709a..94f196f4 100644 --- a/src/ui/flutter_app/lib/screens/home_drawer.dart +++ b/src/ui/flutter_app/lib/screens/home_drawer.dart @@ -88,8 +88,7 @@ class HomeDrawer extends StatelessWidget { final listItem = items[index]; final bool isSelected = screenIndex == listItem.index; - final bool ltr = - getBidirectionality(context) == Bidirectionality.leftToRight; + final bool ltr = Directionality.of(context) == TextDirection.ltr; const double radius = 28.0; final animatedBuilder = AnimatedBuilder( animation: iconAnimationController, @@ -109,11 +108,9 @@ class HomeDrawer extends StatelessWidget { height: 46, decoration: BoxDecoration( color: LocalDatabaseService.colorSettings.drawerHighlightItemColor, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(ltr ? 0 : radius), - topRight: Radius.circular(ltr ? radius : 0), - bottomLeft: Radius.circular(ltr ? 0 : radius), - bottomRight: Radius.circular(ltr ? radius : 0), + borderRadius: BorderRadius.horizontal( + right: ltr ? const Radius.circular(radius) : Radius.zero, + left: !ltr ? const Radius.circular(radius) : Radius.zero, ), ), ), diff --git a/src/ui/flutter_app/lib/screens/license_page.dart b/src/ui/flutter_app/lib/screens/license_page.dart index 7075eaaf..35fd7c1a 100644 --- a/src/ui/flutter_app/lib/screens/license_page.dart +++ b/src/ui/flutter_app/lib/screens/license_page.dart @@ -18,7 +18,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart' show rootBundle; -import 'package:sanmill/generated/l10n.dart'; +import 'package:sanmill/generated/intl/l10n.dart'; import 'package:sanmill/shared/constants.dart'; class LicenseAgreementPage extends StatelessWidget { diff --git a/src/ui/flutter_app/lib/screens/navigation_home_screen.dart b/src/ui/flutter_app/lib/screens/navigation_home_screen.dart index d65263a0..7a1b1291 100644 --- a/src/ui/flutter_app/lib/screens/navigation_home_screen.dart +++ b/src/ui/flutter_app/lib/screens/navigation_home_screen.dart @@ -26,8 +26,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_email_sender/flutter_email_sender.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:path_provider/path_provider.dart'; -import 'package:sanmill/generated/l10n.dart'; -import 'package:sanmill/l10n/resources.dart'; +import 'package:sanmill/generated/intl/l10n.dart'; import 'package:sanmill/mill/game.dart'; import 'package:sanmill/models/temporary.dart'; import 'package:sanmill/screens/about_page.dart'; @@ -45,6 +44,7 @@ part 'package:sanmill/screens/home_drawer.dart'; part 'package:sanmill/shared/drawer_controller.dart'; class NavigationHomeScreen extends StatefulWidget { + const NavigationHomeScreen({Key? key}) : super(key: key); @override _NavigationHomeScreenState createState() => _NavigationHomeScreenState(); } diff --git a/src/ui/flutter_app/lib/screens/oss_license_page.dart b/src/ui/flutter_app/lib/screens/oss_license_page.dart index 101b105b..59483e71 100644 --- a/src/ui/flutter_app/lib/screens/oss_license_page.dart +++ b/src/ui/flutter_app/lib/screens/oss_license_page.dart @@ -19,7 +19,7 @@ import 'package:fluentui_system_icons/fluentui_system_icons.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:sanmill/generated/l10n.dart'; +import 'package:sanmill/generated/intl/l10n.dart'; import 'package:sanmill/generated/oss_licenses.dart'; import 'package:url_launcher/url_launcher.dart'; diff --git a/src/ui/flutter_app/lib/screens/personalization_settings/language_picker.dart b/src/ui/flutter_app/lib/screens/personalization_settings/language_picker.dart new file mode 100644 index 00000000..732ec0b2 --- /dev/null +++ b/src/ui/flutter_app/lib/screens/personalization_settings/language_picker.dart @@ -0,0 +1,60 @@ +/* + This file is part of Sanmill. + Copyright (C) 2019-2021 The Sanmill developers (see AUTHORS file) + + Sanmill is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Sanmill is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +part of 'package:sanmill/screens/personalization_settings/personalization_settings_page.dart'; + +class _LanguagePicker extends StatelessWidget { + const _LanguagePicker({ + Key? key, + required this.currentLocale, + required this.onChanged, + }) : super(key: key); + + final Locale? currentLocale; + final Function(Locale?) onChanged; + + @override + Widget build(BuildContext context) { + final languageColumn = Column( + mainAxisSize: MainAxisSize.min, + children: [ + RadioListTile( + activeColor: AppTheme.switchListTileActiveColor, + title: Text(S.of(context).defaultLanguage), + groupValue: currentLocale, + value: null, + onChanged: onChanged, + ), + const ListItemDivider(), + for (var i in languageCodeToStrings.keys) + RadioListTile( + activeColor: AppTheme.switchListTileActiveColor, + title: Text(languageCodeToStrings[i]!), + groupValue: currentLocale, + value: Locale(i), + onChanged: onChanged, + ), + ], + ); + + return AlertDialog( + scrollable: true, + content: languageColumn, + ); + } +} diff --git a/src/ui/flutter_app/lib/screens/personalization_settings/personalization_settings_page.dart b/src/ui/flutter_app/lib/screens/personalization_settings/personalization_settings_page.dart index 8f90a6b2..e677e547 100644 --- a/src/ui/flutter_app/lib/screens/personalization_settings/personalization_settings_page.dart +++ b/src/ui/flutter_app/lib/screens/personalization_settings/personalization_settings_page.dart @@ -19,26 +19,28 @@ import 'package:flutter/material.dart'; import 'package:flutter_colorpicker/flutter_colorpicker.dart'; import 'package:hive_flutter/hive_flutter.dart' show Box; -import 'package:sanmill/generated/l10n.dart'; -import 'package:sanmill/l10n/resources.dart'; +import 'package:sanmill/generated/intl/l10n.dart'; import 'package:sanmill/models/color.dart'; import 'package:sanmill/models/display.dart'; +import 'package:sanmill/services/language_info.dart'; import 'package:sanmill/services/storage/storage.dart'; import 'package:sanmill/shared/constants.dart'; +import 'package:sanmill/shared/list_item_divider.dart'; import 'package:sanmill/shared/settings/settings_card.dart'; import 'package:sanmill/shared/settings/settings_list_tile.dart'; import 'package:sanmill/shared/settings/settings_switch_list_tile.dart'; import 'package:sanmill/shared/theme/app_theme.dart'; -part 'package:sanmill/screens/personalization_settings/color_selector_list_tile.dart'; part 'package:sanmill/screens/personalization_settings/animation_duration_slider.dart'; -part 'package:sanmill/screens/personalization_settings/board_top_slider.dart'; part 'package:sanmill/screens/personalization_settings/board_boarder_line_width_slider.dart'; part 'package:sanmill/screens/personalization_settings/board_inner_line_width_slider.dart'; +part 'package:sanmill/screens/personalization_settings/board_top_slider.dart'; +part 'package:sanmill/screens/personalization_settings/color_selector_list_tile.dart'; part 'package:sanmill/screens/personalization_settings/font_size_slider.dart'; -part 'package:sanmill/screens/personalization_settings/point_width_slider.dart'; part 'package:sanmill/screens/personalization_settings/piece_width_slider.dart'; part 'package:sanmill/screens/personalization_settings/point_style_modal.dart'; +part 'package:sanmill/screens/personalization_settings/point_width_slider.dart'; +part 'package:sanmill/screens/personalization_settings/language_picker.dart'; class PersonalizationSettingsPage extends StatelessWidget { void setBoardBorderLineWidth(BuildContext context) => showModalBottomSheet( @@ -97,7 +99,11 @@ class PersonalizationSettingsPage extends StatelessWidget { void langCallback(BuildContext context, Display _display, [Locale? locale]) { Navigator.pop(context); - LocalDatabaseService.display = _display.copyWith(languageCode: locale); + if (locale == null) { + LocalDatabaseService.display = _display.copyWithNull(languageCode: true); + } else { + LocalDatabaseService.display = _display.copyWith(languageCode: locale); + } debugPrint("[config] languageCode = $locale"); } @@ -223,11 +229,14 @@ class PersonalizationSettingsPage extends StatelessWidget { titleString: S.of(context).language, trailingString: LocalDatabaseService.display.languageCode != Constants.defaultLocale - ? languageCodeToStrings[_display.languageCode]!.languageName + ? languageCodeToStrings[_display.languageCode] : '', - onTap: () => setLanguage( - context, - (locale) => langCallback(context, _display, locale), + onTap: () => showDialog( + context: context, + builder: (_) => _LanguagePicker( + currentLocale: _display.languageCode, + onChanged: (locale) => langCallback(context, _display, locale), + ), ), ), SettingsSwitchListTile( diff --git a/src/ui/flutter_app/lib/screens/rule_settings/rule_settings_page.dart b/src/ui/flutter_app/lib/screens/rule_settings/rule_settings_page.dart index 9e6d5133..8d8628ba 100644 --- a/src/ui/flutter_app/lib/screens/rule_settings/rule_settings_page.dart +++ b/src/ui/flutter_app/lib/screens/rule_settings/rule_settings_page.dart @@ -18,7 +18,7 @@ import 'package:flutter/material.dart'; import 'package:hive_flutter/hive_flutter.dart' show Box; -import 'package:sanmill/generated/l10n.dart'; +import 'package:sanmill/generated/intl/l10n.dart'; import 'package:sanmill/models/rules.dart'; import 'package:sanmill/services/storage/storage.dart'; import 'package:sanmill/shared/settings/settings_card.dart'; diff --git a/src/ui/flutter_app/lib/services/language_info.dart b/src/ui/flutter_app/lib/services/language_info.dart new file mode 100644 index 00000000..ebca87ac --- /dev/null +++ b/src/ui/flutter_app/lib/services/language_info.dart @@ -0,0 +1,127 @@ +/* + This file is part of Sanmill. + Copyright (C) 2019-2021 The Sanmill developers (see AUTHORS file) + + Sanmill is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Sanmill is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +import 'package:flutter/material.dart'; +import 'package:sanmill/generated/intl/l10n_ar.dart'; +import 'package:sanmill/generated/intl/l10n_bg.dart'; +import 'package:sanmill/generated/intl/l10n_bn.dart'; +import 'package:sanmill/generated/intl/l10n_cs.dart'; +import 'package:sanmill/generated/intl/l10n_da.dart'; +import 'package:sanmill/generated/intl/l10n_de.dart'; +import 'package:sanmill/generated/intl/l10n_el.dart'; +import 'package:sanmill/generated/intl/l10n_en.dart'; +import 'package:sanmill/generated/intl/l10n_es.dart'; +import 'package:sanmill/generated/intl/l10n_et.dart'; +import 'package:sanmill/generated/intl/l10n_fa.dart'; +import 'package:sanmill/generated/intl/l10n_fi.dart'; +import 'package:sanmill/generated/intl/l10n_fr.dart'; +import 'package:sanmill/generated/intl/l10n_gu.dart'; +import 'package:sanmill/generated/intl/l10n_hi.dart'; +import 'package:sanmill/generated/intl/l10n_hr.dart'; +import 'package:sanmill/generated/intl/l10n_hu.dart'; +import 'package:sanmill/generated/intl/l10n_id.dart'; +import 'package:sanmill/generated/intl/l10n_it.dart'; +import 'package:sanmill/generated/intl/l10n_ja.dart'; +import 'package:sanmill/generated/intl/l10n_kn.dart'; +import 'package:sanmill/generated/intl/l10n_ko.dart'; +import 'package:sanmill/generated/intl/l10n_lt.dart'; +import 'package:sanmill/generated/intl/l10n_lv.dart'; +import 'package:sanmill/generated/intl/l10n_mk.dart'; +import 'package:sanmill/generated/intl/l10n_ms.dart'; +import 'package:sanmill/generated/intl/l10n_nl.dart'; +import 'package:sanmill/generated/intl/l10n_nn.dart'; +import 'package:sanmill/generated/intl/l10n_pl.dart'; +import 'package:sanmill/generated/intl/l10n_pt.dart'; +import 'package:sanmill/generated/intl/l10n_ro.dart'; +import 'package:sanmill/generated/intl/l10n_ru.dart'; +import 'package:sanmill/generated/intl/l10n_sk.dart'; +import 'package:sanmill/generated/intl/l10n_sl.dart'; +import 'package:sanmill/generated/intl/l10n_sq.dart'; +import 'package:sanmill/generated/intl/l10n_sr.dart'; +import 'package:sanmill/generated/intl/l10n_sv.dart'; +import 'package:sanmill/generated/intl/l10n_te.dart'; +import 'package:sanmill/generated/intl/l10n_th.dart'; +import 'package:sanmill/generated/intl/l10n_tr.dart'; +import 'package:sanmill/generated/intl/l10n_uz.dart'; +import 'package:sanmill/generated/intl/l10n_vi.dart'; +import 'package:sanmill/generated/intl/l10n_zh.dart'; + +Map languageCodeToStrings = { + 'ar': SAr().languageName, + 'bg': SBg().languageName, + 'bn': SBn().languageName, + 'cs': SCs().languageName, + 'da': SDa().languageName, + 'de': SDe().languageName, + 'de_CH': SDeCh().languageName, + 'el': SEl().languageName, + 'en': SEn().languageName, + 'es': SEs().languageName, + 'et': SEt().languageName, + 'fa': SFa().languageName, + 'fi': SFi().languageName, + 'fr': SFr().languageName, + 'gu': SGu().languageName, + 'hi': SHi().languageName, + 'hr': SHr().languageName, + 'hu': SHu().languageName, + 'id': SId().languageName, + 'it': SIt().languageName, + 'ja': SJa().languageName, + 'kn': SKn().languageName, + 'ko': SKo().languageName, + 'lt': SLt().languageName, + 'lv': SLv().languageName, + 'mk': SMk().languageName, + 'ms': SMs().languageName, + 'nl': SNl().languageName, + 'nn': SNn().languageName, + 'pl': SPl().languageName, + 'pt': SPt().languageName, + 'ro': SRo().languageName, + 'ru': SRu().languageName, + 'sk': SSk().languageName, + 'sl': SSl().languageName, + 'sq': SSq().languageName, + 'sr': SSr().languageName, + 'sv': SSv().languageName, + 'te': STe().languageName, + 'th': STh().languageName, + 'tr': STr().languageName, + 'uz': SUz().languageName, + 'vi': SVi().languageName, + 'zh': SZh().languageName, + 'zh_Hant': SZhHant().languageName, +}; + +String specialCountryAndRegion = ""; + +void setSpecialCountryAndRegion(BuildContext context) { + final Locale currentLocale = Localizations.localeOf(context); + + switch (currentLocale.countryCode) { + case "IR": + specialCountryAndRegion = "Iran"; + break; + default: + specialCountryAndRegion = ""; + break; + } + + debugPrint("Set Special Country and Region to $specialCountryAndRegion."); +} diff --git a/src/ui/flutter_app/lib/services/storage/adapters/locale_adapter.dart b/src/ui/flutter_app/lib/services/storage/adapters/locale_adapter.dart index 1ab29359..016f7cb9 100644 --- a/src/ui/flutter_app/lib/services/storage/adapters/locale_adapter.dart +++ b/src/ui/flutter_app/lib/services/storage/adapters/locale_adapter.dart @@ -24,7 +24,7 @@ import 'package:json_annotation/json_annotation.dart' show JsonSerializable; /// /// This adapter provides helper functions to be used with [JsonSerializable] /// and is a general [TypeAdapter] to be used with Hive [Box]ses -class LocaleAdapter extends TypeAdapter { +class LocaleAdapter extends TypeAdapter { @override final typeId = 7; @@ -35,10 +35,16 @@ class LocaleAdapter extends TypeAdapter { } @override - void write(BinaryWriter writer, Locale obj) { - writer.writeString(obj.languageCode); + void write(BinaryWriter writer, Locale? obj) { + if (obj != null) { + writer.writeString(obj.languageCode); + } } - static String colorToJson(Locale locale) => locale.languageCode; - static Locale colorFromJson(String value) => Locale(value); + static String? colorToJson(Locale? locale) => locale?.languageCode; + static Locale? colorFromJson(String? value) { + if (value != null) { + return Locale(value); + } + } } diff --git a/src/ui/flutter_app/lib/services/storage/storage.dart b/src/ui/flutter_app/lib/services/storage/storage.dart index 3fd6b52e..ee6e198c 100644 --- a/src/ui/flutter_app/lib/services/storage/storage.dart +++ b/src/ui/flutter_app/lib/services/storage/storage.dart @@ -95,7 +95,7 @@ class LocalDatabaseService { /// initilizes the [Display] reference static Future _initDisplay() async { - Hive.registerAdapter(LocaleAdapter()); + Hive.registerAdapter(LocaleAdapter()); Hive.registerAdapter(DisplayAdapter()); _displayBox = await Hive.openBox(_displayBoxName); } diff --git a/src/ui/flutter_app/lib/shared/constants.dart b/src/ui/flutter_app/lib/shared/constants.dart index dd0c929e..2e47ea0a 100644 --- a/src/ui/flutter_app/lib/shared/constants.dart +++ b/src/ui/flutter_app/lib/shared/constants.dart @@ -32,7 +32,7 @@ class Constants { "assets/files/environment_variables.txt"; static const String gplLicenseFilename = "assets/licenses/GPL-3.0.txt"; - static const Locale defaultLocale = Locale("Default"); + static const Locale? defaultLocale = null; static const String feedbackSubjectPrefix = "[$appName] $projectName "; static const String feedbackSubjectSuffix = " Feedback"; diff --git a/src/ui/flutter_app/lib/shared/dialog.dart b/src/ui/flutter_app/lib/shared/dialog.dart index 5352343b..4d0624b7 100644 --- a/src/ui/flutter_app/lib/shared/dialog.dart +++ b/src/ui/flutter_app/lib/shared/dialog.dart @@ -23,7 +23,7 @@ import 'package:devicelocale/devicelocale.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:sanmill/generated/l10n.dart'; +import 'package:sanmill/generated/intl/l10n.dart'; import 'package:sanmill/services/storage/storage.dart'; import 'package:sanmill/shared/constants.dart'; import 'package:url_launcher/url_launcher.dart'; diff --git a/src/ui/flutter_app/lib/shared/drawer_controller.dart b/src/ui/flutter_app/lib/shared/drawer_controller.dart index be3cd307..2ae86cf7 100644 --- a/src/ui/flutter_app/lib/shared/drawer_controller.dart +++ b/src/ui/flutter_app/lib/shared/drawer_controller.dart @@ -120,8 +120,7 @@ class _DrawerControllerState extends State @override Widget build(BuildContext context) { - final bool ltr = - getBidirectionality(context) == Bidirectionality.leftToRight; + final bool ltr = Directionality.of(context) == TextDirection.ltr; // this just menu and arrow icon animation final inkWell = InkWell( diff --git a/src/ui/flutter_app/lib/shared/picker.dart b/src/ui/flutter_app/lib/shared/picker.dart index e85a9529..1a0ffd73 100644 --- a/src/ui/flutter_app/lib/shared/picker.dart +++ b/src/ui/flutter_app/lib/shared/picker.dart @@ -18,7 +18,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_picker/flutter_picker.dart'; -import 'package:sanmill/generated/l10n.dart'; +import 'package:sanmill/generated/intl/l10n.dart'; import 'package:sanmill/services/storage/storage.dart'; import 'package:sanmill/shared/theme/app_theme.dart'; diff --git a/src/ui/flutter_app/lib/shared/settings/settings_list_tile.dart b/src/ui/flutter_app/lib/shared/settings/settings_list_tile.dart index 866df0de..ddd48985 100644 --- a/src/ui/flutter_app/lib/shared/settings/settings_list_tile.dart +++ b/src/ui/flutter_app/lib/shared/settings/settings_list_tile.dart @@ -18,7 +18,6 @@ import 'package:fluentui_system_icons/fluentui_system_icons.dart'; import 'package:flutter/material.dart'; -import 'package:sanmill/l10n/resources.dart'; import 'package:sanmill/services/storage/storage.dart'; import 'package:sanmill/shared/theme/app_theme.dart'; @@ -40,8 +39,8 @@ class SettingsListTile extends StatelessWidget { @override Widget build(BuildContext context) { - final bool ltr = - getBidirectionality(context) == Bidirectionality.leftToRight; + final bool ltr = Directionality.of(context) == TextDirection.ltr; + return ListTile( title: Text( titleString, diff --git a/src/ui/flutter_app/pubspec.yaml b/src/ui/flutter_app/pubspec.yaml index b8901b2b..d965c1ca 100644 --- a/src/ui/flutter_app/pubspec.yaml +++ b/src/ui/flutter_app/pubspec.yaml @@ -47,6 +47,7 @@ dependencies: dev_dependencies: build_runner: ^2.1.4 copy_with_extension_gen: ^2.0.3 + flutter_gen_runner: ^4.0.0 flutter_oss_licenses: ^1.0.1 flutter_test: sdk: flutter diff --git a/src/ui/flutter_app/test/widget_test.dart b/src/ui/flutter_app/test/widget_test.dart index e459b6ba..299d24d0 100644 --- a/src/ui/flutter_app/test/widget_test.dart +++ b/src/ui/flutter_app/test/widget_test.dart @@ -17,35 +17,29 @@ */ import 'package:flutter/material.dart'; -import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:sanmill/generated/l10n.dart'; +import 'package:sanmill/generated/intl/l10n.dart'; import 'package:sanmill/screens/navigation_home_screen.dart'; void main() { Widget makeTestableWidget({required Widget child, required Locale locale}) { return MaterialApp( - localizationsDelegates: const >[ - S.delegate, - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - GlobalCupertinoLocalizations.delegate, - ], - supportedLocales: S.delegate.supportedLocales, + localizationsDelegates: S.localizationsDelegates, + supportedLocales: S.supportedLocales, locale: locale, home: child, ); } testWidgets('Widget', (WidgetTester tester) async { - final NavigationHomeScreen screen = NavigationHomeScreen(); + const _screen = NavigationHomeScreen(); await tester.pumpWidget( makeTestableWidget( - child: screen, + child: _screen, locale: const Locale('en'), ), ); await tester.pump(); - expect(find.text(S.current.appName), findsOneWidget); + expect(find.text('Mill'), findsOneWidget); }); }