Skip to content

Conversation

@ShadowLoveElysia
Copy link

@ShadowLoveElysia ShadowLoveElysia commented Nov 23, 2025

Hi! I implemented a translation system for CompactGUI.

It works by scanning the UI at runtime and replacing text using JSON files, so I didn't have to change your existing hardcoded strings (safe and clean).

What's new:

  • Auto-detects system language on first run.
  • Automatically switch the displayed language when changing the language (only for ComboBoxItem)
  • Added a Language Selector in the Settings page.
  • Added localization files for Chinese, Japanese, German, French, etc. in the i18n folder.
  • Translations are fully external (JSON), easy for others to contribute.

🐛 One small heads-up (Help Needed):
The "View on GitHub" button currently disappears when the translation logic runs.
I suspect my reflection code is accidentally overwriting the button's complex content (Icon + Text) with a simple string. I'm not sure how to fix this specific button without breaking the loop, so I might need your help on that part! 😅

Hope this helps more people use this tool!

This is the modified interface and effect I have created.
image
image
image

Copy link

@wuyilingwei wuyilingwei left a comment

Choose a reason for hiding this comment

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

Looks fine

@panda361
Copy link

Nice work! One concern: the reflection-based approach using original text as keys feels fragile (some controls get overwritten, changes to wording break translations).

Would you (and the original author) be open to moving toward stable keys and a standard i18n pattern (resource dictionaries) in the future? If so, I’m happy to help flesh it out. 👀

@ShadowLoveElysia
Copy link
Author

Nice work! One concern: the reflection-based approach using original text as keys feels fragile (some controls get overwritten, changes to wording break translations).

Would you (and the original author) be open to moving toward stable keys and a standard i18n pattern (resource dictionaries) in the future? If so, I’m happy to help flesh it out. 👀

At first, I also wanted to try the separation. However, after I did it myself, I found that there would be a bunch of problems during the compilation. The current version is the result of my trade - offs, and it seems to be working quite well at present.🤔

@Iridium-IO
Copy link
Member

Love this, and so much easier than going through the hassle of resource dictionary setups!

@ShadowLoveElysia
Copy link
Author

Love this, and so much easier than going through the hassle of resource dictionary setups!

However, it is worth noting that reflection based translation requires simultaneous modification/addition of the corresponding English/other language in the JSON whenever the string is changed

@ShadowLoveElysia
Copy link
Author

Love this, and so much easier than going through the hassle of resource dictionary setups!

Apart from adding the corresponding English and translation to JSON every time a new string is added, there are no other requirements

@panda361
Copy link

Nice work! One concern: the reflection-based approach using original text as keys feels fragile (some controls get overwritten, changes to wording break translations).
Would you (and the original author) be open to moving toward stable keys and a standard i18n pattern (resource dictionaries) in the future? If so, I’m happy to help flesh it out. 👀

At first, I also wanted to try the separation. However, after I did it myself, I found that there would be a bunch of problems during the compilation. The current version is the result of my trade - offs, and it seems to be working quite well at present.🤔

Makes sense. If there’s no big refactor planned, the current approach works efficiently enough. 🚀

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.

4 participants