Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(localization): Added Vietnamese language support #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"spanishText": "Spanisch",
"frenchText": "Französisch",
"germanText": "Deutsch",
"brazilianText": "Brasilianisches Portugiesisch"
"brazilianText": "Brasilianisches Portugiesisch",
"vietnameseText": "Vietnamesisch"
}
}
3 changes: 2 additions & 1 deletion assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"spanishText": "Spanish",
"frenchText": "French",
"germanText": "German",
"brazilianText": "Brazilian Portuguese"
"brazilianText": "Brazilian Portuguese",
"vietnameseText": "Vietnamese"
}
}
3 changes: 2 additions & 1 deletion assets/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
3 changes: 2 additions & 1 deletion assets/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"spanishText": "Espagnol",
"frenchText": "Français",
"germanText": "Allemand",
"brazilianText": "Portugais brésilien"
"brazilianText": "Portugais brésilien",
"vietnameseText": "Vietnamien"
}
}
3 changes: 2 additions & 1 deletion assets/translations/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"spanishText": "Espanhol",
"frenchText": "Francês",
"germanText": "Alemão",
"brazilianText": "Português Brasileiro"
"brazilianText": "Português Brasileiro",
"vietnameseText": "Vietnamita"
}
}
3 changes: 2 additions & 1 deletion assets/translations/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"spanishText": "İspanyolca",
"frenchText": "Fransızca",
"germanText": "Almanca",
"brazilianText": "Brezilya Portekizcesi"
"brazilianText": "Brezilya Portekizcesi",
"vietnameseText": "Vietnamca"
}
}
84 changes: 84 additions & 0 deletions assets/translations/vi.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
10 changes: 2 additions & 8 deletions lib/localizations/init_localization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@ class InitLocalizations extends EasyLocalization {
fallbackLocale: Locales.en.locale,
);

static final List<Locale> _supportedLocales = [
Locales.en.locale,
Locales.tr.locale,
Locales.es.locale,
Locales.pt.locale,
Locales.de.locale,
Locales.fr.locale,
];
static final List<Locale> _supportedLocales =
Locales.values.map((e) => e.locale).toList();

static const String _path = "assets/translations";

Expand Down
1 change: 1 addition & 0 deletions lib/localizations/locale_keys.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
29 changes: 17 additions & 12 deletions lib/ui/views/settings/settings_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ class _SettingsViewState extends ConsumerState<SettingsView> {
children: [
SwitchLangTile(
language: Language.en_us,
langCode: "en",
countryCode: "US",
locale: Locales.en.locale,
langText: LocaleKeys.languagesTexts_englishText.tr(),
onTap: () {
InitLocalizations.updateLanguage(
Expand All @@ -149,8 +148,7 @@ class _SettingsViewState extends ConsumerState<SettingsView> {
),
SwitchLangTile(
language: Language.tr,
langCode: "tr",
countryCode: "TR",
locale: Locales.tr.locale,
langText: LocaleKeys.languagesTexts_turkishText.tr(),
onTap: () {
InitLocalizations.updateLanguage(
Expand All @@ -161,8 +159,7 @@ class _SettingsViewState extends ConsumerState<SettingsView> {
),
SwitchLangTile(
language: Language.pt_br,
langCode: "pt",
countryCode: "BR",
locale: Locales.pt.locale,
langText: LocaleKeys.languagesTexts_brazilianText.tr(),
onTap: () {
InitLocalizations.updateLanguage(
Expand All @@ -173,8 +170,7 @@ class _SettingsViewState extends ConsumerState<SettingsView> {
),
SwitchLangTile(
language: Language.es,
langCode: "es",
countryCode: "ES",
locale: Locales.es.locale,
langText: LocaleKeys.languagesTexts_spanishText.tr(),
onTap: () {
InitLocalizations.updateLanguage(
Expand All @@ -185,8 +181,7 @@ class _SettingsViewState extends ConsumerState<SettingsView> {
),
SwitchLangTile(
language: Language.fr,
langCode: "fr",
countryCode: "FR",
locale: Locales.fr.locale,
langText: LocaleKeys.languagesTexts_frenchText.tr(),
onTap: () {
InitLocalizations.updateLanguage(
Expand All @@ -197,8 +192,7 @@ class _SettingsViewState extends ConsumerState<SettingsView> {
),
SwitchLangTile(
language: Language.de,
langCode: "de",
countryCode: "DE",
locale: Locales.de.locale,
langText: LocaleKeys.languagesTexts_germanText.tr(),
onTap: () {
InitLocalizations.updateLanguage(
Expand All @@ -207,6 +201,17 @@ class _SettingsViewState extends ConsumerState<SettingsView> {
);
},
),
SwitchLangTile(
language: Language.vi,
locale: Locales.vn.locale,
langText: LocaleKeys.languagesTexts_vietnameseText.tr(),
onTap: () {
InitLocalizations.updateLanguage(
context: context,
value: Locales.vn,
);
},
),
],
),
],
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/widgets/settings/switch_lang_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion lib/utils/constants/enums/locales.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 2 additions & 0 deletions scripts/localization.sh
Original file line number Diff line number Diff line change
@@ -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