From f2bc07d2fd9243ac46dac0b289f2acd8126fed7e Mon Sep 17 00:00:00 2001 From: Xianglin Zeng Date: Mon, 4 Nov 2024 23:07:38 +0800 Subject: [PATCH] fix hard-coded text in Chinese version, improve weight expressed in Chinese --- lib/l10n/app_en.arb | 11 +++++++- lib/l10n/app_zh.arb | 38 +++++++++++++++++++++++---- lib/widgets/measurements/charts.dart | 2 +- lib/widgets/measurements/helpers.dart | 4 +-- lib/widgets/nutrition/forms.dart | 13 ++++++++- 5 files changed, 58 insertions(+), 10 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 9b093c9b..0e61ee08 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -888,5 +888,14 @@ "@log": { "description": "Log a specific meal (imperative form)" }, - "done": "Done" + "done": "Done", + "overallChangeWeight": "Overall change", + "@overallChangeWeight": { + "description": "Overall change in weight" + }, + "goalTypeMeals": "From meals", + "goalTypeBasic": "Basic", + "goalTypeAdvanced": "Advanced", + "indicatorRaw": "raw", + "indicatorAvg": "avg" } diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 075c6ddb..5eca5f7d 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -250,7 +250,7 @@ }, "delete": "删除", "@delete": {}, - "loadingText": "加载...", + "loadingText": "加载中...", "@loadingText": { "description": "Text to show when entries are being loaded in the background: Loading..." }, @@ -324,7 +324,7 @@ "@date": { "description": "The date of a workout log or body weight entry" }, - "weight": "重量", + "weight": "体重", "@weight": { "description": "The weight of a workout log or body weight entry" }, @@ -348,7 +348,7 @@ "@addMeal": {}, "save": "保存", "@save": {}, - "name": "名", + "name": "名称", "@name": { "description": "Name for a workout or nutritional plan" }, @@ -670,5 +670,33 @@ } }, "noMeasurementEntries": "您没有测量条目", - "@noMeasurementEntries": {} -} + "@noMeasurementEntries": {}, + "overallChangeWeight": "总体变化", + "@overallChangeWeight": { + "description": "Overall change in weight" + }, + "goalTypeMeals": "从饮食出发", + "goalTypeBasic": "基础", + "goalTypeAdvanced": "进阶", + "chartAllTimeTitle": "{name} 历史记录曲线", + "@chartAllTimeTitle": { + "description": "All-time chart of 'name' (e.g. 'weight', 'body fat' etc.)", + "type": "text", + "placeholders": { + "name": {} + } + }, + "chartDuringPlanTitle": "{chartName} 在计划 \"{planName}\" 期间的改变曲线", + "@chartDuringPlanTitle": { + "description": "chart of 'chartName' (e.g. 'weight', 'body fat' etc.) logged during plan", + "type": "text", + "placeholders": { + "chartName": {}, + "planName": {} + } + }, + "indicatorRaw": "原始值", + "indicatorAvg": "平均值", + "textPromptTitle": "准备就绪?", + "textPromptSubheading": "点击右下角按钮开始" +} \ No newline at end of file diff --git a/lib/widgets/measurements/charts.dart b/lib/widgets/measurements/charts.dart index e7ca60ce..80ce33cf 100644 --- a/lib/widgets/measurements/charts.dart +++ b/lib/widgets/measurements/charts.dart @@ -37,7 +37,7 @@ class MeasurementOverallChangeWidget extends StatelessWidget { ? '-' : ''; - return Text('overall change $prefix ${delta.abs().toStringAsFixed(1)} $_unit'); + return Text('${AppLocalizations.of(context).overallChangeWeight} $prefix ${delta.abs().toStringAsFixed(1)} $_unit'); } } diff --git a/lib/widgets/measurements/helpers.dart b/lib/widgets/measurements/helpers.dart index 85139454..000b72e3 100644 --- a/lib/widgets/measurements/helpers.dart +++ b/lib/widgets/measurements/helpers.dart @@ -77,8 +77,8 @@ List getOverviewWidgetsSeries( Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Indicator(color: Theme.of(context).colorScheme.primary, text: 'raw', isSquare: true), - Indicator(color: Theme.of(context).colorScheme.tertiary, text: 'avg', isSquare: true), + Indicator(color: Theme.of(context).colorScheme.primary, text: AppLocalizations.of(context).indicatorRaw, isSquare: true), + Indicator(color: Theme.of(context).colorScheme.tertiary, text: AppLocalizations.of(context).indicatorAvg, isSquare: true), ], ), ]; diff --git a/lib/widgets/nutrition/forms.dart b/lib/widgets/nutrition/forms.dart index ec336f37..1ab0c67d 100644 --- a/lib/widgets/nutrition/forms.dart +++ b/lib/widgets/nutrition/forms.dart @@ -484,6 +484,17 @@ enum GoalType { const GoalType(this.label); final String label; + + String getI18nLabel(BuildContext context) { + switch (this) { + case GoalType.meals: + return AppLocalizations.of(context).goalTypeMeals; + case GoalType.basic: + return AppLocalizations.of(context).goalTypeBasic; + case GoalType.advanced: + return AppLocalizations.of(context).goalTypeAdvanced; + } + } } class PlanForm extends StatefulWidget { @@ -572,7 +583,7 @@ class _PlanFormState extends State { .map( (e) => DropdownMenuItem( value: e, - child: Text(e.label), + child: Text(e.getI18nLabel(context)), ), ) .toList(),