feat: 實作語言切換功能

This commit is contained in:
JingChiang
2024-11-10 13:08:37 +08:00
parent 62808b2701
commit 8eab769b74
14 changed files with 933 additions and 56 deletions

View File

@@ -0,0 +1,67 @@
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
// This is a library that looks up messages for specific locales by
// delegating to the appropriate library.
// Ignore issues from commonly used lints in this file.
// ignore_for_file:implementation_imports, file_names, unnecessary_new
// ignore_for_file:unnecessary_brace_in_string_interps, directives_ordering
// ignore_for_file:argument_type_not_assignable, invalid_assignment
// ignore_for_file:prefer_single_quotes, prefer_generic_function_type_aliases
// ignore_for_file:comment_references
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';
import 'package:intl/src/intl_helpers.dart';
import 'messages_en.dart' as messages_en;
import 'messages_zh_Hant.dart' as messages_zh_hant;
typedef Future<dynamic> LibraryLoader();
Map<String, LibraryLoader> _deferredLibraries = {
'en': () => new SynchronousFuture(null),
'zh_Hant': () => new SynchronousFuture(null),
};
MessageLookupByLibrary? _findExact(String localeName) {
switch (localeName) {
case 'en':
return messages_en.messages;
case 'zh_Hant':
return messages_zh_hant.messages;
default:
return null;
}
}
/// User programs should call this before using [localeName] for messages.
Future<bool> initializeMessages(String localeName) {
var availableLocale = Intl.verifiedLocale(
localeName, (locale) => _deferredLibraries[locale] != null,
onFailure: (_) => null);
if (availableLocale == null) {
return new SynchronousFuture(false);
}
var lib = _deferredLibraries[availableLocale];
lib == null ? new SynchronousFuture(false) : lib();
initializeInternalMessageLookup(() => new CompositeMessageLookup());
messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor);
return new SynchronousFuture(true);
}
bool _messagesExistFor(String locale) {
try {
return _findExact(locale) != null;
} catch (e) {
return false;
}
}
MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) {
var actualLocale =
Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null);
if (actualLocale == null) return null;
return _findExact(actualLocale);
}

View File

@@ -0,0 +1,81 @@
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
// This is a library that provides messages for a en locale. All the
// messages from the main program should be duplicated here with the same
// function name.
// Ignore issues from commonly used lints in this file.
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes
import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';
final messages = new MessageLookup();
typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'en';
static String m0(time, reason, location) =>
"Time: ${time}\nReason: ${reason},\nLocation: ${location}\n";
static String m1(location) => "Location: ${location}";
static String m2(reason) => "Reason: ${reason}";
static String m3(time) => "Time: ${time}";
static String m4(displayIndex) => "ID: ${displayIndex}";
final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"account_setting": MessageLookupByLibrary.simpleMessage("Account"),
"additional_information":
MessageLookupByLibrary.simpleMessage("Knowledge"),
"address": MessageLookupByLibrary.simpleMessage("Address"),
"basic_information_setting":
MessageLookupByLibrary.simpleMessage("Basic Information"),
"call_phone":
MessageLookupByLibrary.simpleMessage("Call Emergency Phone"),
"cancel": MessageLookupByLibrary.simpleMessage("Cancel"),
"confirm": MessageLookupByLibrary.simpleMessage("Confirm"),
"edit": MessageLookupByLibrary.simpleMessage("Edit"),
"email": MessageLookupByLibrary.simpleMessage("Email"),
"email_label": MessageLookupByLibrary.simpleMessage("Email/Username"),
"fall_detail": m0,
"fall_detail_location": m1,
"fall_detail_reason": m2,
"fall_detail_time": m3,
"fall_detail_title":
MessageLookupByLibrary.simpleMessage("Fall Detail"),
"fall_id": m4,
"fall_record": MessageLookupByLibrary.simpleMessage("Fall Record"),
"fall_record_empty":
MessageLookupByLibrary.simpleMessage("No fall record"),
"forgot_password":
MessageLookupByLibrary.simpleMessage("Forgot password"),
"gender": MessageLookupByLibrary.simpleMessage("Gender"),
"home": MessageLookupByLibrary.simpleMessage("Home"),
"language_alert": MessageLookupByLibrary.simpleMessage(
"Return to the home page to complete the language setting(Confirm to redirect), otherwise some languages will not be updated in real time!"),
"language_alert_android": MessageLookupByLibrary.simpleMessage(
"Reopen the APP to complete the language setting, otherwise some languages will not be updated in real time!"),
"language_setting": MessageLookupByLibrary.simpleMessage("Language"),
"language_setting_alert_title":
MessageLookupByLibrary.simpleMessage("Language Setting"),
"login_button": MessageLookupByLibrary.simpleMessage("Login"),
"logout_button": MessageLookupByLibrary.simpleMessage("Logout"),
"name": MessageLookupByLibrary.simpleMessage("Name"),
"password_label": MessageLookupByLibrary.simpleMessage("Password"),
"personal_information": MessageLookupByLibrary.simpleMessage("Profile"),
"phone": MessageLookupByLibrary.simpleMessage("Phone Number"),
"realtime_video": MessageLookupByLibrary.simpleMessage("Live View"),
"register_button": MessageLookupByLibrary.simpleMessage("Register"),
"save": MessageLookupByLibrary.simpleMessage("Save"),
"switch_camera": MessageLookupByLibrary.simpleMessage("Switch View")
};
}

View File

@@ -0,0 +1,76 @@
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
// This is a library that provides messages for a zh_Hant locale. All the
// messages from the main program should be duplicated here with the same
// function name.
// Ignore issues from commonly used lints in this file.
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes
import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';
final messages = new MessageLookup();
typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'zh_Hant';
static String m0(time, reason, location) =>
"跌倒時間: ${time}\n跌倒原因: ${reason},\n跌倒地點: ${location}\n";
static String m1(location) => "跌倒地點: ${location}";
static String m2(reason) => "跌倒原因: ${reason}";
static String m3(time) => "跌倒時間: ${time}";
static String m4(displayIndex) => "編號: ${displayIndex}";
final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"account_setting": MessageLookupByLibrary.simpleMessage("帳號設定"),
"additional_information": MessageLookupByLibrary.simpleMessage("知識補充"),
"address": MessageLookupByLibrary.simpleMessage("地址"),
"basic_information_setting":
MessageLookupByLibrary.simpleMessage("基本資料"),
"call_phone": MessageLookupByLibrary.simpleMessage("撥打電話"),
"cancel": MessageLookupByLibrary.simpleMessage("取消"),
"confirm": MessageLookupByLibrary.simpleMessage("確認"),
"edit": MessageLookupByLibrary.simpleMessage("修改資料"),
"email": MessageLookupByLibrary.simpleMessage("電子信箱"),
"email_label": MessageLookupByLibrary.simpleMessage("電子信箱/帳號"),
"fall_detail": m0,
"fall_detail_location": m1,
"fall_detail_reason": m2,
"fall_detail_time": m3,
"fall_detail_title": MessageLookupByLibrary.simpleMessage("詳細資料"),
"fall_id": m4,
"fall_record": MessageLookupByLibrary.simpleMessage("跌倒紀錄"),
"fall_record_empty": MessageLookupByLibrary.simpleMessage("尚無跌倒紀錄"),
"forgot_password": MessageLookupByLibrary.simpleMessage("忘記密碼"),
"gender": MessageLookupByLibrary.simpleMessage("性別"),
"home": MessageLookupByLibrary.simpleMessage("首頁"),
"language_alert": MessageLookupByLibrary.simpleMessage(
"跳轉回首頁以完成語言設定,否則會有部分語言無法即時更新!"),
"language_alert_android": MessageLookupByLibrary.simpleMessage(
"重新開啟APP以完成語言設定否則會有部分語言無法即時更新"),
"language_setting": MessageLookupByLibrary.simpleMessage("語言設定"),
"language_setting_alert_title":
MessageLookupByLibrary.simpleMessage("語言設定"),
"login_button": MessageLookupByLibrary.simpleMessage("登入"),
"logout_button": MessageLookupByLibrary.simpleMessage("登出"),
"name": MessageLookupByLibrary.simpleMessage("姓名"),
"password_label": MessageLookupByLibrary.simpleMessage("密碼"),
"personal_information": MessageLookupByLibrary.simpleMessage("個人資料"),
"phone": MessageLookupByLibrary.simpleMessage("電話"),
"realtime_video": MessageLookupByLibrary.simpleMessage("即時畫面"),
"register_button": MessageLookupByLibrary.simpleMessage("立即註冊"),
"save": MessageLookupByLibrary.simpleMessage("儲存變更"),
"switch_camera": MessageLookupByLibrary.simpleMessage("切換畫面")
};
}