fix(i18n): 印尼语内容缺失时不再回退中文

This commit is contained in:
Vicky authored and trae-solo-agent committed 2026-10-30 17:14:37 +08:00
1 parent 9ef8eb15b0
commit 19196ceb8e
13 files changed
+261 -95

No files matched your search

@@ -0,0 +1,21 @@
// Author: fruit.com.cn
import '../data/models/drama.dart';
const String _indonesianLanguageCode = 'id';
/// 判断短剧是否满足当前界面语言的基础文案完整度。
bool isDramaCompleteForLocale(Drama drama, String languageCode) {
final primaryCode = languageCode.split(RegExp(r'[_-]')).first;
if (primaryCode != _indonesianLanguageCode) return true;
return drama.localizedTitle(primaryCode).trim().isNotEmpty &&
drama.localizedSynopsis(primaryCode).trim().isNotEmpty;
}
/// 过滤不满足首发语言文案完整度的短剧,保持原顺序。
List<Drama> visibleDramasForLocale(
Iterable<Drama> dramas,
String languageCode,
) => dramas
.where((drama) => isDramaCompleteForLocale(drama, languageCode))
.toList(growable: false);