translate tags on block dialog.

This commit is contained in:
2025-02-15 21:51:05 +08:00
parent 14837e2543
commit b8e4cc5937
2 changed files with 12 additions and 1 deletions

View File

@@ -463,7 +463,9 @@ class ComicTile extends StatelessWidget {
children: [ children: [
for (var word in all) for (var word in all)
OptionChip( OptionChip(
text: word, text: (comic.tags?.contains(word) ?? false)
? word.translateTagIfNeed
: word,
isSelected: words.contains(word), isSelected: words.contains(word),
onTap: () { onTap: () {
setState(() { setState(() {

View File

@@ -52,6 +52,15 @@ extension TagsTranslation on String{
/// translate tag's text to chinese /// translate tag's text to chinese
String get translateTagsToCN => _translateTags(this); String get translateTagsToCN => _translateTags(this);
String get translateTagIfNeed {
var locale = App.locale;
if (locale.languageCode == "zh") {
return translateTagsToCN;
} else {
return this;
}
}
static String translateTag(String tag) { static String translateTag(String tag) {
if(tag.contains(':') && tag.indexOf(':') == tag.lastIndexOf(':')) { if(tag.contains(':') && tag.indexOf(':') == tag.lastIndexOf(':')) {
var [namespace, text] = tag.split(':'); var [namespace, text] = tag.split(':');