How to add multiple language support in Delphi XE2 application

639 Views Asked by At

I'm a beginner in Delphi but I need to add multiple other languages support to current application.

Projects->Languages->Add(languages) does not work in my version of Delphi and gives these errors on compiling:

[Error] E1026 File not found: 'vcl\DBLOGDLG.dfm'
[Error] E1026 File not found: 'vcl\DBPWDLG.dfm'

I tried creating my own translation by adding them to [root]/lang/ en.rc , lt.rc, lv.rc Example of lang.rc

STRINGTABLE
BEGIN
    telefon_monitor L"Phone Monitoring"
    koned L"Calls"
    alates L"From"
    kuni L"Until"
    vali_numbrid L"Choose numbers"
    otsi L"Search"
    tolgi L"Translate"
    satted L"Settings"
    salvesta L"Save"
    lisa_rida L"Add row"
END

I have no idea how to read them.

Does anyone have any better idea how to load translations? What I want to do is, read config.ini [language] section and based that display translation from .rc file or some better extensions.

1

There are 1 best solutions below

2
MysteriousNothing On

Could not use github.com/albertodev01/TLanguages on Delphi XE2 which sucks.

I ended up creating a translation.json file and overwrite default values on Application.FormCreate plus made language toggle system

{ "en_EN":{ "hello":"Hello!" },
  "lv_LT":{ "hello":"Hi!" }
}

PS! Parsing nested json in older Delphi is something else.