I have an application which shows a window with two buttons (Ok and Cancel), I was using it in English, but now I want to show Ok and Cancel button's text in Chinese.
My original code was:
if win32con.IDOK == win32gui.MessageBox(self.hwnd,self.dic.voc["mainwin.quitConfirm"],
self.dic.voc["mainwin.quitConfirmTitle"],
win32con.MB_OKCANCEL):
And now I am trying with MessageBoxExW
function, because in the API page says you can use any language in the last parameter (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messageboxexw).
So now my code is as follows:
lang = win32api.MAKELANGID(4, 2)
if win32con.IDOK ==ctypes.windll.user32.MessageBoxExW(self.hwnd,self.dic.voc["mainwin.quitConfirm"], self.dic.voc["mainwin.quitConfirmTitle"], win32con.MB_YESNO, lang):
But it continues showing the text buttons in English, not in Chinese, I have also set in my computer, in Region and Language, Chinese(Simplified, PRC) in 'Formats' and in 'System Locale'. And my script is encoded as 'UTF-8'.
When I run this,
locale.getdefaultlocale(["LANGUAGE"])
I obtain,
('zh_CN', 'cp936')
I would appreciate very much any help or clue. Thank you very much.
If you are using Windows 10, you need to install a language pack in Windows for the specified language.
It does NOT have to be the default displayed language, but it needs to be in the installed language packs.