StringManipulation icon indicating copy to clipboard operation
StringManipulation copied to clipboard

Feature Request - Enable Chinese UI only when the Chinese Lang Pack is enabled

Open jonathanlermitage opened this issue 2 years ago • 6 comments

I would like to suggest something: for now, the Chinese UI is enabled if the system's locale is set to zh.
Meanwhile, some Chinese users may want to keep the English UI. Also, other users may want to enable the Chinese UI on non-zh locale (per example, on a corporate computer).
A solution is to detect the official Chinese Language Pack, then load the Chinese resource bundle, and do NOT rely on the system's locale.

A contributor suggested me this feature on another plugin, and this is how I implemented it:

  • detect the Chinese Language Pack: https://github.com/jonathanlermitage/intellij-extra-icons-plugin/blob/master/src/main/java/lermitage/intellij/extra/icons/utils/IDEUtils.java
  • load the Chinese resource bundle only if the Chinese Language Pack is activated: https://github.com/jonathanlermitage/intellij-extra-icons-plugin/blob/master/src/main/java/lermitage/intellij/extra/icons/utils/I18nUtils.java

That also means you cannot use the GUI form designer in order to link the labels strings to a resource bundle (double-click on a field, then pick a resource bundle and an i18n key). Instead, you have to set the fields strings manually:

  • I get the appopriate resource bundle: https://github.com/jonathanlermitage/intellij-extra-icons-plugin/blob/master/src/main/java/lermitage/intellij/extra/icons/cfg/SettingsForm.java#L105
  • then I update the fields labels: https://github.com/jonathanlermitage/intellij-extra-icons-plugin/blob/master/src/main/java/lermitage/intellij/extra/icons/cfg/SettingsForm.java#L261

Nota: there is one downside -> you cannot translate IDE settings menu items (in the left panel), because you have to give the resource bundle name in settings.xml, so you cannot invoke the code which selects the right resource bundle (there is an open issue for that).

jonathanlermitage avatar Mar 11 '23 22:03 jonathanlermitage

Thanks. The whole situation sucks.

I have too many UIs to do it programmatically. I think the best would be to somehow do multiple releases with Gradle - one normal and one Chinese - https://plugins.jetbrains.com/plugin/2162-string-manipulation/versions/chinese Then advertise it inside the IDE for people with Zh locale + an action that would add https://plugins.jetbrains.com/plugins/list?channel=chinese&pluginId=2162 to plugin repositories.

For now, I made a new release without Chinese.

krasa avatar Mar 11 '23 23:03 krasa

I see, I totally agree. Thx for the explanation! 👍

jonathanlermitage avatar Mar 11 '23 23:03 jonathanlermitage

If you want to suggest a plugin, you can use this api: https://plugins.jetbrains.com/docs/intellij/ide-infrastructure.html#plugin-suggestions

jonathanlermitage avatar Mar 11 '23 23:03 jonathanlermitage

The Chinese version has not been updated simultaneously, which is simply too uncomfortable for me with updating obsessive-compulsive disorder

jinxiangqiang avatar Jul 11 '23 08:07 jinxiangqiang

The Chinese version has not been updated simultaneously, which is simply too uncomfortable for me with updating obsessive-compulsive disorder

I think contributions are welcome :-)
Internationalization files are located here: https://github.com/krasa/StringManipulation/tree/master/src/main/resources/messages

jonathanlermitage avatar Jul 11 '23 09:07 jonathanlermitage

The Chinese version has not been updated simultaneously, which is simply too uncomfortable for me with updating obsessive-compulsive disorder

Yeah, I need to automate it.

krasa avatar Jul 11 '23 09:07 krasa