Skip to content

Conversation

@Filtik
Copy link
Contributor

@Filtik Filtik commented Jan 1, 2026

Launcher language change automaticly if language changing

Filtik and others added 2 commits January 1, 2026 21:49
Launcher language change automaticly if language changing
@dgelessus
Copy link
Contributor

(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 pfLocalizationMgr is only initialized after login (I vaguely remember that it's because parsing all the XML files causes a short but noticeable delay, but I may be wrong...). If we can initialize pfLocalizationMgr earlier, we can convert the existing hardcoded translations to XML files, and then these new translations should also be done in XML.

@colincornaby
Copy link
Contributor

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.

@colincornaby
Copy link
Contributor

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.

@dgelessus
Copy link
Contributor

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.

@Filtik
Copy link
Contributor Author

Filtik commented Jan 2, 2026

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.

`
LANGID systemLang = GetUserDefaultUILanguage();
WORD primaryLang = PRIMARYLANGID(systemLang);

plLocalization::Language startLang;

if (primaryLang == LANG_GERMAN) {
startLang = plLocalization::kGerman;
}
else {
startLang = plLocalization::kEnglish;
}

plLocalization::SetLanguage(startLang);
SetWindowsUILanguage(startLang);

HWND hCombo = GetDlgItem(hwndDlg, IDC_LANGUAGE);
SendMessage(hCombo, CB_SETCURSEL, (WPARAM)startLang, 0);

UpdateDialogTexts(hwndDlg);
`

@TheScarFr
Copy link
Contributor

TheScarFr commented Jan 2, 2026

Have you, guys, think about the possibility to add a second language selection list for the KI commands?
We now all have the habitude to use the English commands, like "/clearchat", for example, but if I set the game language to French, I'll have to use "/effacerconversation"...
To have the possibility to use another language for the KI commands, at least English, would be nice.
(Personally, with my memory problems, I'd have to memorise both English and French KI commands, instead of only English...)

@dgelessus
Copy link
Contributor

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?

@TheScarFr
Copy link
Contributor

Done: #1833

Comment on lines +582 to +587
static const char* LoadLocalizedString(UINT nID)
{
static char buffer[256];
LoadStringA(gHInst, nID, buffer, sizeof(buffer));
return buffer;
}
Copy link
Member

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.

Suggested change
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;
}

Comment on lines +609 to +610
SetDlgItemText(hwndDlg, IDC_BUTTON_ACCEPT, LoadLocalizedString(IDC_TEXT_ACCEPT));
SetDlgItemText(hwndDlg, IDC_BUTTON_DECLINE, LoadLocalizedString(IDC_TEXT_DECLINE));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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);
Copy link
Member

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>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#include <windows.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

@@ -0,0 +1,22 @@
#include "resource.h"
#include <windows.h>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#include <windows.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

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.

5 participants