Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chinese language support #4

Merged
merged 8 commits into from Dec 27, 2021

Conversation

LingMuQingYu
Copy link
Contributor

Chinese language support.
In our country, many friends are using this software, so we have made multi-language support, but there may be some problems due to the large changes in the code.

Comment on lines 74 to 86

// Load fonts
Profiler.stopAndStart("Load fonts");
try {
font = Font.createFont(Font.TRUETYPE_FONT, Main.class.getResourceAsStream("/resources/OpenSans-Regular.ttf"));
fontLight = Font.createFont(Font.TRUETYPE_FONT, Main.class.getResourceAsStream("/resources/OpenSans-Light.ttf"));
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.registerFont(font);
ge.registerFont(fontLight);
} catch (Exception e) {
e.printStackTrace();
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this removed, is it incompatible with chinese characters? The text looks much worse with the default font.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I see why you removed it, what I dont understand is why it works fine on certain labels and on others it doesnt. For example almost all labels in the settings menu are fine with, but not in the main window. asd
I am not going to remove the better looking font for english users, but I wonder if there is a better solution than to just hard code it and say "use the default font if chinese, otherwise load this font".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this font cannot display Chinese.
I tried to introduce Chinese fonts, but that would have made the package too big. Maybe I can make Chinese use the default fonts of the operating system and English use the built-in fonts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I can try to solve the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
In the code, only the buttons on the Settings page set the font.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The font is set everywhere, since ThemedLabels are used everywhere. I think the reason it works in some places is because some labels are enclosed in html tags, which may cause the text to use a default font if a characted doesnt exist in the used font. I would rather not use html tags everywhere though, I think the best solution is to just use different fonts for different languages.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ill fix this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to go to bed because it's midnight here.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 0eeb34d

@@ -16,7 +16,7 @@
* @since 2021/12/25 14:39
*/
public class I18n {
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("resources/lang/I18n", Locale.getDefault(), new UTF8Control());
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("resources/lang/I18n", Locale.US, new UTF8Control());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, how exactly does it know which language to choose, it seems to me that it will always be english based on this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to change back to the original version when I was testing My English

@Ninjabrain1
Copy link
Owner

Is the en_US file necessary? The default will be used if it is absent, so it can just be deleted right?

@Ninjabrain1
Copy link
Owner

Thank you for doing this! I changed the title back to "Ninjabrain Bot" because I dont think the name should be translated, but let me know if you really think it should be.

@Ninjabrain1 Ninjabrain1 merged commit 55d9ead into Ninjabrain1:main Dec 27, 2021
@Ninjabrain1
Copy link
Owner

The changes will be in the next release, but until then I made this prerelease v1.1.1-pre1

@LingMuQingYu
Copy link
Contributor Author

It is really unnecessary to translate the title.
Thank you for allowing me to add Chinese language into Ninjabrain Bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants