Following on from the discussion here: https://forum.powerbasic.com/forum/u...ion#post822964
(Please put any discussion there, not here in the Source Code forum)
One method of "internationalising" your application with a language file embedded as RCData.
'

(Please put any discussion there, not here in the Source Code forum)
One method of "internationalising" your application with a language file embedded as RCData.
'
Code:
'Uses a translations file. 'File is UTF-8 encoded, $CRLF delimited (you can even create it with Notepad) 'Each line contains three Tab delmited values: 'IDString, English wording, Translation #COMPILE EXE #DIM ALL #RESOURCE RCDATA,transdata,"Russian.txt" #INCLUDE ONCE "WIN32API.INC" ENUM ctrls SINGULAR IDC_btnAction= 1001 END ENUM FUNCTION Translate(wsValue AS WSTRING) AS WSTRING LOCAL lngTrans,lngSearchLen AS LONG LOCAL wsTranslations AS WSTRING DIM trans() AS STATIC WSTRING IF NOT ARRAYATTR(trans(), 0) THEN wsTranslations = UTF8TOCHR$(RESOURCE$(RCDATA,"transdata")) lngTrans = PARSECOUNT(wsTranslations,$CRLF) REDIM trans(1 TO lngTrans) PARSE wsTranslations, trans(),$CRLF END IF lngSearchLen = LEN(wsValue)+1 ARRAY SCAN trans() ,FROM 1 TO lngSearchLen, COLLATE UCASE, = wsValue & $TAB , TO lngTrans IF lngTrans > 0 THEN FUNCTION = PARSE$(trans(lngTrans),$TAB,3) END IF END FUNCTION FUNCTION PBMAIN() AS LONG LOCAL lRslt AS LONG LOCAL hDlg AS DWORD DIALOG NEW 0, Translate("CAPTION"), , , 200, 180, %WS_SYSMENU, TO hDlg CONTROL ADD BUTTON , hDlg,%IDC_btnAction,Translate("ACTION"),60,130,80,20 DIALOG SHOW MODAL hDlg, CALL MainDlgCB TO lRslt END FUNCTION CALLBACK FUNCTION MainDlgCB() SELECT CASE AS LONG CB.MSG CASE %WM_COMMAND SELECT CASE AS LONG CB.CTL CASE %IDC_btnAction IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN ? Translate("MSG1"),,Translate("MSGTITLE") END IF END SELECT END SELECT END FUNCTION '
Comment