SKCraft / Launcher

🚀 Distribute your Minecraft modpacks with a custom launcher
Other
620 stars 433 forks source link

ISO-8859-1 is not a suitable encoding for my language #467

Closed MJRamon closed 2 years ago

MJRamon commented 2 years ago

Looks like encoding problem is still not fixed. Tried to translate to Ukrainian language - same deal as it was 7 years ago.

https://github.com/SKCraft/Launcher/issues/123 https://github.com/SKCraft/Launcher/issues/95

hedgehog1029 commented 2 years ago

I'm happy to update the encoding but I do have to consider backwards compatibility; I think I have an idea on how to do this though.

MJRamon commented 2 years ago

I'd suggest to migrate to Java 17, but I guess it will be a lot of work.

Also, there are no lang lines for "Yes" and "No" buttons.

For anyone waiting for fix: you can use "jUniConv Unicode Characters to Java Entities Converter" https://itpro.cz/juniconv/

hedgehog1029 commented 2 years ago

Yes, you can actually work around the encoding limitation by using Java unicode escapes.

Everything is supported on java 8; currently we have no plans to migrate up to 17 because of the launcher's current reliance on "whatever Java version the user has installed".

I think the "Yes"/"No" buttons are generated internally by Swing, so that's odd.

hedgehog1029 commented 2 years ago

You can now use UTF-8 encoded properties files if they have a byte-order mark (U+FEFF) at the beginning

MJRamon commented 2 years ago

You can now use UTF-8 encoded properties files if they have a byte-order mark (U+FEFF) at the beginning

Can you elaborate with an example for a lang file line?

hedgehog1029 commented 2 years ago

You just need to save the Launcher_xx.properties file as "UTF-8 with BOM" as offered by some text editors - for example notepad++ can do it via the "Encoding" menu.

The BOM is a sequence of bytes that encodes the Unicode character U+FEFF BYTE ORDER MARK, which in UTF-8 is the byte sequence EF BB BF. These needs to be present as the first 3 bytes in the file for the launcher to detect it as UTF-8.

hedgehog1029 commented 2 years ago

Updated the Wiki: https://github.com/SKCraft/Launcher/wiki/Localization

MJRamon commented 2 years ago

Are you sure it's working as intended? image

hedgehog1029 commented 2 years ago

I did do a basic test last night. If you're seeing missing keys, check the launcher log (viewable by running the launcher from the commandline, e.g. java -jar launcher-4.6-SNAPSHOT.jar) for any error messages.

mesl commented 2 years ago

I also encountered the language issue in the latest version, I found this error:

java.util.MissingResourceException: Can't find bundle for base name com.skcraft.launcher.lang.Launcher, locale en_US
        at java.base/java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:2045)
        at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1683)
        at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1586)
        at java.base/java.util.ResourceBundle.getBundle(ResourceBundle.java:1504)
        at com.skcraft.launcher.util.SharedLocale.loadBundle(SharedLocale.java:98)
        at com.skcraft.launcher.Launcher.<init>(Launcher.java:90)
        at com.skcraft.launcher.Launcher.<init>(Launcher.java:78)
        at com.skcraft.launcher.Launcher.createFromArguments(Launcher.java:432)
        at com.skcraft.launcher.FancyLauncher$1.run(FancyLauncher.java:39)
        at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:771)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
        at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:741)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.io.IOException: mark/reset not supported
        at java.base/java.util.zip.InflaterInputStream.reset(InflaterInputStream.java:290)
        at java.base/java.io.FilterInputStream.reset(FilterInputStream.java:224)
        at com.skcraft.launcher.util.LocaleEncodingControl.newBundle(LocaleEncodingControl.java:46)
        at java.base/java.util.ResourceBundle.loadBundle(ResourceBundle.java:1984)
        at java.base/java.util.ResourceBundle.findBundle(ResourceBundle.java:1770)
        at java.base/java.util.ResourceBundle.findBundle(ResourceBundle.java:1722)
        at java.base/java.util.ResourceBundle.findBundle(ResourceBundle.java:1722)
        at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1656)
        ... 20 more
hedgehog1029 commented 2 years ago

interesting, I guess sometimes the jar stream doesn't support mark/reset, and sometimes it does. will land a fix shortly

hedgehog1029 commented 2 years ago

Ah, turns out the ZipInputStream that you get with a JAR doesn't support mark/reset. Should be fixed in master.