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

Initial commit for multilingual UI, and Hungarian translation #1790

Merged
merged 26 commits into from Nov 13, 2021
Merged

Initial commit for multilingual UI, and Hungarian translation #1790

merged 26 commits into from Nov 13, 2021

Conversation

Copy link

@ghost ghost commented Nov 8, 2021

Summary

This PR adds a kinda effortless solution to translate the current UI, via separating the RC file into multiple parts.

2021-11-08_19h17_07

The UI translation after this PR can be added to src\win\languages by translating en-US.rc and then adding a single line to 86Box.rc to include the new translation. The language-dependent loading of resources are done with the existing code, and Windows itself, no further changes needed.

The PR also adds a Hungarian translation for 86Box, as first translated language.

Edit: Even if an UI rewrite is in progress, I think the translations for multiple languages probably can re-used after the rewrite.

Checklist

References

https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-LCID/%5bMS-LCID%5d.pdf

Laci bá added 3 commits Nov 7, 2021
Add the possibility to change runtime language, via --lang parameter. Also specify the verbose language code in the Hungarian translation.
@ghost
Copy link
Author

@ghost ghost commented Nov 9, 2021

A brief introduction to this language system

The basic concept of this language system, that 86Box has a Win32 UI currently, which uses resources to display dialogs, menus, controls, etc.

What's under the hood?

The Windows itself allows to define multiple resources on the same name with different languages. This PR uses this feature to provide multilanguage UI with minimal changes.

In order to achieve this the win/86box.rc file was split to a localizable, and a non-localizable part. After then the localizable part was translated to Hungarian language.

Changing the language

Changing language is very complicated, because needs a heavy planning about how all the possibly localized in-memory contents should change when the language-switch occurs.

Because of this I've decided about allowing the language-switch only at startup. This means that the selected display language is fixed for the whole run-time.

Originally this system used the Windows's display language, without allowing to differ from it. By that in order to display the Hungarian UI, you had to use Hungarian Windows (or MUI).

Introducing --lang or -G

With the recent commits this behavior was changed, so you can choose between any translated languages you wish for 86Box, with the ˙-G ˙ or ˙--lang ˙ parameter.

You can find a list about language codes here.

Example

In order to test 86Box in Hungarian, without having Hungarian Windows (or MUI), you can use the following command line.

86box --lang hu-HU

How can I translate 86Box?

1, Look up for the desired language in the linked table above.
2, Create a copy from win/languages/en-US.rc to win/languages/<your_language-code>.rc
3, Change the header of the fresh RC file according to the destination language. You can find the constants' name here.
(e.g. for Hungarian I had to use LANGUAGE_HUNGARIAN,SUBLANG_DEFAULT, or 0xE,0x1)
4, Also add your name as Translator to the header.
4, Translate all the strings, then save your changes.
5, Open win/86box.rc, and add a new #include line, where you link to your fresly created translation.
6, Build 86Box with the changes, and start it with your new translation. Check that every text fits in their place.
7, Done!

Laci bá and others added 23 commits Nov 9, 2021
- Fix the broken itemindex of ComboBox  in the Settings dialog
- Change from LCID to uint32_t
- Rewrite the headers of the lang related functions (can handle the whole LCID as input)
- Add dummy functions to unix.c
- Add proper combobox handling in win_settings.c
- Added a lot of debug calls temporarily
- Reactivate every disabled option related to language changes
- Move lang_id to 86box.h from win.h
- Implement on-fly resource switch as discussed with OBattler
- Reimplement everything language related in the initialization section of the program
- Implemented the ladder of three points
1, what is the --lang?
2, what are definied in the config? (to be implemented)
3, what is the system language
Also update everything and save the config without hard reset.
Move to translateable (System Default) message
Move change language to Tools menu
Redesign the language dialog
Add the translators' name to the About dialog, to make the translation process more attractive
And remove some unnecessary stuff.
@OBattler OBattler merged commit bd36a10 into 86Box:master Nov 13, 2021
0 of 45 checks passed
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

1 participant