Skip to content

Commit

Permalink
多语言测试通过,添加两个超链接
Browse files Browse the repository at this point in the history
  • Loading branch information
Xujiayao committed Oct 22, 2024
1 parent cb842c3 commit efef398
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 15 deletions.
58 changes: 54 additions & 4 deletions wrapper/src/main/java/com/xujiayao/discord_mc_chat/gui/GUI.form
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.xujiayao.discord_mc_chat.gui.GUI">
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="6" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="13" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<xy x="20" y="20" width="658" height="514"/>
Expand Down Expand Up @@ -33,20 +33,20 @@
</constraints>
<properties>
<font size="12"/>
<text resource-bundle="lang/lang" key="description"/>
<text resource-bundle="lang/lang" key="description1"/>
</properties>
</component>
<component id="f21cf" class="javax.swing.JSeparator">
<constraints>
<grid row="4" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="11" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<orientation value="0"/>
</properties>
</component>
<component id="2943f" class="javax.swing.JButton" binding="button">
<constraints>
<grid row="5" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
<grid row="12" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font size="12"/>
Expand Down Expand Up @@ -82,6 +82,56 @@
</constraints>
<properties/>
</component>
<component id="3772" class="javax.swing.JLabel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font size="12"/>
<opaque value="false"/>
<text resource-bundle="lang/lang" key="description2"/>
</properties>
</component>
<component id="b2631" class="javax.swing.JLabel" binding="docsLabel">
<constraints>
<grid row="7" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font size="12"/>
<text resource-bundle="lang/lang" key="description3"/>
<toolTipText value="https://blog.xujiayao.com/posts/4ba0a17a/" noi18n="true"/>
</properties>
</component>
<vspacer id="26498">
<constraints>
<grid row="8" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<vspacer id="13b05">
<constraints>
<grid row="6" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<vspacer id="b64a9">
<constraints>
<grid row="4" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<vspacer id="b7b17">
<constraints>
<grid row="10" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="63dc0" class="javax.swing.JLabel" binding="discordLabel">
<constraints>
<grid row="9" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font size="12"/>
<text resource-bundle="lang/lang" key="description4"/>
<toolTipText value="https://discord.gg/kbXkV6k2XU" noi18n="true"/>
</properties>
</component>
</children>
</grid>
</form>
66 changes: 62 additions & 4 deletions wrapper/src/main/java/com/xujiayao/discord_mc_chat/gui/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
import com.formdev.flatlaf.extras.FlatSVGUtils;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;

import javax.swing.*;
import javax.swing.plaf.FontUIResource;
import javax.swing.text.StyleContext;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.lang.reflect.Method;
import java.net.URI;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.PropertyResourceBundle;
Expand All @@ -26,6 +30,8 @@ public class GUI extends JFrame {
private JLabel versionLabel;
private JButton button;
private JLabel iconLabel;
private JLabel docsLabel;
private JLabel discordLabel;

public GUI() {
ResourceBundle bundle = PropertyResourceBundle.getBundle("lang/lang");
Expand All @@ -41,6 +47,31 @@ public GUI() {
String pattern = bundle.getString("version");
versionLabel.setText(MessageFormat.format(pattern, VERSION));

docsLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
discordLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));

docsLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
try {
Desktop.getDesktop().browse(new URI("https://blog.xujiayao.com/posts/4ba0a17a/"));
} catch (Exception ex) {
ex.printStackTrace();
}
}
});

discordLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
try {
Desktop.getDesktop().browse(new URI("https://discord.gg/kbXkV6k2XU"));
} catch (Exception ex) {
ex.printStackTrace();
}
}
});

setPreferredSize(new Dimension(500, 400));
pack();

Expand All @@ -66,7 +97,7 @@ public GUI() {
*/
private void $$$setupUI$$$() {
contentPane = new JPanel();
contentPane.setLayout(new GridLayoutManager(6, 3, new Insets(10, 10, 10, 10), -1, -1));
contentPane.setLayout(new GridLayoutManager(13, 3, new Insets(10, 10, 10, 10), -1, -1));
versionLabel = new JLabel();
Font versionLabelFont = this.$$$getFont$$$(null, -1, 12, versionLabel.getFont());
if (versionLabelFont != null) versionLabel.setFont(versionLabelFont);
Expand All @@ -78,17 +109,17 @@ public GUI() {
final JLabel label1 = new JLabel();
Font label1Font = this.$$$getFont$$$(null, -1, 12, label1.getFont());
if (label1Font != null) label1.setFont(label1Font);
this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("lang/lang", "description"));
this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("lang/lang", "description1"));
contentPane.add(label1, new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
final JSeparator separator2 = new JSeparator();
separator2.setOrientation(0);
contentPane.add(separator2, new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
contentPane.add(separator2, new GridConstraints(11, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
button = new JButton();
Font buttonFont = this.$$$getFont$$$(null, -1, 12, button.getFont());
if (buttonFont != null) button.setFont(buttonFont);
button.setHorizontalAlignment(0);
this.$$$loadButtonText$$$(button, this.$$$getMessageFromBundle$$$("lang/lang", "buttonText"));
contentPane.add(button, new GridConstraints(5, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
contentPane.add(button, new GridConstraints(12, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JLabel label2 = new JLabel();
Font label2Font = this.$$$getFont$$$(null, Font.BOLD, 20, label2.getFont());
if (label2Font != null) label2.setFont(label2Font);
Expand All @@ -101,6 +132,32 @@ public GUI() {
contentPane.add(label3, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
iconLabel = new JLabel();
contentPane.add(iconLabel, new GridConstraints(0, 0, 2, 1, GridConstraints.ANCHOR_SOUTHWEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(50, 50), new Dimension(50, 50), new Dimension(50, 50), 0, false));
final JLabel label4 = new JLabel();
Font label4Font = this.$$$getFont$$$(null, -1, 12, label4.getFont());
if (label4Font != null) label4.setFont(label4Font);
label4.setOpaque(false);
this.$$$loadLabelText$$$(label4, this.$$$getMessageFromBundle$$$("lang/lang", "description2"));
contentPane.add(label4, new GridConstraints(5, 0, 1, 3, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
docsLabel = new JLabel();
Font docsLabelFont = this.$$$getFont$$$(null, -1, 12, docsLabel.getFont());
if (docsLabelFont != null) docsLabel.setFont(docsLabelFont);
this.$$$loadLabelText$$$(docsLabel, this.$$$getMessageFromBundle$$$("lang/lang", "description3"));
docsLabel.setToolTipText("https://blog.xujiayao.com/posts/4ba0a17a/");
contentPane.add(docsLabel, new GridConstraints(7, 0, 1, 3, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
final Spacer spacer1 = new Spacer();
contentPane.add(spacer1, new GridConstraints(8, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
final Spacer spacer2 = new Spacer();
contentPane.add(spacer2, new GridConstraints(6, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
final Spacer spacer3 = new Spacer();
contentPane.add(spacer3, new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
final Spacer spacer4 = new Spacer();
contentPane.add(spacer4, new GridConstraints(10, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
discordLabel = new JLabel();
Font discordLabelFont = this.$$$getFont$$$(null, -1, 12, discordLabel.getFont());
if (discordLabelFont != null) discordLabel.setFont(discordLabelFont);
this.$$$loadLabelText$$$(discordLabel, this.$$$getMessageFromBundle$$$("lang/lang", "description4"));
discordLabel.setToolTipText("https://discord.gg/kbXkV6k2XU");
contentPane.add(discordLabel, new GridConstraints(9, 0, 1, 3, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
}

/**
Expand Down Expand Up @@ -202,4 +259,5 @@ public GUI() {
public JComponent $$$getRootComponent$$$() {
return contentPane;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import javax.swing.*;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Locale;
import java.util.Objects;

/**
Expand All @@ -31,6 +32,8 @@ public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
FlatIntelliJLaf.setup();

//Locale.setDefault(Locale.US);

GUI gui = new GUI();
gui.setVisible(true);
});
Expand Down
5 changes: 4 additions & 1 deletion wrapper/src/main/resources/lang/lang.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ title=Welcome - Discord-MC-Chat (DMCC)
welcome=Welcome to Discord-MC-Chat (DMCC)!
version=Version: {0}
author=By Xujiayao
description=<html>You are trying to open the Discord-MC-Chat JAR file.<br><br>Note:<br>This file is a Minecraft mod. Please place it in the mods folder of your Minecraft server and run it through the Fabric mod loader, instead of opening the JAR file directly.</html>
description1=<html>Oops! You are attempting to run Discord-MC-Chat directly!</html>
description2=<html>Note:<br><br>Discord-MC-Chat is a Fabric Minecraft mod. Please place the JAR file in the "mods" folder of your Minecraft server and run it through the Fabric mod loader, instead of opening it directly.</html>
description3=<html>Please follow <font color="#1B75D0">Discord-MC-Chat Docs</font> to configure Discord-MC-Chat.</html>
description4=<html>If you need more help, you can ask me questions in the <font color="#1B75D0">DMCC Discord Server</font>.</html>
buttonText=&Close
9 changes: 9 additions & 0 deletions wrapper/src/main/resources/lang/lang_en_US.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title=Welcome - Discord-MC-Chat (DMCC)
welcome=Welcome to Discord-MC-Chat (DMCC)!
version=Version: {0}
author=By Xujiayao
description1=<html>Oops! You are attempting to run Discord-MC-Chat directly!</html>
description2=<html>Note:<br><br>Discord-MC-Chat is a Fabric Minecraft mod. Please place the JAR file in the "mods" folder of your Minecraft server and run it through the Fabric mod loader, instead of opening it directly.</html>
description3=<html>Please follow <font color="#1B75D0">Discord-MC-Chat Docs</font> to configure Discord-MC-Chat.</html>
description4=<html>If you need more help, you can ask me questions in the <font color="#1B75D0">DMCC Discord Server</font>.</html>
buttonText=&Close
6 changes: 0 additions & 6 deletions wrapper/src/main/resources/lang/lang_zh.properties

This file was deleted.

9 changes: 9 additions & 0 deletions wrapper/src/main/resources/lang/lang_zh_CN.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title=欢迎 - Discord-MC-Chat (DMCC)
welcome=欢迎使用 Discord-MC-Chat (DMCC)!
version=版本:{0}
author=作者:Xujiayao
description1=<html>哎呀!你正试图直接运行 Discord-MC-Chat!</html>
description2=<html>注意:<br><br>Discord-MC-Chat 是一个 Fabric Minecraft 模组。请将 JAR 文件放入 Minecraft 服务器的 "mods" 文件夹中,并通过 Fabric 模组加载器运行,而并非直接打开。</html>
description3=<html>请按照 <font color="#1B75D0">Discord-MC-Chat 文档</font> 配置 Discord-MC-Chat。</html>
description4=<html>如果你需要更多帮助,你可以在 <font color="#1B75D0">DMCC Discord Server</font> 向我提问。</html>
buttonText=&关闭

0 comments on commit efef398

Please sign in to comment.