Browse Source

config: cowType update

Yi 1 week ago
parent
commit
3d490b0389
2 changed files with 9 additions and 9 deletions
  1. 1 5
      http/middleware/i18n.go
  2. 8 4
      model/config_cow_type.go

+ 1 - 5
http/middleware/i18n.go

@@ -79,17 +79,13 @@ func loadTranslations() error {
 			continue
 		}
 
-		messageFile, err := bundle.ParseMessageFileBytes(data, filePath)
+		_, err = bundle.ParseMessageFileBytes(data, filePath)
 		if err != nil {
 			zaplog.Error("Failed to parse translation file",
 				zap.String("file", filePath),
 				zap.Error(err))
 			continue
 		}
-
-		zaplog.Info("Loaded translation",
-			zap.String("language", messageFile.Tag.String()),
-			zap.Any("messageFile", messageFile))
 		loaded = true
 	}
 

+ 8 - 4
model/config_cow_type.go

@@ -46,11 +46,10 @@ func (c ConfigCowTypeSlice) ToPB2(userModel *UserModel, optionName string) []*pa
 			MessageID: v.I18nFieldTag,
 		})
 
-		if optionName == "breed" {
-			if v.Kind == pasturePb.CowType_Breeding_Calf || v.Kind == pasturePb.CowType_Reserve_Calf {
-				continue
-			}
+		if optionName == "breed" && !isBreedingOrReserveCalf(v.Kind) {
+			continue
 		}
+
 		res = append(res, &pasturePb.ConfigOptionsList{
 			Value:    int32(v.Kind),
 			Label:    label,
@@ -59,3 +58,8 @@ func (c ConfigCowTypeSlice) ToPB2(userModel *UserModel, optionName string) []*pa
 	}
 	return res
 }
+
+// 辅助函数:判断是否为 Breeding_Calf 或 Reserve_Calf
+func isBreedingOrReserveCalf(kind pasturePb.CowType_Kind) bool {
+	return kind == pasturePb.CowType_Breeding_Calf || kind == pasturePb.CowType_Reserve_Calf
+}