From 218afcfb8e00e40f7e90aa997a2943911a94c1d4 Mon Sep 17 00:00:00 2001 From: 15871369330 <@Gitee31415926535> Date: Thu, 12 Sep 2024 10:21:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9E=84=E5=BB=BA=E5=A4=9A=E7=A7=8D=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E5=BC=B9=E7=AA=97=20=E9=80=82=E9=85=8D?= 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/common/utils/CommonUtils.ets | 17 +++++++++++++++-- .../src/main/resources/base/element/string.json | 14 +++++++++++++- .../main/resources/en_US/element/string.json | 14 +++++++++++++- .../main/resources/zh_CN/element/string.json | 12 ++++++++++++ 5 files changed, 56 insertions(+), 7 deletions(-) diff --git a/entry/src/main/ets/common/constants/CommonConstants.ets b/entry/src/main/ets/common/constants/CommonConstants.ets index 4dc496b..55e181d 100644 --- a/entry/src/main/ets/common/constants/CommonConstants.ets +++ b/entry/src/main/ets/common/constants/CommonConstants.ets @@ -50,17 +50,17 @@ export default class CommonConstants { /** * Date year */ - static readonly DATE_YEAR: string = '年'; + static readonly DATE_YEAR: Resource = $r('app.string.text_year'); /** * Date month */ - static readonly DATE_MONTH: string = '月'; + static readonly DATE_MONTH: Resource = $r('app.string.text_month'); /** * Date day */ - static readonly DATE_DAY: string = '日'; + static readonly DATE_DAY: Resource = $r('app.string.text_day'); /** * Date dialog start time. diff --git a/entry/src/main/ets/common/utils/CommonUtils.ets b/entry/src/main/ets/common/utils/CommonUtils.ets index 6fc7b39..227eba0 100644 --- a/entry/src/main/ets/common/utils/CommonUtils.ets +++ b/entry/src/main/ets/common/utils/CommonUtils.ets @@ -101,8 +101,8 @@ export class CommonUtils { * @returns {string} return birth date */ getBirthDateValue(year: number, month: number, day: number): string { - let birthdate: string = `${year}${CommonConstants.DATE_YEAR}${month}` + - `${CommonConstants.DATE_MONTH}${day}${CommonConstants.DATE_DAY}`; + let birthdate: string = `${year}${this.getResourceString(CommonConstants.DATE_YEAR)}${month}` + + `${this.getResourceString(CommonConstants.DATE_MONTH)}${day}${this.getResourceString(CommonConstants.DATE_DAY)}`; return birthdate; } @@ -125,6 +125,19 @@ export class CommonUtils { isEmptyArr(array: Array): boolean { return this.isEmpty(array) || array.length === 0; } + + /** + * The Resource type is converted to a string type. + */ + getResourceString(resource: Resource): string { + let resourceString: string = ''; + try { + resourceString = getContext(this).resourceManager.getStringSync(resource.id); + } catch (error) { + Logger.error(`getResourceString err: ${JSON.stringify(error)}`); + } + return resourceString; + } } export default new CommonUtils(); \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index bb3d713..4ad68f2 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -50,11 +50,23 @@ }, { "name": "text_personal_title", - "value": "Personal information" + "value": "Personal Information" }, { "name": "text_title_hobbies", "value": "Hobbies" + }, + { + "name": "text_year", + "value": "-" + }, + { + "name": "text_month", + "value": "-" + }, + { + "name": "text_day", + "value": "" } ] } \ 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 index bb3d713..b9e3d38 100644 --- a/entry/src/main/resources/en_US/element/string.json +++ b/entry/src/main/resources/en_US/element/string.json @@ -50,11 +50,23 @@ }, { "name": "text_personal_title", - "value": "Personal information" + "value": "Personal Information" }, { "name": "text_title_hobbies", "value": "Hobbies" + }, + { + "name": "text_year", + "value": "/" + }, + { + "name": "text_month", + "value": "/" + }, + { + "name": "text_day", + "value": "" } ] } \ 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 index 2a1a570..70833bd 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -55,6 +55,18 @@ { "name": "text_title_hobbies", "value": "兴趣爱好" + }, + { + "name": "text_year", + "value": "年" + }, + { + "name": "text_month", + "value": "月" + }, + { + "name": "text_day", + "value": "日" } ] } \ No newline at end of file -- Gitee