diff --git a/assets/translations/de.json b/assets/translations/de.json index f5933ba..9eaee20 100644 --- a/assets/translations/de.json +++ b/assets/translations/de.json @@ -77,6 +77,7 @@ "spanishText": "Spanisch", "frenchText": "Französisch", "germanText": "Deutsch", - "brazilianText": "Brasilianisches Portugiesisch" + "brazilianText": "Brasilianisches Portugiesisch", + "vietnameseText": "Vietnamesisch" } } diff --git a/assets/translations/en.json b/assets/translations/en.json index 2085f8d..0f07859 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -78,6 +78,7 @@ "spanishText": "Spanish", "frenchText": "French", "germanText": "German", - "brazilianText": "Brazilian Portuguese" + "brazilianText": "Brazilian Portuguese", + "vietnameseText": "Vietnamese" } } diff --git a/assets/translations/es.json b/assets/translations/es.json index b765336..ad4f494 100644 --- a/assets/translations/es.json +++ b/assets/translations/es.json @@ -77,6 +77,7 @@ "spanishText": "Español", "frenchText": "Francés", "germanText": "Alemán", - "brazilianText": "Portugués Brasileño" + "brazilianText": "Portugués Brasileño", + "vietnameseText": "Vietnamita" } } diff --git a/assets/translations/fr.json b/assets/translations/fr.json index 8e6ee48..2cb4253 100644 --- a/assets/translations/fr.json +++ b/assets/translations/fr.json @@ -77,6 +77,7 @@ "spanishText": "Espagnol", "frenchText": "Français", "germanText": "Allemand", - "brazilianText": "Portugais brésilien" + "brazilianText": "Portugais brésilien", + "vietnameseText": "Vietnamien" } } diff --git a/assets/translations/pt.json b/assets/translations/pt.json index 7486ed1..2b7dab1 100644 --- a/assets/translations/pt.json +++ b/assets/translations/pt.json @@ -77,6 +77,7 @@ "spanishText": "Espanhol", "frenchText": "Francês", "germanText": "Alemão", - "brazilianText": "Português Brasileiro" + "brazilianText": "Português Brasileiro", + "vietnameseText": "Vietnamita" } } diff --git a/assets/translations/tr.json b/assets/translations/tr.json index dd93bde..465128f 100644 --- a/assets/translations/tr.json +++ b/assets/translations/tr.json @@ -73,6 +73,7 @@ "spanishText": "İspanyolca", "frenchText": "Fransızca", "germanText": "Almanca", - "brazilianText": "Brezilya Portekizcesi" + "brazilianText": "Brezilya Portekizcesi", + "vietnameseText": "Vietnamca" } } diff --git a/assets/translations/vi.json b/assets/translations/vi.json new file mode 100644 index 0000000..915c9eb --- /dev/null +++ b/assets/translations/vi.json @@ -0,0 +1,84 @@ +{ + "freeGamesView": { + "appBarTitle": "Đang Free", + "platformsText": "Nền Tảng", + "gameText": "Game", + "lootText": "Dlc", + "freeText": "Miễn Phí", + "endDateText": "Ngày Kết Thúc", + "descriptionText": "Mô Tả", + "instructionsText": "Hướng Dẫn" + }, + "gameDealsView": { + "appBarTitle": "Đang Giảm Giá", + "platformText": "Nền Tảng", + "minPrice": "Thấp Nhất", + "maxPrice": "Cao Nhất", + "discountedText": "Giảm giá", + "addFavoriteText": "Thêm vào yêu thích", + "reviewsText": "Đánh giá", + "scoreText": "Điểm", + "rateText": "Tỷ lệ", + "avarageReviewText": "Đánh giá trung bình", + "releaseDateText": "Ngày Phát Hành", + "discountDateText": "Ngày Giảm Giá" + }, + + "searchGameView": { + "textfieldHintText": "Tìm kiếm game", + "cheapestText": "Rẻ nhất" + }, + + "favoriteGamesView": { + "appBarTitle": "Yêu Thích", + "alertDialog": { + "clearFavListText": "Xóa danh sách yêu thích?", + "sureDeleteAllText": "Bạn có chắc chắn muốn xóa tất cả game khỏi danh sách yêu thích?", + "undoneText": "Hành động này không thể hoàn tác.", + "cancelText": "Hủy", + "approveText": "Đồng ý" + } + }, + + "settingsView": { + "appBarTitle": "Cài Đặt", + "permissionsText": "Quyền Truy Cập", + "acceptText": "Chấp Nhận", + "languagesText": "Ngôn Ngữ", + "contact": "Liên Hệ", + "darkModeText": "Dark Mode", + "sendText": "Gửi", + "themeText": "Theme", + "notificationText": "Thông Báo", + "privacyPolicyText": "Chính Sách Bảo Mật", + "privacyText": "Chính Sách", + "eMailText": "Email", + "localizationText": "Địa Phương Hóa" + }, + "emptyView": { + "noGameFoundText": "Không Tìm Thấy Game" + }, + "snackbarTexts": { + "addedText": "Đã thêm game vào danh sách yêu thích.", + "deletedText": "Đã xóa game khỏi danh sách yêu thích.", + "allGamesRemovedText": "Đã xóa tất cả game khỏi danh sách yêu thích.", + "permissionAccepted": "Quyền truy cập đã được chấp nhận.", + "permissionAlreadyAccepted": "Tất cả quyền truy cập đã được chấp nhận." + }, + + "commonTexts": { + "getButtonText": "Nhận", + "priceText": "Giá", + "typeText": "Loại" + }, + + "languagesTexts": { + "englishText": "Tiếng Anh", + "turkishText": "Tiếng Thổ Nhĩ Kỳ", + "spanishText": "Tiếng Tây Ban Nha", + "frenchText": "Tiếng Pháp", + "germanText": "Tiếng Đức", + "brazilianText": "Tiếng Bồ Đào Nha", + "vietnameseText": "Tiếng Việt" + } +} diff --git a/lib/localizations/init_localization.dart b/lib/localizations/init_localization.dart index 6870a5f..88baf94 100644 --- a/lib/localizations/init_localization.dart +++ b/lib/localizations/init_localization.dart @@ -13,14 +13,8 @@ class InitLocalizations extends EasyLocalization { fallbackLocale: Locales.en.locale, ); - static final List _supportedLocales = [ - Locales.en.locale, - Locales.tr.locale, - Locales.es.locale, - Locales.pt.locale, - Locales.de.locale, - Locales.fr.locale, - ]; + static final List _supportedLocales = + Locales.values.map((e) => e.locale).toList(); static const String _path = "assets/translations"; diff --git a/lib/localizations/locale_keys.g.dart b/lib/localizations/locale_keys.g.dart index 24307b7..73947d4 100644 --- a/lib/localizations/locale_keys.g.dart +++ b/lib/localizations/locale_keys.g.dart @@ -81,5 +81,6 @@ abstract class LocaleKeys { static const languagesTexts_frenchText = 'languagesTexts.frenchText'; static const languagesTexts_germanText = 'languagesTexts.germanText'; static const languagesTexts_brazilianText = 'languagesTexts.brazilianText'; + static const languagesTexts_vietnameseText = 'languagesTexts.vietnameseText'; static const languagesTexts = 'languagesTexts'; } diff --git a/lib/ui/views/settings/settings_view.dart b/lib/ui/views/settings/settings_view.dart index bc58875..99d679a 100644 --- a/lib/ui/views/settings/settings_view.dart +++ b/lib/ui/views/settings/settings_view.dart @@ -137,8 +137,7 @@ class _SettingsViewState extends ConsumerState { children: [ SwitchLangTile( language: Language.en_us, - langCode: "en", - countryCode: "US", + locale: Locales.en.locale, langText: LocaleKeys.languagesTexts_englishText.tr(), onTap: () { InitLocalizations.updateLanguage( @@ -149,8 +148,7 @@ class _SettingsViewState extends ConsumerState { ), SwitchLangTile( language: Language.tr, - langCode: "tr", - countryCode: "TR", + locale: Locales.tr.locale, langText: LocaleKeys.languagesTexts_turkishText.tr(), onTap: () { InitLocalizations.updateLanguage( @@ -161,8 +159,7 @@ class _SettingsViewState extends ConsumerState { ), SwitchLangTile( language: Language.pt_br, - langCode: "pt", - countryCode: "BR", + locale: Locales.pt.locale, langText: LocaleKeys.languagesTexts_brazilianText.tr(), onTap: () { InitLocalizations.updateLanguage( @@ -173,8 +170,7 @@ class _SettingsViewState extends ConsumerState { ), SwitchLangTile( language: Language.es, - langCode: "es", - countryCode: "ES", + locale: Locales.es.locale, langText: LocaleKeys.languagesTexts_spanishText.tr(), onTap: () { InitLocalizations.updateLanguage( @@ -185,8 +181,7 @@ class _SettingsViewState extends ConsumerState { ), SwitchLangTile( language: Language.fr, - langCode: "fr", - countryCode: "FR", + locale: Locales.fr.locale, langText: LocaleKeys.languagesTexts_frenchText.tr(), onTap: () { InitLocalizations.updateLanguage( @@ -197,8 +192,7 @@ class _SettingsViewState extends ConsumerState { ), SwitchLangTile( language: Language.de, - langCode: "de", - countryCode: "DE", + locale: Locales.de.locale, langText: LocaleKeys.languagesTexts_germanText.tr(), onTap: () { InitLocalizations.updateLanguage( @@ -207,6 +201,17 @@ class _SettingsViewState extends ConsumerState { ); }, ), + SwitchLangTile( + language: Language.vi, + locale: Locales.vn.locale, + langText: LocaleKeys.languagesTexts_vietnameseText.tr(), + onTap: () { + InitLocalizations.updateLanguage( + context: context, + value: Locales.vn, + ); + }, + ), ], ), ], diff --git a/lib/ui/widgets/settings/switch_lang_tile.dart b/lib/ui/widgets/settings/switch_lang_tile.dart index 70d998e..f704c38 100644 --- a/lib/ui/widgets/settings/switch_lang_tile.dart +++ b/lib/ui/widgets/settings/switch_lang_tile.dart @@ -8,14 +8,12 @@ class SwitchLangTile extends StatelessWidget { Key? key, required this.langText, required this.onTap, - required this.langCode, - required this.countryCode, + required this.locale, required this.language, }) : super(key: key); final String langText; final Function() onTap; - final String langCode; - final String countryCode; + final Locale locale; final Language language; @override @@ -33,7 +31,7 @@ class SwitchLangTile extends StatelessWidget { fontSize: 14.sp, ), ), - trailing: context.locale == Locale(langCode, countryCode) + trailing: context.locale == locale ? Icon( Icons.check, size: 24.w, diff --git a/lib/utils/constants/enums/locales.dart b/lib/utils/constants/enums/locales.dart index 091f8c4..880299e 100644 --- a/lib/utils/constants/enums/locales.dart +++ b/lib/utils/constants/enums/locales.dart @@ -6,8 +6,10 @@ enum Locales { pt(Locale('pt', 'BR')), es(Locale('es', 'ES')), de(Locale('de', 'DE')), - fr(Locale('fr', 'FR')); + fr(Locale('fr', 'FR')), + vn(Locale('vi', 'VN')); final Locale locale; + const Locales(this.locale); } diff --git a/scripts/localization.sh b/scripts/localization.sh new file mode 100644 index 0000000..844b9cd --- /dev/null +++ b/scripts/localization.sh @@ -0,0 +1,2 @@ +# Run this script to generate localization files: sh scripts/localization.sh +dart run easy_localization:generate -S assets/translations -O lib/localizations -o locale_keys.g.dart -f keys \ No newline at end of file