Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Commit 94e11bf

Browse files
committed
fixed !
1 parent cdd1b0a commit 94e11bf

File tree

7 files changed

+33
-46
lines changed

7 files changed

+33
-46
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Make [Checklist](https://www.curseforge.com/minecraft/mc-mods/checklist) Mod sup
55

66
### You can localize it in the following ways:
77

8+
LTDR: See [example](example)
9+
810
First, create a new language file (e.g. `en_us.json`).
911

1012
Then you can use the text contents of `tasks.txt` as a translation key to write the language file. As shown below:

example/config/checklist/tasks.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#title.checklist.tasks.translations
2+
#desc.checklist.tasks.translations
3+
[link.checklist.tasks.translations](https://www.youtube.com)
4+
===
5+
checkbox1.checklist.tasks.translations
6+
checkbox2.checklist.tasks.translations
7+
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"title.checklist.tasks.translations": "§1--==§ Title §1==--",
3+
"desc.checklist.tasks.translations": "This is desc!!!!!! ",
4+
"link.checklist.tasks.translations": "§1§nXXXXX's YT",
5+
"checkbox1.checklist.tasks.translations": "§1==§0Task 1§1==",
6+
"checkbox2.checklist.tasks.translations": "§c==§0Task 2§c=="
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"title.checklist.tasks.translations": "§1--==§ 标题 §1==--",
3+
"desc.checklist.tasks.translations": "这是说明性文字!!!!!! ",
4+
"link.checklist.tasks.translations": "§1§nXXXXX's 油管",
5+
"checkbox1.checklist.tasks.translations": "§1==§0任务 1§1==",
6+
"checkbox2.checklist.tasks.translations": "§c==§0任务 2§c=="
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"pack": {
3+
"pack_format": 15,
4+
"description": "ChecklistTranslationExamplePack"
5+
}
6+
}

src/main/java/org/localizedmc/checklistlocalizer/mixin/LinkElementMarkdownMixin.java

-22
This file was deleted.

src/main/java/org/localizedmc/checklistlocalizer/mixin/TaskElementMixin.java

+3-24
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,22 @@
22

33
import com.lclc98.checklist.client.gui.element.TaskElement;
44
import net.minecraft.text.Text;
5+
import org.localizedmc.checklistlocalizer.ChecklistLocalizer;
56
import org.objectweb.asm.Opcodes;
67
import org.spongepowered.asm.mixin.*;
78
import org.spongepowered.asm.mixin.injection.At;
89
import org.spongepowered.asm.mixin.injection.Redirect;
910

10-
import java.util.regex.Matcher;
11-
import java.util.regex.Pattern;
12-
1311
@Mixin(TaskElement.class)
1412
public class TaskElementMixin {
1513
@Mutable
1614
@Shadow(remap = false) @Final protected String text;
1715

1816
@Redirect(method = "<init>", at = @At(value = "FIELD", target = "Lcom/lclc98/checklist/client/gui/element/TaskElement;text:Ljava/lang/String;", opcode = Opcodes.PUTFIELD), remap = false)
1917
private void injected(TaskElement instance, String value) {
20-
Pattern pattern = Pattern.compile("\\[(.*?)\\]");
21-
Matcher matcher = pattern.matcher(value);
22-
23-
if (text.isEmpty() | value.contains("===")) {
24-
this.text = value;
25-
} else if (matcher.find()) {
26-
this.text = Text.translatable(getLinkText(value, matcher)).getString();
27-
} else {
18+
if (value != null) {
2819
this.text = Text.translatable(value).getString();
20+
ChecklistLocalizer.LOGGER.info("Localizer is working!");
2921
}
3022
}
31-
32-
@Unique
33-
private String getLinkText(String text, Matcher matcher) {
34-
if (matcher.find()) {
35-
// group(0) 是整个匹配的字符串,group(1) 是第一个括号内的内容
36-
String content = matcher.group(1);
37-
System.out.println("Extracted content:" + content);
38-
return content;
39-
} else {
40-
System.out.println("No match found.");
41-
}
42-
return text;
43-
}
4423
}

0 commit comments

Comments
 (0)