This commit is contained in:
commit
0a02620564
13 files changed
+27
-128
No files matched your search
@@ -241,11 +241,11 @@ class Drama {
|
||||
}
|
||||
|
||||
String localizedTitle(String languageCode) {
|
||||
return localizedRequiredText(languageCode, title, titleLocales);
|
||||
return localizedText(languageCode, title, titleLocales);
|
||||
}
|
||||
|
||||
String localizedSynopsis(String languageCode) {
|
||||
return localizedRequiredText(languageCode, synopsis, synopsisLocales);
|
||||
return localizedText(languageCode, synopsis, synopsisLocales);
|
||||
}
|
||||
|
||||
String localizedTag(String languageCode) {
|
||||
|
||||
@@ -18,16 +18,3 @@ String localizedText(
|
||||
if (chinese.isNotEmpty) return chinese;
|
||||
return fallback;
|
||||
}
|
||||
|
||||
/// 按当前语言取必须本地化的文案;印尼语缺失时不回退中文。
|
||||
String localizedRequiredText(
|
||||
String languageCode,
|
||||
String fallback,
|
||||
Map<String, String> locales,
|
||||
) {
|
||||
final primaryCode = languageCode.split(RegExp(r'[_-]')).first;
|
||||
final selected = locales[languageCode] ?? locales[primaryCode] ?? '';
|
||||
if (selected.trim().isNotEmpty) return selected;
|
||||
if (primaryCode == 'id') return '';
|
||||
return localizedText(primaryCode, fallback, locales);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
// 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);
|
||||
Reference in new issue
Block a user