diff --git a/assets/l10n/en.yaml b/assets/l10n/en.yaml index c1c503dca..9432f866b 100644 --- a/assets/l10n/en.yaml +++ b/assets/l10n/en.yaml @@ -902,6 +902,9 @@ game: toefl: TOEFL forum: navigation: Forum + title: SIT Forum +bulletin: + title: Bulletin permission: permissionDenied: Permission denied permissionDeniedDescOf: "{} permission was not granted. Please check the app settings." @@ -956,3 +959,5 @@ unspecified: Unspecified shareQrCode: Share QR code add: Add rename: Rename +enter: Enter +comingSoon: COMING SOON diff --git a/assets/l10n/zh-Hans.yaml b/assets/l10n/zh-Hans.yaml index 0907086cb..60d6c5ffb 100644 --- a/assets/l10n/zh-Hans.yaml +++ b/assets/l10n/zh-Hans.yaml @@ -902,6 +902,9 @@ game: toefl: 托福 forum: navigation: 社区 + title: 小应社区 +bulletin: + title: 布告栏 permission: permissionDenied: 没有权限 permissionDeniedDescOf: "{}权限未被授权,请检查应用的设置。" @@ -956,3 +959,5 @@ unspecified: 未指定 shareQrCode: 分享二维码 add: 添加 rename: 重命名 +enter: 进入 +comingSoon: 敬请期待 diff --git a/assets/l10n/zh-Hant.yaml b/assets/l10n/zh-Hant.yaml index 55a5d914a..a233baee9 100644 --- a/assets/l10n/zh-Hant.yaml +++ b/assets/l10n/zh-Hant.yaml @@ -902,6 +902,9 @@ game: toefl: 托福 forum: navigation: 社群 + title: 小應社群 +bulletin: + title: 佈告欄 permission: permissionDenied: 沒有權限 permissionDeniedDescOf: "{}權限未授予許可,請檢查應用程式的設定。" @@ -956,3 +959,5 @@ unspecified: 未指定 shareQrCode: 分享 QR 碼 add: 增加 rename: 重新命名 +enter: 進入 +comingSoon: 即將推出 diff --git a/lib/backend/bulletin/i18n.dart b/lib/backend/bulletin/i18n.dart new file mode 100644 index 000000000..1c4c961b0 --- /dev/null +++ b/lib/backend/bulletin/i18n.dart @@ -0,0 +1,12 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:mimir/l10n/common.dart'; + +const i18n = _I18n(); + +class _I18n with CommonI18nMixin { + const _I18n(); + + static const ns = "bulletin"; + + String get title => "$ns.title".tr(); +} diff --git a/lib/backend/bulletin/page/list.dart b/lib/backend/bulletin/page/list.dart index 1f53d878e..0fb310743 100644 --- a/lib/backend/bulletin/page/list.dart +++ b/lib/backend/bulletin/page/list.dart @@ -7,6 +7,7 @@ import 'package:mimir/widgets/markdown.dart'; import 'package:rettulf/rettulf.dart'; import '../entity/bulletin.dart'; +import '../i18n.dart'; class BulletinListPage extends ConsumerStatefulWidget { const BulletinListPage({super.key}); @@ -55,7 +56,7 @@ class _BulletinListPageState extends ConsumerState { body: CustomScrollView( slivers: [ SliverAppBar.medium( - title: "Bulletin List".text(), + title: i18n.title.text(), bottom: !fetching ? null : const PreferredSize( diff --git a/lib/backend/bulletin/service/bulletin.dart b/lib/backend/bulletin/service/bulletin.dart index 36e933264..fb58f419e 100644 --- a/lib/backend/bulletin/service/bulletin.dart +++ b/lib/backend/bulletin/service/bulletin.dart @@ -1,4 +1,5 @@ import 'package:mimir/init.dart'; +import 'package:mimir/lifecycle.dart'; import 'package:mimir/session/mimir.dart'; @@ -11,7 +12,7 @@ class BulletinService { Future getLatest() async { final res = await _session.request( - "https://bulletin.mysit.life/v1/latest", + "https://bulletin.mysit.life/v1/latest?lang=${$locale}", ); if (res.statusCode != 200) { return null; @@ -21,7 +22,7 @@ class BulletinService { Future> getList() async { final res = await _session.request( - "https://bulletin.mysit.life/v1/list", + "https://bulletin.mysit.life/v1/list?lang=${$locale}", ); if (res.statusCode != 200) { return const []; diff --git a/lib/backend/forum/card.dart b/lib/backend/forum/card.dart index 7e5e29b9c..57f13eb41 100644 --- a/lib/backend/forum/card.dart +++ b/lib/backend/forum/card.dart @@ -15,6 +15,8 @@ import 'package:mimir/l10n/extension.dart'; import 'package:mimir/settings/dev.dart'; import 'package:mimir/utils/guard_launch.dart'; import 'package:universal_platform/universal_platform.dart'; +import "package:mimir/backend/bulletin/i18n.dart" as $bulletin; +import 'i18n.dart'; class ForumAppCard extends ConsumerStatefulWidget { const ForumAppCard({super.key}); @@ -46,7 +48,7 @@ class _ForumAppCardState extends ConsumerState { final bulletin = ref.watch(BackendInit.bulletinStorage.$latest); final dev = ref.watch(Dev.$on); return AppCard( - title: "小应社区".text(), + title: i18n.title.text(), view: bulletin == null ? null : BulletinLatestSummaryCard(bulletin), leftActions: [ FilledButton.icon( @@ -59,7 +61,7 @@ class _ForumAppCardState extends ConsumerState { await guardLaunchUrl(context, R.forumUri); } }, - label: !dev ? "敬请期待".text() : "进入".text(), + label: !dev ? i18n.comingSoon.text() : i18n.enter.text(), icon: Icon(context.icons.home), ), OutlinedButton.icon( @@ -69,7 +71,7 @@ class _ForumAppCardState extends ConsumerState { (ctx) => const BulletinListPage(), ); }, - label: "布告栏".text(), + label: $bulletin.i18n.title.text(), icon: const Icon(Icons.list_alt), ), ], diff --git a/lib/backend/forum/i18n.dart b/lib/backend/forum/i18n.dart index 93a605f9f..1d03a974d 100644 --- a/lib/backend/forum/i18n.dart +++ b/lib/backend/forum/i18n.dart @@ -6,15 +6,9 @@ const i18n = _I18n(); class _I18n with CommonI18nMixin { const _I18n(); - final settings = const _Settings(); - static const ns = "forum"; String get navigation => "$ns.navigation".tr(); + String get title => "$ns.title".tr(); } -class _Settings { - const _Settings(); - - static const ns = "${_I18n.ns}.settings"; -} diff --git a/lib/l10n/common.dart b/lib/l10n/common.dart index 6d561be5b..e3748495b 100644 --- a/lib/l10n/common.dart +++ b/lib/l10n/common.dart @@ -88,6 +88,10 @@ mixin class CommonI18nMixin { String get add => "add".tr(); String get rename => "rename".tr(); + + String get enter => "enter".tr(); + + String get comingSoon => "comingSoon".tr(); } class CommonI18n with CommonI18nMixin { diff --git a/lib/lifecycle.dart b/lib/lifecycle.dart index 9aeb8f3cf..dfb81e07a 100644 --- a/lib/lifecycle.dart +++ b/lib/lifecycle.dart @@ -1,7 +1,12 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:easy_localization/easy_localization.dart'; +import 'package:mimir/r.dart'; final $key = GlobalKey(); + final $oaOnline = StateProvider((ref) => false); final $campusNetworkAvailable = StateProvider((ref) => false); final $studentRegAvailable = StateProvider((ref) => false); + +Locale get $locale => $key.currentContext?.locale ?? R.defaultLocale;