diff --git a/entry/src/main/ets/common/constants/CommonConstants.ets b/entry/src/main/ets/common/constants/CommonConstants.ets index 4dc496b195d27c12caad07bbee7f3db54482600b..55e181dfa7efc3ee6b10c9544fd9be23e16e1215 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 6fc7b390552a635cbcc0cf976c9af2f004ae304b..227eba057c5e9080946eca0e86c6de2c868e7096 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 bb3d71378ccf7cdb40749b47cf64caf31e1f0365..4ad68f22e8a7acb30af30041a8cb1dde671e4013 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 bb3d71378ccf7cdb40749b47cf64caf31e1f0365..b9e3d388e1726789190b15b6f1353051a583b5fd 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 2a1a5708d85e8bc78cdf05b07e6e3fce30880baa..70833bd23b9b444b3ab3556e66602ddaddb10eee 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