Merge branch 'l10n' into dev

This commit is contained in:
Leptopoda 2021-10-18 13:35:23 +02:00
commit b00e982480
No known key found for this signature in database
GPG Key ID: 661B059EDE309F11
75 changed files with 549 additions and 766 deletions

View File

@ -12,9 +12,7 @@ flutter config --no-analytics
flutter pub get flutter pub get
flutter pub global activate intl_utils flutter gen-l10n
flutter --no-color pub global run intl_utils:generate
flutter pub run flutter_oss_licenses:generate.dart flutter pub run flutter_oss_licenses:generate.dart
mv lib/oss_licenses.dart lib/generated mv lib/oss_licenses.dart lib/generated

View File

@ -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 arb-dir: lib/l10n
template-arb-file: intl_en.arb template-arb-file: intl_en.arb
output-localization-file: app_localizations.dart output-dir: lib/generated/intl/
untranslated-messages-file: untranslated-messages-file.txt 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

View File

@ -1248,5 +1248,9 @@
"hollow": "أجوف", "hollow": "أجوف",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "عربى",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Куха", "hollow": "Куха",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "български",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "ফাঁপা", "hollow": "ফাঁপা",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "বাংলা",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Dutý", "hollow": "Dutý",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Čeština",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Hul", "hollow": "Hul",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Dansk",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Hohle", "hollow": "Hohle",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Deutsch",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Hohle", "hollow": "Hohle",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Schweizerdeutsch",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Κοίλος", "hollow": "Κοίλος",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Ελληνικά",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Hollow", "hollow": "Hollow",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "English",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Hueco", "hollow": "Hueco",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Español",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Õõnes", "hollow": "Õõnes",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Eestlane",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "توخالی", "hollow": "توخالی",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "فارسی",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Ontto", "hollow": "Ontto",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Suomalainen",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Creux", "hollow": "Creux",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Français",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "હોલો", "hollow": "હોલો",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "ગુજરાતી",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "खोखला", "hollow": "खोखला",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "हिंदी",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Šuplje", "hollow": "Šuplje",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Hrvatski",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Üreges", "hollow": "Üreges",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Magyar",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Kosong", "hollow": "Kosong",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Indonesia",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Vuoto", "hollow": "Vuoto",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Italiano",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "中空円", "hollow": "中空円",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "日本語",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "ಟೊಳ್ಳು", "hollow": "ಟೊಳ್ಳು",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "ಕನ್ನಡ",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "구멍", "hollow": "구멍",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "한국어",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Tuščiaviduriai", "hollow": "Tuščiaviduriai",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Lietuvis",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Dobis", "hollow": "Dobis",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Latvietis",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Шупливи", "hollow": "Шупливи",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Македонски",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Berongga", "hollow": "Berongga",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Melayu",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Hol", "hollow": "Hol",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Nederlands",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Hul", "hollow": "Hul",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Norsk",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Dziurawy", "hollow": "Dziurawy",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Polskie",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Oco", "hollow": "Oco",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Português",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Gol", "hollow": "Gol",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Română",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Пустой", "hollow": "Пустой",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Pусский",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Dutý", "hollow": "Dutý",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Slovák",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Votlo", "hollow": "Votlo",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Slovenščina",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Zgavër", "hollow": "Zgavër",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Shqiptare",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Холлов", "hollow": "Холлов",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Српски",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Ihålig", "hollow": "Ihålig",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Svenska",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "బోలు", "hollow": "బోలు",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "తెలుగు",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "กลวง", "hollow": "กลวง",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "ไทย",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Oyuk", "hollow": "Oyuk",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Türk",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Ichi bo'sh", "hollow": "Ichi bo'sh",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "O'zbek",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "Rỗng", "hollow": "Rỗng",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "Tiếng Việt",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "空心圆", "hollow": "空心圆",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "简体中文",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -1248,5 +1248,9 @@
"hollow": "空心圓", "hollow": "空心圓",
"@hollow": { "@hollow": {
"description": "Hollow" "description": "Hollow"
},
"languageName": "繁體中文",
"@languageName": {
"description": "The name of the current language"
} }
} }

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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<Locale, Strings> 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<Locale> 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<void> setLanguage(
BuildContext context,
Function(Locale?)? callback,
) async {
final languageColumn = Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
RadioListTile<Locale>(
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<Locale>(
activeColor: AppTheme.switchListTileActiveColor,
title: Text(languageCodeToStrings[i]!.languageName),
groupValue: LocalDatabaseService.display.languageCode,
value: i,
onChanged: callback,
),
],
);
showDialog<void>(
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.");
}

View File

@ -24,12 +24,13 @@ import 'package:double_back_to_close_app/double_back_to_close_app.dart';
import 'package:feedback/feedback.dart'; import 'package:feedback/feedback.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.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:path_provider/path_provider.dart';
import 'package:sanmill/generated/l10n.dart'; import 'package:sanmill/generated/intl/l10n.dart';
import 'package:sanmill/l10n/resources.dart'; import 'package:sanmill/models/display.dart';
import 'package:sanmill/screens/navigation_home_screen.dart'; import 'package:sanmill/screens/navigation_home_screen.dart';
import 'package:sanmill/services/audios.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.dart';
import 'package:sanmill/services/storage/storage_v1.dart'; import 'package:sanmill/services/storage/storage_v1.dart';
import 'package:sanmill/shared/constants.dart'; import 'package:sanmill/shared/constants.dart';
@ -84,38 +85,44 @@ class SanmillApp extends StatelessWidget {
setSpecialCountryAndRegion(context); setSpecialCountryAndRegion(context);
return MaterialApp( return ValueListenableBuilder(
/// Add navigator key from Catcher. valueListenable: LocalDatabaseService.listenDisplay,
/// It will be used to navigate user to report page or to show dialog. builder: (BuildContext context, Box<Display> displayBox, _) {
navigatorKey: Catcher.navigatorKey, final Display _display = displayBox.get(
key: globalScaffoldKey, LocalDatabaseService.displayKey,
navigatorObservers: [routeObserver], defaultValue: Display(),
localizationsDelegates: const [ )!;
// ... app-specific localization delegate[s] here return MaterialApp(
S.delegate, /// Add navigator key from Catcher.
GlobalMaterialLocalizations.delegate, /// It will be used to navigate user to report page or to show dialog.
GlobalWidgetsLocalizations.delegate, navigatorKey: Catcher.navigatorKey,
GlobalCupertinoLocalizations.delegate, key: globalScaffoldKey,
], navigatorObservers: [routeObserver],
supportedLocales: supportedLocales, localizationsDelegates: S.localizationsDelegates,
theme: AppTheme.lightThemeData, supportedLocales: S.supportedLocales,
darkTheme: AppTheme.darkThemeData, locale: _display.languageCode,
debugShowCheckedModeBanner: false, theme: AppTheme.lightThemeData,
home: Scaffold( darkTheme: AppTheme.darkThemeData,
body: DoubleBackToCloseApp( debugShowCheckedModeBanner: false,
snackBar: SnackBar( home: const _Home(),
content: Text(Resources.of().strings.tapBackAgainToLeave), );
), },
child: NavigationHomeScreen(), );
), }
), }
/*
WillPopScope( class _Home extends StatelessWidget {
onWillPop: () async { const _Home({Key? key}) : super(key: key);
Audios.disposePool();
return true; @override
}, Widget build(BuildContext context) {
*/ return Scaffold(
body: DoubleBackToCloseApp(
snackBar: SnackBar(
content: Text(S.of(context).tapBackAgainToLeave),
),
child: const NavigationHomeScreen(),
),
); );
} }
} }

View File

@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
import 'package:sanmill/l10n/resources.dart'; import 'package:sanmill/services/language_info.dart';
// TODO: deprecate this thingy. No reason to keep it // TODO: deprecate this thingy. No reason to keep it
class Rule { class Rule {

View File

@ -30,7 +30,7 @@ part 'display.g.dart';
/// holds the data needed for the Display Settings /// holds the data needed for the Display Settings
@HiveType(typeId: 1) @HiveType(typeId: 1)
@JsonSerializable() @JsonSerializable()
@CopyWith() @CopyWith(generateCopyWithNull: true)
@immutable @immutable
class Display { class Display {
Display({ Display({
@ -57,7 +57,7 @@ class Display {
fromJson: LocaleAdapter.colorFromJson, fromJson: LocaleAdapter.colorFromJson,
toJson: LocaleAdapter.colorToJson, toJson: LocaleAdapter.colorToJson,
) )
final Locale languageCode; final Locale? languageCode;
@HiveField(1) @HiveField(1)
final bool standardNotationEnabled; final bool standardNotationEnabled;

View File

@ -20,7 +20,7 @@ import 'package:copy_with_extension/copy_with_extension.dart';
import 'package:flutter/foundation.dart' show immutable; import 'package:flutter/foundation.dart' show immutable;
import 'package:hive_flutter/adapters.dart'; import 'package:hive_flutter/adapters.dart';
import 'package:json_annotation/json_annotation.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'; part 'rules.g.dart';

View File

@ -23,7 +23,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:package_info_plus/package_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart';
import 'package:sanmill/generated/flutter_version.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/license_page.dart';
import 'package:sanmill/screens/oss_license_page.dart'; import 'package:sanmill/screens/oss_license_page.dart';
import 'package:sanmill/shared/constants.dart'; import 'package:sanmill/shared/constants.dart';

View File

@ -18,7 +18,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show rootBundle; 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'; import 'package:sanmill/shared/constants.dart';
class EnvironmentVariablesPage extends StatelessWidget { class EnvironmentVariablesPage extends StatelessWidget {

View File

@ -240,8 +240,8 @@ class Board extends StatelessWidget {
1 1
]; ];
final bool ltr = final bool ltr = Directionality.of(context) == TextDirection.ltr;
getBidirectionality(context) == Bidirectionality.leftToRight;
if (ltr) { if (ltr) {
for (final file in ['a', 'b', 'c', 'd', 'e', 'f', 'g']) { for (final file in ['a', 'b', 'c', 'd', 'e', 'f', 'g']) {

View File

@ -23,8 +23,7 @@ import 'dart:async';
import 'package:fluentui_system_icons/fluentui_system_icons.dart'; import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:sanmill/generated/l10n.dart'; import 'package:sanmill/generated/intl/l10n.dart';
import 'package:sanmill/l10n/resources.dart';
import 'package:sanmill/main.dart'; import 'package:sanmill/main.dart';
import 'package:sanmill/mill/game.dart'; import 'package:sanmill/mill/game.dart';
import 'package:sanmill/mill/position.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/engine.dart';
import 'package:sanmill/services/engine/native_engine.dart'; import 'package:sanmill/services/engine/native_engine.dart';
import 'package:sanmill/services/storage/storage.dart'; import 'package:sanmill/services/storage/storage.dart';
import 'package:sanmill/shared/constants.dart';
import 'package:sanmill/shared/dialog.dart'; import 'package:sanmill/shared/dialog.dart';
import 'package:sanmill/shared/picker.dart'; import 'package:sanmill/shared/picker.dart';
import 'package:sanmill/shared/snack_bar.dart'; import 'package:sanmill/shared/snack_bar.dart';
@ -1793,10 +1791,12 @@ class _GamePageState extends State<GamePage>
_initAnimation(); _initAnimation();
LocalDatabaseService.listenPreferences.addListener(() async { LocalDatabaseService.listenPreferences.addListener(_refeshEngine);
await _engine.setOptions(); }
debugPrint("$tag reloaded engine options");
}); Future<void> _refeshEngine() async {
await _engine.setOptions();
debugPrint("$tag reloaded engine options");
} }
@override @override
@ -1807,7 +1807,7 @@ class _GamePageState extends State<GamePage>
ModalRoute.of(context)! as PageRoute<dynamic>, ModalRoute.of(context)! as PageRoute<dynamic>,
); );
screenPaddingH = _screenPaddingH; screenPaddingH = _screenPaddingH;
ltr = getBidirectionality(context) == Bidirectionality.leftToRight; ltr = Directionality.of(context) == TextDirection.ltr;
} }
@override @override
@ -1851,39 +1851,27 @@ class _GamePageState extends State<GamePage>
disposed = true; disposed = true;
_engine.shutdown(); _engine.shutdown();
_animationController.dispose(); _animationController.dispose();
super.dispose();
routeObserver.unsubscribe(this); routeObserver.unsubscribe(this);
LocalDatabaseService.listenPreferences.removeListener(_refeshEngine);
super.dispose();
} }
@override @override
Future<void> didPush() async { void didPush() {
final route = ModalRoute.of(context)!.settings.name; final route = ModalRoute.of(context)!.settings.name;
debugPrint('$tag Game Page didPush route: $route'); debugPrint('$tag Game Page didPush route: $route');
await _engine.setOptions();
if (LocalDatabaseService.display.languageCode != Constants.defaultLocale) {
S.load(LocalDatabaseService.display.languageCode);
setState(() {});
}
} }
@override @override
Future<void> didPopNext() async { void didPopNext() {
final route = ModalRoute.of(context)!.settings.name; final route = ModalRoute.of(context)!.settings.name;
debugPrint('$tag Game Page didPopNext route: $route'); debugPrint('$tag Game Page didPopNext route: $route');
await _engine.setOptions();
if (LocalDatabaseService.display.languageCode != Constants.defaultLocale) {
S.load(LocalDatabaseService.display.languageCode);
}
} }
@override @override
Future<void> didPushNext() async { void didPushNext() {
final route = ModalRoute.of(context)!.settings.name; final route = ModalRoute.of(context)!.settings.name;
debugPrint('$tag Game Page didPushNext route: $route'); debugPrint('$tag Game Page didPushNext route: $route');
await _engine.setOptions();
if (LocalDatabaseService.display.languageCode != Constants.defaultLocale) {
S.load(LocalDatabaseService.display.languageCode);
}
} }
@override @override

View File

@ -21,7 +21,7 @@ import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hive_flutter/hive_flutter.dart' show Box; 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/preferences.dart';
import 'package:sanmill/models/temporary.dart'; import 'package:sanmill/models/temporary.dart';
import 'package:sanmill/screens/env_page.dart'; import 'package:sanmill/screens/env_page.dart';

View File

@ -1,5 +1,5 @@
import 'package:flutter/material.dart'; 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/services/storage/storage.dart';
import 'package:sanmill/shared/theme/app_theme.dart'; import 'package:sanmill/shared/theme/app_theme.dart';

View File

@ -88,8 +88,7 @@ class HomeDrawer extends StatelessWidget {
final listItem = items[index]; final listItem = items[index];
final bool isSelected = screenIndex == listItem.index; final bool isSelected = screenIndex == listItem.index;
final bool ltr = final bool ltr = Directionality.of(context) == TextDirection.ltr;
getBidirectionality(context) == Bidirectionality.leftToRight;
const double radius = 28.0; const double radius = 28.0;
final animatedBuilder = AnimatedBuilder( final animatedBuilder = AnimatedBuilder(
animation: iconAnimationController, animation: iconAnimationController,
@ -109,11 +108,9 @@ class HomeDrawer extends StatelessWidget {
height: 46, height: 46,
decoration: BoxDecoration( decoration: BoxDecoration(
color: LocalDatabaseService.colorSettings.drawerHighlightItemColor, color: LocalDatabaseService.colorSettings.drawerHighlightItemColor,
borderRadius: BorderRadius.only( borderRadius: BorderRadius.horizontal(
topLeft: Radius.circular(ltr ? 0 : radius), right: ltr ? const Radius.circular(radius) : Radius.zero,
topRight: Radius.circular(ltr ? radius : 0), left: !ltr ? const Radius.circular(radius) : Radius.zero,
bottomLeft: Radius.circular(ltr ? 0 : radius),
bottomRight: Radius.circular(ltr ? radius : 0),
), ),
), ),
), ),

View File

@ -18,7 +18,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show rootBundle; 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'; import 'package:sanmill/shared/constants.dart';
class LicenseAgreementPage extends StatelessWidget { class LicenseAgreementPage extends StatelessWidget {

View File

@ -26,8 +26,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_email_sender/flutter_email_sender.dart'; import 'package:flutter_email_sender/flutter_email_sender.dart';
import 'package:package_info_plus/package_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:sanmill/generated/l10n.dart'; import 'package:sanmill/generated/intl/l10n.dart';
import 'package:sanmill/l10n/resources.dart';
import 'package:sanmill/mill/game.dart'; import 'package:sanmill/mill/game.dart';
import 'package:sanmill/models/temporary.dart'; import 'package:sanmill/models/temporary.dart';
import 'package:sanmill/screens/about_page.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'; part 'package:sanmill/shared/drawer_controller.dart';
class NavigationHomeScreen extends StatefulWidget { class NavigationHomeScreen extends StatefulWidget {
const NavigationHomeScreen({Key? key}) : super(key: key);
@override @override
_NavigationHomeScreenState createState() => _NavigationHomeScreenState(); _NavigationHomeScreenState createState() => _NavigationHomeScreenState();
} }

View File

@ -19,7 +19,7 @@
import 'package:fluentui_system_icons/fluentui_system_icons.dart'; import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.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:sanmill/generated/oss_licenses.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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: <Widget>[
RadioListTile<Locale?>(
activeColor: AppTheme.switchListTileActiveColor,
title: Text(S.of(context).defaultLanguage),
groupValue: currentLocale,
value: null,
onChanged: onChanged,
),
const ListItemDivider(),
for (var i in languageCodeToStrings.keys)
RadioListTile<Locale>(
activeColor: AppTheme.switchListTileActiveColor,
title: Text(languageCodeToStrings[i]!),
groupValue: currentLocale,
value: Locale(i),
onChanged: onChanged,
),
],
);
return AlertDialog(
scrollable: true,
content: languageColumn,
);
}
}

View File

@ -19,26 +19,28 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_colorpicker/flutter_colorpicker.dart'; import 'package:flutter_colorpicker/flutter_colorpicker.dart';
import 'package:hive_flutter/hive_flutter.dart' show Box; 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/l10n/resources.dart';
import 'package:sanmill/models/color.dart'; import 'package:sanmill/models/color.dart';
import 'package:sanmill/models/display.dart'; import 'package:sanmill/models/display.dart';
import 'package:sanmill/services/language_info.dart';
import 'package:sanmill/services/storage/storage.dart'; import 'package:sanmill/services/storage/storage.dart';
import 'package:sanmill/shared/constants.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_card.dart';
import 'package:sanmill/shared/settings/settings_list_tile.dart'; import 'package:sanmill/shared/settings/settings_list_tile.dart';
import 'package:sanmill/shared/settings/settings_switch_list_tile.dart'; import 'package:sanmill/shared/settings/settings_switch_list_tile.dart';
import 'package:sanmill/shared/theme/app_theme.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/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_boarder_line_width_slider.dart';
part 'package:sanmill/screens/personalization_settings/board_inner_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/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/piece_width_slider.dart';
part 'package:sanmill/screens/personalization_settings/point_style_modal.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 { class PersonalizationSettingsPage extends StatelessWidget {
void setBoardBorderLineWidth(BuildContext context) => showModalBottomSheet( void setBoardBorderLineWidth(BuildContext context) => showModalBottomSheet(
@ -97,7 +99,11 @@ class PersonalizationSettingsPage extends StatelessWidget {
void langCallback(BuildContext context, Display _display, [Locale? locale]) { void langCallback(BuildContext context, Display _display, [Locale? locale]) {
Navigator.pop(context); 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"); debugPrint("[config] languageCode = $locale");
} }
@ -223,11 +229,14 @@ class PersonalizationSettingsPage extends StatelessWidget {
titleString: S.of(context).language, titleString: S.of(context).language,
trailingString: LocalDatabaseService.display.languageCode != trailingString: LocalDatabaseService.display.languageCode !=
Constants.defaultLocale Constants.defaultLocale
? languageCodeToStrings[_display.languageCode]!.languageName ? languageCodeToStrings[_display.languageCode]
: '', : '',
onTap: () => setLanguage( onTap: () => showDialog(
context, context: context,
(locale) => langCallback(context, _display, locale), builder: (_) => _LanguagePicker(
currentLocale: _display.languageCode,
onChanged: (locale) => langCallback(context, _display, locale),
),
), ),
), ),
SettingsSwitchListTile( SettingsSwitchListTile(

View File

@ -18,7 +18,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hive_flutter/hive_flutter.dart' show Box; 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/models/rules.dart';
import 'package:sanmill/services/storage/storage.dart'; import 'package:sanmill/services/storage/storage.dart';
import 'package:sanmill/shared/settings/settings_card.dart'; import 'package:sanmill/shared/settings/settings_card.dart';

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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<String, String> 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.");
}

View File

@ -24,7 +24,7 @@ import 'package:json_annotation/json_annotation.dart' show JsonSerializable;
/// ///
/// This adapter provides helper functions to be used with [JsonSerializable] /// This adapter provides helper functions to be used with [JsonSerializable]
/// and is a general [TypeAdapter] to be used with Hive [Box]ses /// and is a general [TypeAdapter] to be used with Hive [Box]ses
class LocaleAdapter extends TypeAdapter<Locale> { class LocaleAdapter extends TypeAdapter<Locale?> {
@override @override
final typeId = 7; final typeId = 7;
@ -35,10 +35,16 @@ class LocaleAdapter extends TypeAdapter<Locale> {
} }
@override @override
void write(BinaryWriter writer, Locale obj) { void write(BinaryWriter writer, Locale? obj) {
writer.writeString(obj.languageCode); if (obj != null) {
writer.writeString(obj.languageCode);
}
} }
static String colorToJson(Locale locale) => locale.languageCode; static String? colorToJson(Locale? locale) => locale?.languageCode;
static Locale colorFromJson(String value) => Locale(value); static Locale? colorFromJson(String? value) {
if (value != null) {
return Locale(value);
}
}
} }

View File

@ -95,7 +95,7 @@ class LocalDatabaseService {
/// initilizes the [Display] reference /// initilizes the [Display] reference
static Future<void> _initDisplay() async { static Future<void> _initDisplay() async {
Hive.registerAdapter<Locale>(LocaleAdapter()); Hive.registerAdapter<Locale?>(LocaleAdapter());
Hive.registerAdapter<Display>(DisplayAdapter()); Hive.registerAdapter<Display>(DisplayAdapter());
_displayBox = await Hive.openBox<Display>(_displayBoxName); _displayBox = await Hive.openBox<Display>(_displayBoxName);
} }

View File

@ -32,7 +32,7 @@ class Constants {
"assets/files/environment_variables.txt"; "assets/files/environment_variables.txt";
static const String gplLicenseFilename = "assets/licenses/GPL-3.0.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 feedbackSubjectPrefix = "[$appName] $projectName ";
static const String feedbackSubjectSuffix = " Feedback"; static const String feedbackSubjectSuffix = " Feedback";

View File

@ -23,7 +23,7 @@ import 'package:devicelocale/devicelocale.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.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/services/storage/storage.dart';
import 'package:sanmill/shared/constants.dart'; import 'package:sanmill/shared/constants.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';

View File

@ -120,8 +120,7 @@ class _DrawerControllerState extends State<DrawerController>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final bool ltr = final bool ltr = Directionality.of(context) == TextDirection.ltr;
getBidirectionality(context) == Bidirectionality.leftToRight;
// this just menu and arrow icon animation // this just menu and arrow icon animation
final inkWell = InkWell( final inkWell = InkWell(

View File

@ -18,7 +18,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_picker/flutter_picker.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/services/storage/storage.dart';
import 'package:sanmill/shared/theme/app_theme.dart'; import 'package:sanmill/shared/theme/app_theme.dart';

View File

@ -18,7 +18,6 @@
import 'package:fluentui_system_icons/fluentui_system_icons.dart'; import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:sanmill/l10n/resources.dart';
import 'package:sanmill/services/storage/storage.dart'; import 'package:sanmill/services/storage/storage.dart';
import 'package:sanmill/shared/theme/app_theme.dart'; import 'package:sanmill/shared/theme/app_theme.dart';
@ -40,8 +39,8 @@ class SettingsListTile extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final bool ltr = final bool ltr = Directionality.of(context) == TextDirection.ltr;
getBidirectionality(context) == Bidirectionality.leftToRight;
return ListTile( return ListTile(
title: Text( title: Text(
titleString, titleString,

View File

@ -47,6 +47,7 @@ dependencies:
dev_dependencies: dev_dependencies:
build_runner: ^2.1.4 build_runner: ^2.1.4
copy_with_extension_gen: ^2.0.3 copy_with_extension_gen: ^2.0.3
flutter_gen_runner: ^4.0.0
flutter_oss_licenses: ^1.0.1 flutter_oss_licenses: ^1.0.1
flutter_test: flutter_test:
sdk: flutter sdk: flutter

View File

@ -17,35 +17,29 @@
*/ */
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.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'; import 'package:sanmill/screens/navigation_home_screen.dart';
void main() { void main() {
Widget makeTestableWidget({required Widget child, required Locale locale}) { Widget makeTestableWidget({required Widget child, required Locale locale}) {
return MaterialApp( return MaterialApp(
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[ localizationsDelegates: S.localizationsDelegates,
S.delegate, supportedLocales: S.supportedLocales,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
locale: locale, locale: locale,
home: child, home: child,
); );
} }
testWidgets('Widget', (WidgetTester tester) async { testWidgets('Widget', (WidgetTester tester) async {
final NavigationHomeScreen screen = NavigationHomeScreen(); const _screen = NavigationHomeScreen();
await tester.pumpWidget( await tester.pumpWidget(
makeTestableWidget( makeTestableWidget(
child: screen, child: _screen,
locale: const Locale('en'), locale: const Locale('en'),
), ),
); );
await tester.pump(); await tester.pump();
expect(find.text(S.current.appName), findsOneWidget); expect(find.text('Mill'), findsOneWidget);
}); });
} }