Browse Source

1、测试翻译包

bakamaka.guan 2 years ago
parent
commit
64ffccaf1a

+ 1 - 10
lib/process/language/measure_language.dart

@@ -2,24 +2,15 @@ import 'dart:convert';
 
 class MeasureLanguage {
   static Map<String, dynamic> _map = {};
-  static bool _isLoad = false;
 
   static void load(String mapJson) {
     _map = jsonDecode(mapJson)["Language"];
-    _isLoad = true;
   }
 
-  static String t(String code) {
+  String t(String code) {
     if (_map.containsKey(code)) {
       return _map[code]!;
     } else {
-      if (!_isLoad) {
-        Future.delayed(const Duration(milliseconds: 2000), () {
-          if (_map.containsKey(code)) {
-            return _map[code]!;
-          }
-        });
-      }
       return code;
     }
   }

+ 4 - 24
lib/view/measure/measure_config/measure_configuation_page.dart

@@ -282,19 +282,12 @@ class _HasSelectedModulePage extends StatelessWidget implements FWidget {
 
   /// 数据
   final measureData = Get.find<MeasureDataController>();
+
+  final measureLanguage = MeasureLanguage();
   _HasSelectedModulePage({
     required this.chooseMeasureList,
   });
 
-  // /// 根据语言包翻译
-  // ///
-  // /// [code] 翻译编码
-  // String getValues(String code) {
-  //   final value = MeasureLanguage().languageValue(code);
-
-  //   return value ?? code;
-  // }
-
   @override
   FWidget build(BuildContext context) {
     return FListView(
@@ -314,20 +307,7 @@ class _HasSelectedModulePage extends StatelessWidget implements FWidget {
                 children: List<FWidget>.generate(
                   chooseMeasureList.length,
                   (index) {
-                    return
-                        // FElevatedButton(
-                        //   onPressed: () {
-                        //     // controller.openHasSelectedSettingDialog(
-                        //     //   controller.state.chooseMeasureList[index],
-                        //     // );
-                        //   },
-                        //   style: ButtonStyle(
-                        //     backgroundColor: MaterialStateProperty.all(
-                        //       Colors.white,
-                        //     ),
-                        //   ),
-                        //   child:
-                        FContainer(
+                    return FContainer(
                       width: 180,
                       height: 60,
                       decoration: BoxDecoration(
@@ -346,7 +326,7 @@ class _HasSelectedModulePage extends StatelessWidget implements FWidget {
                             ),
                           ),
                           FText(
-                            MeasureLanguage.t(
+                            measureLanguage.t(
                               chooseMeasureList[index].toString(),
                             ),
                             style: const TextStyle(

+ 4 - 11
lib/view/measure/measure_config/widgets/measurement_tool_selection.dart

@@ -32,14 +32,7 @@ class SelectModulePage extends FStatefulWidget
 class _SelectModulePageState extends FState<SelectModulePage> {
   /// 数据
   final measureData = Get.find<MeasureDataController>();
-
-  // /// 根据语言包翻译
-  // ///
-  // /// [code] 翻译编码
-  // String getValues(String code) {
-  //   final value = MeasureLanguage().languageValue(code);
-  //   return value ?? code;
-  // }
+  final measureLanguage = MeasureLanguage();
 
   /// 新增测量项目
   ///
@@ -112,7 +105,7 @@ class _SelectModulePageState extends FState<SelectModulePage> {
               itemMetaGroupTitle,
             ),
             FText(
-              MeasureLanguage.t(itemMetaGroupTitle),
+              measureLanguage.t(itemMetaGroupTitle),
             ),
           ],
         ),
@@ -146,7 +139,7 @@ class _SelectModulePageState extends FState<SelectModulePage> {
             mainAxisAlignment: MainAxisAlignment.center,
             children: [
               FText(
-                MeasureLanguage.t(e.description ?? ''),
+                measureLanguage.t(e.description ?? ''),
                 style: const TextStyle(
                   color: Colors.white,
                   fontSize: 14,
@@ -190,7 +183,7 @@ class _SelectModulePageState extends FState<SelectModulePage> {
             mainAxisAlignment: MainAxisAlignment.center,
             children: [
               FText(
-                MeasureLanguage.t(e.description ?? ''),
+                measureLanguage.t(e.description ?? ''),
                 style: const TextStyle(
                   color: Colors.black,
                   fontSize: 14,

+ 4 - 3
lib/view/measure/measure_images_bar.dart

@@ -208,6 +208,7 @@ class _ScrollableImageListState extends State<ScrollableImageList> {
 
   MeasureController measureController = Get.find<MeasureController>();
   late final measureHandler = Get.put(MeasureHandler());
+  final measureLanguage = MeasureLanguage();
 
   /// 图像数据列表
   List<RemedicalInfoDTO> remedicalList = [];
@@ -316,12 +317,12 @@ class _ScrollableImageListState extends State<ScrollableImageList> {
     String description = '';
     if (applicationCategory == "FromSonopost" ||
         application == "FromSonopost") {
-      description = MeasureLanguage.t("FromSonopost");
+      description = measureLanguage.t("FromSonopost");
     } else {
       if (application != '' || applicationCategory != '') {
-        description = MeasureLanguage.t(applicationCategory) +
+        description = measureLanguage.t(applicationCategory) +
             "-" +
-            MeasureLanguage.t(application);
+            measureLanguage.t(application);
       } else {
         description = '';
       }

+ 5 - 4
lib/view/measure/measure_tool.dart

@@ -34,6 +34,7 @@ class LeftSiderSelectMeasureState extends FState<LeftSiderSelectMeasure> {
   final measureHandler = Get.find<MeasureHandler>();
   final measureData = Get.find<MeasureDataController>();
   final measureMetaController = Get.find<MeasureMetaController>();
+  final measureLanguage = MeasureLanguage();
 
   /// 当前选中的测量项下标
   int activeItemIndex = 0;
@@ -249,7 +250,7 @@ class LeftSiderSelectMeasureState extends FState<LeftSiderSelectMeasure> {
   FWidget _buildItemButton(int itemIndex) {
     final itemMeta = measureData.curItemMetaList[itemIndex];
     final ifShowCN = i18nBook.isCurrentChinese && // 中文环境下显示中英文,否则只显示英文
-        MeasureLanguage.t(itemMeta.description) != itemMeta.description;
+        measureLanguage.t(itemMeta.description) != itemMeta.description;
     final isActived = itemIndex == activeItemIndex;
     return FElevatedButton(
       name: itemMeta.name,
@@ -260,7 +261,7 @@ class LeftSiderSelectMeasureState extends FState<LeftSiderSelectMeasure> {
         children: [
           if (ifShowCN)
             FText(
-              MeasureLanguage.t(itemMeta.description),
+              measureLanguage.t(itemMeta.description),
               maxLines: 1,
               overflow: TextOverflow.ellipsis,
               style: TextStyle(
@@ -293,7 +294,7 @@ class LeftSiderSelectMeasureState extends FState<LeftSiderSelectMeasure> {
   FWidget _buildItemTitle(int itemIndex) {
     final itemMeta = measureData.curItemMetaList[itemIndex];
     final ifShowCN = i18nBook.isCurrentChinese && // 中文环境下显示中英文,否则只显示英文
-        MeasureLanguage.t(itemMeta.description) != itemMeta.description;
+        measureLanguage.t(itemMeta.description) != itemMeta.description;
     return FContainer(
       decoration: const BoxDecoration(
         border: Border(
@@ -309,7 +310,7 @@ class LeftSiderSelectMeasureState extends FState<LeftSiderSelectMeasure> {
           children: [
             if (ifShowCN)
               FText(
-                MeasureLanguage.t(itemMeta.description),
+                measureLanguage.t(itemMeta.description),
                 maxLines: 1,
                 overflow: TextOverflow.ellipsis,
                 style: TextStyle(