From c95013d99f46087b51ab21ee7f4b6a0b873879b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E4=BA=91=E9=BE=99?= Date: Fri, 30 Aug 2024 10:14:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ets/common/constants/CommonConstants.ets | 6 +- entry/src/main/ets/pages/MainPage.ets | 4 +- entry/src/main/ets/view/DialogComponent.ets | 6 +- entry/src/main/ets/viewmodel/AccountList.ets | 43 ++++++---- entry/src/main/module.json5 | 2 +- .../main/resources/base/element/string.json | 58 +++++++++++-- .../main/resources/en_US/element/string.json | 84 +++++++++++++++++++ .../main/resources/zh_CN/element/string.json | 84 +++++++++++++++++++ 8 files changed, 255 insertions(+), 32 deletions(-) create mode 100644 entry/src/main/resources/en_US/element/string.json create mode 100644 entry/src/main/resources/zh_CN/element/string.json diff --git a/entry/src/main/ets/common/constants/CommonConstants.ets b/entry/src/main/ets/common/constants/CommonConstants.ets index a74b1a1..b46423c 100644 --- a/entry/src/main/ets/common/constants/CommonConstants.ets +++ b/entry/src/main/ets/common/constants/CommonConstants.ets @@ -36,12 +36,12 @@ export default class CommonConstants { /** * Search text of Search component. */ - static readonly SEARCH_TEXT = '搜索'; + static readonly SEARCH_TEXT = $r('app.string.search'); /** * toast text of prompt component. */ - static readonly TOAST_TEXT_1 = '账目类型不能为空'; - static readonly TOAST_TEXT_2 = '账目金额不为正整数'; + static readonly TOAST_TEXT_1 = $r('app.string.TOAST_TEXT_1'); + static readonly TOAST_TEXT_2 = $r('app.string.TOAST_TEXT_2'); /** * Component size. */ diff --git a/entry/src/main/ets/pages/MainPage.ets b/entry/src/main/ets/pages/MainPage.ets index 427f777..ab5ed84 100644 --- a/entry/src/main/ets/pages/MainPage.ets +++ b/entry/src/main/ets/pages/MainPage.ets @@ -17,7 +17,7 @@ import AccountTable from '../common/database/tables/AccountTable'; import AccountData from '../viewmodel/AccountData'; import CommonConstants from '../common/constants/CommonConstants'; import { DialogComponent } from '../view/DialogComponent'; -import { ImageList } from '../viewmodel/AccountList'; +import { ImageList, TextList } from '../viewmodel/AccountList'; import Logger from '../common/utils/Logger'; @Entry @@ -153,7 +153,7 @@ struct MainPage { .aspectRatio(CommonConstants.FULL_SIZE) .margin({ right: $r('app.float.edge_size_MP') }) - Text(item.typeText) + Text(TextList[item.typeText]) .height($r('app.float.component_size_SM')) .fontSize($r('app.float.font_size_M')) diff --git a/entry/src/main/ets/view/DialogComponent.ets b/entry/src/main/ets/view/DialogComponent.ets index d97102f..2ed7707 100644 --- a/entry/src/main/ets/view/DialogComponent.ets +++ b/entry/src/main/ets/view/DialogComponent.ets @@ -17,7 +17,7 @@ import { promptAction } from '@kit.ArkUI'; import AccountData from '../viewmodel/AccountData'; import AccountItem from '../viewmodel/AccountItem'; import CommonConstants from '../common/constants/CommonConstants'; -import { PayList, EarnList } from '../viewmodel/AccountList'; +import { PayList, EarnList, TextList } from '../viewmodel/AccountList'; @CustomDialog export struct DialogComponent { @@ -40,7 +40,7 @@ export struct DialogComponent { .fontSize($r('app.float.font_size_M')) .fontColor(this.curIndex === index ? $r('app.color.main_color') : Color.Gray) } - .width($r('app.float.component_size_MP')) + .width($r('app.float.component_size_LM')) .padding({ top: $r('app.float.edge_size_LM'), bottom: $r('app.float.edge_size_S') }) .margin({ bottom: $r('app.float.edge_size_S') }) .border({ @@ -80,7 +80,7 @@ export struct DialogComponent { .width($r('app.float.image_size')) .aspectRatio(CommonConstants.FULL_SIZE) - Text(item.typeText) + Text(TextList[item.typeText]) .fontSize($r('app.float.font_size_S')) .fontColor(this.curType === item.typeText ? Color.White : $r('app.color.main_color')) .margin({ top: $r('app.float.edge_size_S') }) diff --git a/entry/src/main/ets/viewmodel/AccountList.ets b/entry/src/main/ets/viewmodel/AccountList.ets index 16c694d..130471c 100644 --- a/entry/src/main/ets/viewmodel/AccountList.ets +++ b/entry/src/main/ets/viewmodel/AccountList.ets @@ -20,37 +20,37 @@ export const PayList: Array = [ icon: $rawfile('foods.png'), iconSelected: $rawfile('foods_selected.png'), accountType: 0, - typeText: '吃饭' + typeText: 'foods' }, { icon: $rawfile('snacks.png'), iconSelected: $rawfile('snacks_selected.png'), accountType: 0, - typeText: '零食' + typeText: 'snacks' }, { icon: $rawfile('fuel.png'), iconSelected: $rawfile('fuel_selected.png'), accountType: 0, - typeText: '汽车加油' + typeText: 'fuel' }, { icon: $rawfile('travel.png'), iconSelected: $rawfile('travel_selected.png'), accountType: 0, - typeText: '旅游' + typeText: 'travel' }, { icon: $rawfile('games.png'), iconSelected: $rawfile('games_selected.png'), accountType: 0, - typeText: '娱乐' + typeText: 'games' }, { icon: $rawfile('pets.png'), iconSelected: $rawfile('pets_selected.png'), accountType: 0, - typeText: '宠物' + typeText: 'pets' } ] @@ -59,23 +59,34 @@ export const EarnList: Array = [ icon: $rawfile('income.png'), iconSelected: $rawfile('income_selected.png'), accountType: 1, - typeText: '工作收入' + typeText: 'income' }, { icon: $rawfile('invest.png'), iconSelected: $rawfile('invest_selected.png'), accountType: 1, - typeText: '投资' + typeText: 'invest' } ] export const ImageList: Record = { - '吃饭': $rawfile('foods.png'), - '零食': $rawfile('snacks.png'), - '汽车加油': $rawfile('fuel.png'), - '旅游': $rawfile('travel.png'), - '娱乐': $rawfile('games.png'), - '宠物': $rawfile('pets.png'), - '工作收入': $rawfile('income.png'), - '投资': $rawfile('invest.png') + 'foods': $rawfile('foods.png'), + 'snacks': $rawfile('snacks.png'), + 'fuel': $rawfile('fuel.png'), + 'travel': $rawfile('travel.png'), + 'games': $rawfile('games.png'), + 'pets': $rawfile('pets.png'), + 'income': $rawfile('income.png'), + 'invest': $rawfile('invest.png') +} + +export const TextList: Record = { + 'foods': $r('app.string.foods'), + 'snacks': $r('app.string.snacks'), + 'fuel': $r('app.string.fuel'), + 'travel': $r('app.string.travel'), + 'games': $r('app.string.games'), + 'pets': $r('app.string.pets'), + 'income': $r('app.string.income'), + 'invest': $r('app.string.invest') } \ No newline at end of file diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 index 24f2088..bf66fbd 100644 --- a/entry/src/main/module.json5 +++ b/entry/src/main/module.json5 @@ -20,7 +20,7 @@ "label": "$string:MainAbility_label", "startWindowIcon": "$media:icon", "startWindowBackground": "$color:white", - "exported": false, + "exported": true, "skills": [ { "entities": [ diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index 0e9596c..559460f 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -10,31 +10,75 @@ }, { "name": "MainAbility_label", - "value": "关系型数据库" + "value": "Relational database" }, { "name": "edit_text", - "value": "编辑" + "value": "Edit" }, { "name": "pay_text", - "value": "支出" + "value": "Pay" }, { "name": "income_text", - "value": "收入" + "value": "Income" }, { "name": "count_text", - "value": "金额" + "value": "Amount" }, { "name": "input_text", - "value": "请输入金额" + "value": "Please enter the amount" }, { "name": "confirm_text", - "value": "确定" + "value": "Confirm" + }, + { + "name": "search", + "value": "Search" + }, + { + "name": "TOAST_TEXT_1", + "value": "The account item type cannot be empty" + }, + { + "name": "TOAST_TEXT_2", + "value": "The account item amount is not a positive integer" + }, + { + "name": "foods", + "value": "Foods" + }, + { + "name": "snacks", + "value": "Snacks" + }, + { + "name": "fuel", + "value": "Fuel" + }, + { + "name": "travel", + "value": "Travel" + }, + { + "name": "games", + "value": "Games" + }, + { + "name": "pets", + "value": "Pets" + }, + { + "name": "income", + "value": "Income" + }, + { + "name": "invest", + "value": "Invest" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000..559460f --- /dev/null +++ b/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,84 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "Relational database" + }, + { + "name": "edit_text", + "value": "Edit" + }, + { + "name": "pay_text", + "value": "Pay" + }, + { + "name": "income_text", + "value": "Income" + }, + { + "name": "count_text", + "value": "Amount" + }, + { + "name": "input_text", + "value": "Please enter the amount" + }, + { + "name": "confirm_text", + "value": "Confirm" + }, + { + "name": "search", + "value": "Search" + }, + { + "name": "TOAST_TEXT_1", + "value": "The account item type cannot be empty" + }, + { + "name": "TOAST_TEXT_2", + "value": "The account item amount is not a positive integer" + }, + { + "name": "foods", + "value": "Foods" + }, + { + "name": "snacks", + "value": "Snacks" + }, + { + "name": "fuel", + "value": "Fuel" + }, + { + "name": "travel", + "value": "Travel" + }, + { + "name": "games", + "value": "Games" + }, + { + "name": "pets", + "value": "Pets" + }, + { + "name": "income", + "value": "Income" + }, + { + "name": "invest", + "value": "Invest" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000..9ceb85e --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,84 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "关系型数据库" + }, + { + "name": "edit_text", + "value": "编辑" + }, + { + "name": "pay_text", + "value": "支出" + }, + { + "name": "income_text", + "value": "收入" + }, + { + "name": "count_text", + "value": "金额" + }, + { + "name": "input_text", + "value": "请输入金额" + }, + { + "name": "confirm_text", + "value": "确定" + }, + { + "name": "search", + "value": "搜索" + }, + { + "name": "TOAST_TEXT_1", + "value": "账目类型不能为空" + }, + { + "name": "TOAST_TEXT_2", + "value": "账目金额不为正整数" + }, + { + "name": "foods", + "value": "吃饭" + }, + { + "name": "snacks", + "value": "零食" + }, + { + "name": "fuel", + "value": "汽车加油" + }, + { + "name": "travel", + "value": "旅游" + }, + { + "name": "games", + "value": "娱乐" + }, + { + "name": "pets", + "value": "宠物" + }, + { + "name": "income", + "value": "工作收入" + }, + { + "name": "invest", + "value": "投资" + } + ] +} \ No newline at end of file -- Gitee