translation

This commit is contained in:
wgh19
2024-05-15 19:11:49 +08:00
parent 7e71b5b1ce
commit ed36114ffd
6 changed files with 217 additions and 9 deletions

186
assets/tr.json Normal file
View File

@@ -0,0 +1,186 @@
{
"zh_CN": {
"Search": "搜索",
"Downloading": "下载中",
"Downloaded": "已下载",
"Artwork": "作品",
"Explore": "探索",
"Bookmarks": "收藏",
"Following": "关注",
"History": "历史",
"Ranking": "排行",
"Settings": "设置",
"Artworks": "作品",
"Mangas": "漫画",
"Users": "用户",
"Search artwork": "搜索作品",
"Search Settings": "搜索设置",
"Match": "匹配",
"Favorite number": "收藏数",
"Sort": "排序",
"Age limit": "年龄限制",
"Search novel": "搜索小说",
"Search user": "搜索用户",
"Artwork ID": "作品ID",
"Artist ID": "画师ID",
"Novel ID": "小说ID",
"Search artworks": "搜索作品",
"Speed": "速度",
"View": "查看",
"Info": "信息",
"Delete": "删除",
"Are you sure you want to delete?": "确定要删除吗?",
"Yes": "是",
"Views": "浏览数",
"Favorites": "收藏数",
"Private": "私人",
"Share": "分享",
"Link": "链接",
"Unfollow": "取消关注",
"Favorite": "收藏",
"Comment": "评论",
"Comments": "评论",
"Follows: ": "关注:",
"Information": "信息",
"Introduction": "简介",
"Birthday": "生日",
"Job": "职业",
"Gender": "性别",
"Social Network": "社交网络",
"Batch download": "批量下载",
"Maximum number of downloads": "最大下载数",
"Cancel": "取消",
"Continue": "继续",
"Public": "公开",
"All": "全部",
"Daily": "每日",
"Weekly": "每周",
"Monthly": "每月",
"For male": "男性向",
"For female": "女性向",
"Originals": "原创",
"Rookies": "新人",
"Daily Manga": "每日漫画",
"Weekly Manga": "每周漫画",
"Monthly Manga": "每月漫画",
"R18": "R18",
"Account": "账户",
"Logout": "登出",
"Account Settings": "账户设置",
"Edit": "编辑",
"Download": "下载",
"Manage": "管理",
"About": "关于",
"Are you sure you want to logout?": "确定要登出吗?",
"Download Path": "下载路径",
"Confirm": "确认",
"Download subpath": "下载子路径",
"Rule": "规则",
"Weights of the tags": "标签权重",
"Use translated tag name": "使用翻译后的标签名",
"Edit the rule for where to save an image.": "编辑保存图片的规则",
"Note: The rule should include the filename.": "注意:规则应包含文件名",
"Title of the work": "作品标题",
"Name of the author": "作者名",
"Index of the image in the artwork": "作品中的图片序号",
"File extension": "文件扩展名",
"Tags: Tags will be sorted by the \"Weights of tags\" setting and replaced by the following rule:": "标签:标签将按照“标签权重”设置排序,并按照以下规则替换:",
"The final text will be affected by the \"Use translated tag name\" setting.": "最终文本将受“使用翻译后的标签名”设置影响",
"The first tag of the artwork": "作品的第一个标签",
"The second tag of the artwork": "作品的第二个标签",
"Follow": "关注",
"Save to": "保存到"
},
"zh_TW": {
"Search": "搜索",
"Downloading": "下載中",
"Downloaded": "已下載",
"Artwork": "作品",
"Explore": "探索",
"Bookmarks": "收藏",
"Following": "關注",
"History": "歷史",
"Ranking": "排行",
"Settings": "設置",
"Artworks": "作品",
"Mangas": "漫畫",
"Users": "用戶",
"Search artwork": "搜索作品",
"Search Settings": "搜索設置",
"Match": "匹配",
"Favorite number": "收藏數",
"Sort": "排序",
"Age limit": "年齡限制",
"Search novel": "搜索小說",
"Search user": "搜索用戶",
"Artwork ID": "作品ID",
"Artist ID": "畫師ID",
"Novel ID": "小說ID",
"Search artworks": "搜索作品",
"Speed": "速度",
"View": "查看",
"Info": "信息",
"Delete": "刪除",
"Are you sure you want to delete?": "確定要刪除嗎?",
"Yes": "是",
"Views": "瀏覽數",
"Favorites": "收藏數",
"Private": "私人",
"Share": "分享",
"Link": "鏈接",
"Unfollow": "取消關注",
"Favorite": "收藏",
"Comment": "評論",
"Comments": "評論",
"Follows: ": "關注:",
"Information": "信息",
"Introduction": "簡介",
"Birthday": "生日",
"Job": "職業",
"Gender": "性別",
"Social Network": "社交網絡",
"Batch download": "批量下載",
"Maximum number of downloads": "最大下載數",
"Cancel": "取消",
"Continue": "繼續",
"Public": "公開",
"All": "全部",
"Daily": "每日",
"Weekly": "每周",
"Monthly": "每月",
"For male": "男性向",
"For female": "女性向",
"Originals": "原創",
"Rookies": "新人",
"Daily Manga": "每日漫畫",
"Weekly Manga": "每周漫畫",
"Monthly Manga": "每月漫畫",
"R18": "R18",
"Account": "賬戶",
"Logout": "登出",
"Account Settings": "賬戶設置",
"Edit": "編輯",
"Download": "下載",
"Manage": "管理",
"About": "關於",
"Are you sure you want to logout?": "確定要登出嗎?",
"Download Path": "下載路徑",
"Confirm": "確認",
"Download subpath": "下載子路徑",
"Rule": "規則",
"Weights of the tags": "標籤權重",
"Use translated tag name": "使用翻譯後的標籤名",
"Edit the rule for where to save an image.": "編輯保存圖片的規則",
"Note: The rule should include the filename.": "注意:規則應包含文件名",
"Title of the work": "作品標題",
"Name of the author": "作者名",
"Index of the image in the artwork": "作品中的圖片序號",
"File extension": "文件擴展名",
"Tags: Tags will be sorted by the \"Weights of tags\" setting and replaced by the following rule:": "標籤:標籤將按照“標籤權重”設置排序,並按照以下規則替換:",
"The final text will be affected by the \"Use translated tag name\" setting.": "最終文本將受“使用翻譯後的標籤名”設置影響",
"The first tag of the artwork": "作品的第一個標籤",
"The second tag of the artwork": "作品的第二個標籤",
"Follow": "關注",
"Save to": "保存到"
}
}

View File

@@ -7,6 +7,7 @@ import "package:pixes/foundation/log.dart";
import "package:pixes/network/app_dio.dart"; import "package:pixes/network/app_dio.dart";
import "package:pixes/pages/main_page.dart"; import "package:pixes/pages/main_page.dart";
import "package:pixes/utils/app_links.dart"; import "package:pixes/utils/app_links.dart";
import "package:pixes/utils/translation.dart";
import "package:window_manager/window_manager.dart"; import "package:window_manager/window_manager.dart";
import 'package:system_theme/system_theme.dart'; import 'package:system_theme/system_theme.dart';
@@ -20,6 +21,7 @@ void main() async {
await SystemTheme.accentColor.load(); await SystemTheme.accentColor.load();
await App.init(); await App.init();
await appdata.readData(); await appdata.readData();
await Translation.init();
handleLinks(); handleLinks();
SystemTheme.onChange.listen((event) { SystemTheme.onChange.listen((event) {
StateController.findOrNull(tag: "MyApp")?.update(); StateController.findOrNull(tag: "MyApp")?.update();

View File

@@ -22,6 +22,7 @@ import "package:pixes/utils/translation.dart";
import "package:window_manager/window_manager.dart"; import "package:window_manager/window_manager.dart";
import "../components/page_route.dart"; import "../components/page_route.dart";
import "../utils/debug.dart";
import "downloading_page.dart"; import "downloading_page.dart";
double get _appBarHeight => App.isDesktop ? 36.0 : 48.0; double get _appBarHeight => App.isDesktop ? 36.0 : 48.0;
@@ -203,10 +204,20 @@ class _MainPageState extends State<MainPage> with WindowListener {
padding: EdgeInsets.only(bottom: 4), padding: EdgeInsets.only(bottom: 4),
child: Align( child: Align(
alignment: AlignmentDirectional.centerStart, alignment: AlignmentDirectional.centerStart,
child: Text( child: Row(
children: [
Text(
"Pixes", "Pixes",
style: TextStyle(fontSize: 13), style: TextStyle(fontSize: 13),
), ),
Spacer(),
if(kDebugMode)
Padding(
padding: EdgeInsets.only(right: 138),
child: Button(onPressed: debug, child: Text("Debug")),
)
],
),
), ),
), ),
); );

4
lib/utils/debug.dart Normal file
View File

@@ -0,0 +1,4 @@
/// function used for debug
void debug() {
}

View File

@@ -1,3 +1,6 @@
import 'dart:convert';
import 'package:flutter/services.dart';
import 'package:pixes/foundation/app.dart'; import 'package:pixes/foundation/app.dart';
extension Translation on String { extension Translation on String {
@@ -7,8 +10,10 @@ extension Translation on String {
this; this;
} }
static const translation = <String, Map<String, String>>{ static late final Map<String, Map<String, dynamic>> translation;
"zh_CN": {},
"zh_TW": {}, static Future<void> init() async{
}; var data = await rootBundle.loadString("assets/tr.json");
translation = Map<String, Map<String, dynamic>>.from(jsonDecode(data));
}
} }

View File

@@ -77,8 +77,8 @@ flutter:
uses-material-design: true uses-material-design: true
# To add assets to your application, add an assets section, like this: # To add assets to your application, add an assets section, like this:
# assets: assets:
# - images/a_dot_burr.jpeg - assets/tr.json
# - images/a_dot_ham.jpeg # - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see # An image asset can refer to one or more resolution-specific "variants", see