From e4a6ff2da4a3931f8d912d1ca1a3e60eea16c2ed Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 3 Sep 2024 23:21:46 +0800 Subject: [PATCH] :globe_with_meridians: Localize dashboard --- lib/models/daily_sign.dart | 11 ++++++----- lib/screens/dashboard.dart | 6 +++--- lib/translations/en_us.dart | 8 ++++++++ lib/translations/zh_cn.dart | 8 ++++++++ 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/lib/models/daily_sign.dart b/lib/models/daily_sign.dart index 4b55a79..508888d 100644 --- a/lib/models/daily_sign.dart +++ b/lib/models/daily_sign.dart @@ -1,4 +1,5 @@ import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:get/get.dart'; import 'package:solian/models/account.dart'; part 'daily_sign.g.dart'; @@ -39,10 +40,10 @@ class DailySignRecord { }; String get overviewSuggestion => switch (resultTier) { - 0 => '诸事不宜', - 1 => '有些不宜', - 2 => '平平淡淡', - 3 => '有些事宜', - _ => '诸事皆宜', + 0 => 'dailySignTier0'.tr, + 1 => 'dailySignTier1'.tr, + 2 => 'dailySignTier2'.tr, + 3 => 'dailySignTier3'.tr, + _ => 'dailySignTier4'.tr, }; } diff --git a/lib/screens/dashboard.dart b/lib/screens/dashboard.dart index 3c3d50c..0abd3d9 100644 --- a/lib/screens/dashboard.dart +++ b/lib/screens/dashboard.dart @@ -144,10 +144,10 @@ class _DashboardScreenState extends State { ).paddingSymmetric(horizontal: 9), ).paddingOnly(left: 4), title: _signRecord == null - ? const Text('签到') + ? Text('dailySign'.tr) : Text(_signRecord!.overviewSuggestion), subtitle: _signRecord == null - ? const Text('今日未拜访佛祖') + ? Text('dailySignNone'.tr) : Text('+${_signRecord!.resultExperience} EXP'), trailing: AnimatedSwitcher( switchInCurve: Curves.fastOutSlowIn, @@ -414,7 +414,7 @@ class _DashboardScreenState extends State { style: TextStyle(color: _unFocusColor, fontSize: 12), ), Text( - '占卜多少都是玩,人生还得靠自己', + 'dashboardFooter'.tr, style: GoogleFonts.notoSerifHk( color: _unFocusColor, fontSize: 12, diff --git a/lib/translations/en_us.dart b/lib/translations/en_us.dart index 09c52f6..b0c7a91 100644 --- a/lib/translations/en_us.dart +++ b/lib/translations/en_us.dart @@ -24,6 +24,14 @@ const i18nEnglish = { 'feedUnreadCount': '@count posts you may missed', 'messages': 'Messages', 'messagesUnreadCount': '@count messages unread', + 'dailySign': 'Daily Sign', + 'dailySignNone': 'You haven\'t sign today', + 'dailySignTier0': 'Everything may not be good', + 'dailySignTier1': 'Something may be wrong', + 'dailySignTier2': 'Just so so', + 'dailySignTier3': 'Something may goes well', + 'dailySignTier4': 'Everything will be awesome', + 'dashboardFooter': 'Don\'t be serious, just for fun.', 'visitProfilePage': 'Visit Profile Page', 'profilePosts': 'Posts', 'profileAlbum': 'Album', diff --git a/lib/translations/zh_cn.dart b/lib/translations/zh_cn.dart index c875418..a04e6ba 100644 --- a/lib/translations/zh_cn.dart +++ b/lib/translations/zh_cn.dart @@ -32,6 +32,14 @@ const i18nSimplifiedChinese = { 'feedUnreadCount': '@count 条你可能错过的帖子', 'messages': '消息', 'messagesUnreadCount': '@count 条未读的消息', + 'dailySign': '签到', + 'dailySignNone': '今日未拜访佛祖', + 'dailySignTier0': '诸事不宜', + 'dailySignTier1': '有些不宜', + 'dailySignTier2': '平平淡淡', + 'dailySignTier3': '有些事宜', + 'dailySignTier4': '诸事皆宜', + 'dashboardFooter': '占卜多少沾点玩,人生还得靠实力', 'visitProfilePage': '造访个人主页', 'profilePosts': '帖子', 'profileAlbum': '相簿',