Просмотр исходного кода

refactor: remove hardcoded Chinese fallback for CANNOT_DISABLE_LAST_KEY

Previously, the error message for CANNOT_DISABLE_LAST_KEY had a hardcoded
Chinese fallback text "无法禁用最后一个可用密钥". This violated i18n
principles because:

1. All 5 languages (en/ja/ru/zh-CN/zh-TW) already have proper translations
   in errors.json
2. The hardcoded fallback would show Chinese to non-Chinese users if i18n
   system failed
3. It's inconsistent with other error messages that don't have fallbacks

Changes:
- Removed hardcoded fallback from batchUpdateKeys (2 occurrences)
- Now relies on proper i18n translations from errors.json

Related translations:
- en: "Cannot disable the last active key..."
- zh-CN: "无法禁用最后一个可用密钥..."
- zh-TW: "無法禁用最後一個可用金鑰..."
NightYu 1 месяц назад
Родитель
Сommit
98358e1cbf
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      src/actions/keys.ts

+ 2 - 2
src/actions/keys.ts

@@ -842,7 +842,7 @@ export async function batchUpdateKeys(
             const currentEnabledCount = userEnabledCounts.get(userId) ?? 0;
             if (currentEnabledCount - disableCount < 1) {
               throw new BatchUpdateError(
-                tError("CANNOT_DISABLE_LAST_KEY") || "无法禁用最后一个可用密钥",
+                tError("CANNOT_DISABLE_LAST_KEY"),
                 ERROR_CODES.OPERATION_FAILED
               );
             }
@@ -899,7 +899,7 @@ export async function batchUpdateKeys(
 
           if (Number(remainingEnabled?.count ?? 0) < 1) {
             throw new BatchUpdateError(
-              tError("CANNOT_DISABLE_LAST_KEY") || "无法禁用最后一个可用密钥",
+              tError("CANNOT_DISABLE_LAST_KEY"),
               ERROR_CODES.OPERATION_FAILED
             );
           }