News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Multilingual GUI

Started by Biterider, November 13, 2022, 05:58:54 PM

Previous topic - Next topic

Biterider

Hi
I'm starting to get something to work with. Now I pass a hint to the translation procedure:

CStr SrcLang, "en"
CStr DstLang, "de"

.code
start proc                                              ;Program entry point
  SysInit                                               ;Runtime initialization of OOP model
  DbgClearAll

  OCall $ObjTmpl(Application)::Application.Init         ;Initialize application
  invoke TranslateText, offset DstLang, offset SrcLang, $OfsCStr("File"), $OfsCStr("Menu")
  DbgStrW xax
  invoke TranslateText, offset DstLang, offset SrcLang, $OfsCStr("Open File"), $OfsCStr("Menu")
  DbgStrW xax
  invoke TranslateText, offset DstLang, offset SrcLang, $OfsCStr("Open"), $OfsCStr("Menu")
  DbgStrW xax
  invoke TranslateText, offset DstLang, offset SrcLang, $OfsCStr("Save"), $OfsCStr("Menu")
  DbgStrW xax
  invoke TranslateText, offset DstLang, offset SrcLang, $OfsCStr("Save as..."), $OfsCStr("Menu")
  DbgStrW xax
  invoke TranslateText, offset DstLang, offset SrcLang, $OfsCStr("Print"), $OfsCStr("Menu")
  DbgStrW xax
  invoke TranslateText, offset DstLang, offset SrcLang, $OfsCStr("Exit"), $OfsCStr("Menu")
  DbgStrW xax
  invoke TranslateText, offset DstLang, offset SrcLang, $OfsCStr("Language"), $OfsCStr("Menu")
  DbgStrW xax
  invoke TranslateText, offset DstLang, offset SrcLang, $OfsCStr("English"), NULL
  DbgStrW xax
  invoke TranslateText, offset DstLang, offset SrcLang, $OfsCStr("Spanish"), NULL
  DbgStrW xax
  invoke TranslateText, offset DstLang, offset SrcLang, $OfsCStr("Portuguese"), NULL
  DbgStrW xax
  invoke TranslateText, offset DstLang, offset SrcLang, $OfsCStr("Italian"), NULL
  DbgStrW xax
  invoke TranslateText, offset DstLang, offset SrcLang, $OfsCStr("German"), NULL
  DbgStrW xax
  invoke TranslateText, offset DstLang, offset SrcLang, $OfsCStr("French"), NULL
  DbgStrW xax
  invoke TranslateText, offset DstLang, offset SrcLang, $OfsCStr("OK"), $OfsCStr("Button")
  DbgStrW xax
  invoke TranslateText, offset DstLang, offset SrcLang, $OfsCStr("Cancel"), $OfsCStr("Button")
  DbgStrW xax
  invoke TranslateText, offset DstLang, offset SrcLang, $OfsCStr("Search"), $OfsCStr("Button")
  DbgStrW xax

;  OCall $ObjTmpl(Application)::Application.Run          ;Execute application
  OCall $ObjTmpl(Application)::Application.Done         ;Finalize application

  SysDone                                               ;Runtime finalization of the OOP model
  invoke ExitProcess, 0                                 ;Exit program returning 0 to the OS
start endp


All results seem to be correct, at least for the languages I know
German
xax -> Datei
xax -> Datei öffnen
xax -> Öffnen
xax -> Speichern
xax -> Speichern unter...
xax -> Drucken
xax -> Beenden
xax -> Sprache
xax -> Englisch
xax -> Spanisch
xax -> Portugiesisch
xax -> Italienisch
xax -> Deutsch
xax -> Französisch
xax -> OK
xax -> Abbrechen
xax -> Suchen

Spanish
xax -> Archivo
xax -> Abrir archivo
xax -> Abrir
xax -> Guardar
xax -> Guardar como...
xax -> Imprimir
xax -> Salir
xax -> Idioma
xax -> Inglés
xax -> Español
xax -> Portugués
xax -> Italiano
xax -> Alemán
xax -> Francés
xax -> Aceptar
xax -> Cancelar
xax -> Buscar

Italian
xax -> File
xax -> Apri file
xax -> Apri
xax -> Salva
xax -> Salva con nome...
xax -> Stampa
xax -> Esci
xax -> Lingua
xax -> Inglese
xax -> Spagnolo
xax -> Portoghese
xax -> Italiano
xax -> Tedesco
xax -> Francese
xax -> OK
xax -> Annulla
xax -> Cerca


I can not check the correctness in other languages.
Maybe I can write a test application where other languages like Russian or Chinese can be selected and other forum members could check the results.

These are the results for now:
Russian
xax -> Файл
xax -> Открыть файл
xax -> Открыть
xax -> Сохранить
xax -> Сохранить как...
xax -> Печать
xax -> Выход
xax -> Язык
xax -> Английский
xax -> Испанский
xax -> Португальский
xax -> итальянский
xax -> Немецкий
xax -> Французский
xax -> ОК
xax -> Отмена
xax -> Искать

Simplified Chinese
Work in progress... :-)



Biterider

Biterider

Traditional Chinese
xax -> 文件
xax -> 打開文件
xax -> 打開
xax -> 保存
xax -> 另存為...
xax -> 打印
xax -> 退出
xax -> 語言
xax -> 英語
xax -> 西班牙語
xax -> 葡萄牙語
xax -> 意大利語
xax -> 德語
xax -> 法語
xax -> 確定
xax -> 取消
xax -> 搜索


Biterider

learn64bit

Simplified(cn) - Traditional(tw)
开 - 開
为 - 為
语 - 語
确 - 確

Biterider

Thanks learn64bit
I mixed the chinese language definitions. I corrected the above post.
The result for simplified chinese is

xax -> 文件
xax -> 打开文件
xax -> 打开
xax -> 保存
xax -> 另存为...
xax -> 打印
xax -> 退出
xax -> 语言
xax -> 英语
xax -> 西班牙语
xax -> 葡萄牙语
xax -> 意大利语
xax -> 德语
xax -> 法语
xax -> 确定
xax -> 取消
xax -> 搜索


Hindi
xax -> फ़ाइल
xax -> फ़ाइल खोलें
xax -> खोलें
xax -> सहेजें
xax -> इस रूप में सहेजें ...
xax -> प्रिंट
xax -> बाहर निकलें
xax -> भाषा
xax -> अंग्रेज़ी
xax -> स्पैनिश
xax -> पुर्तगाली
xax -> इतालवी
xax -> जर्मन
xax -> फ्रेंच
xax -> ठीक है
xax -> रद्द करें
xax -> खोज


Japanese
xax -> ファイル
xax -> ファイルを開く
xax -> 開く
xax -> 保存
xax -> 名前を付けて保存...
xax -> 印刷
xax -> 終了
xax -> 言語
xax -> 英語
xax -> スペイン語
xax -> ポルトガル語
xax -> イタリアの
xax -> ドイツ人
xax -> フランス語
xax -> OK
xax -> キャンセル
xax -> 検索



Biterider


Biterider

Hi all
I ask those members who are fluent in the languages of the above posts to check that the translations are correct.
It would help me a lot to verify that the hints are working as intended.

Many thanks.  :thumbsup:

Biterider

Biterider

Hi
When translating a bunch of single words one after the other, the overall process is slow.
For this reason I am changing the strategy, collecting the words first and sending them all together in a single request. This means the response has to be parsed, but I think the speed gain is worth the effort.

Biterider

Biterider

Hi
Bad news...  :sad:
The free service seems to have some limitations: it can not process multiple lines at the same time.
It is designed to translate single sentences.

We have to live with it, which isn't a major problem for the current goal.


Biterider

Biterider

Hi
As a proof of concept, I wrote a demo application that changes the main menu based on a user selection.
Alternatively, the machine locale could be used, but the demo was written to show their online translation capabilities.
Once a language has been selected via the "Languages" submenu (this submenu is intentionally excluded from the translation, preserving the native language names), a nice throbber will appear (only if the OS version is >= 8) while the translation is in action.  :cool:
The final result is saved in a file, so that the next time the application is started, the last translation is immediately active.

For this demo I randomly selected only 10 languages from Google's list. It currently contains more than 90 languages.

Since the application resource section is filled with a large amount of throbber images, its size exceeds the upload limit of the forum. The application can be downloaded from GitHub using the following link https://github.com/ObjAsm/ObjAsm-C.1/raw/master/Projects/X/Multilingual%20GUI/ML_GUI.exe

The complete source code is also available on GitHub, but the original idea and code is posted above.
The code for single translations can be found in the attachment.

Biterider

HSE

Hi Biterider!

Quote from: Biterider on November 20, 2022, 09:13:32 PM
application resource section is filled with a large amount of throbber images

Nice, but to much. In Win7 (without throbber) translation is instantaneus.  :thumbsup:

Quote from: Biterider on November 20, 2022, 09:13:32 PM
The complete source code is also available on GitHub

I cloned full repository in High Contrast machine.

Look fantastic. Still some dynamic layout metric is not perfect, because there are some superpositions (1 to 3 pixels, or so).

Object Explorer don't work. I was thinking I brokened that, but apparently wasn't me this time  :biggrin:

HSE
Equations in Assembly: SmplMath

jj2007

No throbber on Win7-64, as expected, but the translation works fine, with a 3 second delay :thumbsup:

Biterider

Hi
Thanks for testing  :cool:

@HSE:
Knowing that a good friend uses HC, I invested some time to add some improvements :biggrin:
Can you send me a screenshot of the "dynamic layout" issue? It will help a lot to pinpoint the problem.
It may be that the ObjectExplorer is confused because I uploaded the file ObjAsm\code\OA_Info.stm which contains information about my own system. Try deleting the file and restarting the application.
I'll remove this file from GitHub too.

@JJ:
The few seconds delay is due to the running of the online service. It's not related to the application itself. I tried using a batch approach but it didn't work. Maybe sending multiple requests at once can solve the problem.
Since I haven't had any more time so far, I've installed the Throbber, which makes those few seconds go by much faster.  :rolleyes:

Biterider

jj2007

Quote from: Biterider on November 20, 2022, 09:13:32 PMAs a proof of concept, I wrote a demo application that changes the main menu based on a user selection.

Hi Biterider,

News from my own baby, with now about 700 translations :cool:

daydreamer

I have interest in foreign languages, so i downloaded language packs,for example japanese, would it be possible to get info from language pack instead?
Or some way to find windows data somewhere it keeps native meny texts?
.cpp for example in resource file dialogs for file, help,about box is kept there
So swedish version programs probably keep it there or indirect loads it from other files
@JJ
Fluent in x86,x64,German, Italian I guess  :greenclp:
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

TimoVJL

EnumUILanguagesA function (winnls.h)

QuoteIn the registry is this

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\MUI\UILanguages\en-US]
"LCID"=dword:00000409
"Type"=dword:00000091

Some experiments:
https://forum.pellesc.de/index.php?topic=5324.msg20459#msg20459
void SetLang(HWND hwnd, LANGID lid)
{
typedef LANGID (WINAPI *fnSetThreadUILanguage) (LANGID wReserved);
HMENU hMenu;
if ((GetVersion() & 0x00FF) > 5) // Vista =>
{
fnSetThreadUILanguage fnPtr = (fnSetThreadUILanguage)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetThreadUILanguage");
if (fnPtr)
(*fnPtr) (lid);
} else
SetThreadLocale(MAKELCID(lid, SORT_DEFAULT));
hMenu = GetMenu(hwnd);
SetMenu(hwnd, NULL);
DestroyMenu(hMenu);
hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(2001));
SetMenu(hwnd, hMenu);
}
Is this, what you was after ?
May the source be with you

jj2007

Hi Biterider,

You might find these interesting:

https://translatepress.com/deepl-vs-google-translate-comparison/

QuoteWith both Google Translate and DeepL, you can translate up to 500,000 characters (not words) per month for free. This is 100% free forever. So as long as you stay under 500,000 characters per month, you could use either API for free.

https://blog.meinrad.cc/en/deepl-google-translate-not-all-machine-translation-engines-are-created-equal

QuoteThe real difference between these two engines is in the technology they use. Both use neural networks, but Google Translate (like most other machine translation engines) uses what are known as recurrent neural networks. By contrast, DeepL uses convolutional neural networks (CNNs), which produce better all-round results for longer, continuous sequences of words. Although CNNs aren't perfect, and so far haven't been used by other machine translation providers, they process texts better in parallel and produce better translations as a result.