-
Notifications
You must be signed in to change notification settings - Fork 85
Launcher language #1832
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
base: master
Are you sure you want to change the base?
Launcher language #1832
Conversation
Launcher language change automaticly if language changing
|
(repeating what I told Filtik via chat, so others can also read it) Ideally, the login dialog would use the same XML translation mechanism as the rest of the game, so that the translations can be shared across OSes. This isn't possible at the moment, because |
|
Just a comment to show that I've noticed this PR as The Mac Guy. No strong input right now - but macOS does store the user's language and has a language preference hierarchy. It would be good to wire that in - even if there is a dialog entry. Not sure if Windows has the same sort of feature. |
|
Ah - this is localizing the launcher itself. I wonder if our internal mechanism could be plugged into Apple's. But I don't know if we'd need to have platform parity on this. |
|
Yes, it would be nice to select the system language by default (instead of just defaulting to English) if the player hasn't made a language choice yet. That can be implemented with or without this PR though - the language selector already exists, just the login dialog is always in English. |
That might be something you mean. ` plLocalization::Language startLang; if (primaryLang == LANG_GERMAN) { plLocalization::SetLanguage(startLang); HWND hCombo = GetDlgItem(hwndDlg, IDC_LANGUAGE); UpdateDialogTexts(hwndDlg); |
|
Have you, guys, think about the possibility to add a second language selection list for the KI commands? |
|
That is also a separate feature request about the existing language selector and is independent of this PR, which works on translating the login dialog. Could you please create a separate issue for this, so it doesn't get lost in the PR discussion here? |
|
Done: #1833 |
| static const char* LoadLocalizedString(UINT nID) | ||
| { | ||
| static char buffer[256]; | ||
| LoadStringA(gHInst, nID, buffer, sizeof(buffer)); | ||
| return buffer; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to best support all languages, we should probably use unicode here. Also, per the documentation, we can ask for a read only pointer to the string and avoid the copy.
| static const char* LoadLocalizedString(UINT nID) | |
| { | |
| static char buffer[256]; | |
| LoadStringA(gHInst, nID, buffer, sizeof(buffer)); | |
| return buffer; | |
| } | |
| static const wchar_t* GetLocalizedString(UINT nID) | |
| { | |
| wchar_t* buffer = nullptr; | |
| LoadStringW(gHInst, nID, reinterpret_cast<LPWSTR>(&buffer), 0); | |
| return buffer; | |
| } |
| SetDlgItemText(hwndDlg, IDC_BUTTON_ACCEPT, LoadLocalizedString(IDC_TEXT_ACCEPT)); | ||
| SetDlgItemText(hwndDlg, IDC_BUTTON_DECLINE, LoadLocalizedString(IDC_TEXT_DECLINE)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| SetDlgItemText(hwndDlg, IDC_BUTTON_ACCEPT, LoadLocalizedString(IDC_TEXT_ACCEPT)); | |
| SetDlgItemText(hwndDlg, IDC_BUTTON_DECLINE, LoadLocalizedString(IDC_TEXT_DECLINE)); | |
| SetDlgItemTextW(hwndDlg, IDC_BUTTON_ACCEPT, GetLocalizedString(IDC_TEXT_ACCEPT)); | |
| SetDlgItemTextW(hwndDlg, IDC_BUTTON_DECLINE, GetLocalizedString(IDC_TEXT_DECLINE)); |
| return size * nmemb; | ||
| } | ||
|
|
||
| void SetWindowsUILanguage(plLocalization::Language lang) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| void SetWindowsUILanguage(plLocalization::Language lang) | |
| static void SetWindowsUILanguage(plLocalization::Language lang) |
| else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_LANGUAGE) | ||
| { | ||
| HWND hCombo = (HWND)lParam; | ||
| int currentIndex = (int)SendMessage(hCombo, CB_GETCURSEL, 0, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| int currentIndex = (int)SendMessage(hCombo, CB_GETCURSEL, 0, 0); | |
| int currentIndex = ComboBox_GetCurSel(hCombo); |
| int currentIndex = (int)SendMessage(hCombo, CB_GETCURSEL, 0, 0); | ||
|
|
||
| if (currentIndex != CB_ERR) { | ||
| plLocalization::Language new_language = (plLocalization::Language)SendMessage(GetDlgItem(hwndDlg, IDC_LANGUAGE), CB_GETCURSEL, 0, 0L); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could just cast currentIndex to plLocalization::Lanuage instead of asking for the current selection again.
| @@ -0,0 +1,22 @@ | |||
| #include "resource.h" | |||
| #include <windows.h> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #include <windows.h> | |
| #define WIN32_LEAN_AND_MEAN | |
| #include <windows.h> |
| @@ -0,0 +1,22 @@ | |||
| #include "resource.h" | |||
| #include <windows.h> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #include <windows.h> | |
| #define WIN32_LEAN_AND_MEAN | |
| #include <windows.h> |
Launcher language change automaticly if language changing