Alberto Miola 10 Posted January 2, 2019 (edited) I've always had the need to translate my apps in many languages and it's not something that's already integrated in the IDE. Or better, you can localize your VCL projects but there is no support for FMX (and thus, no support for Android/iOS). I have decided to create a component that works with VCL and FMX and can be used to localize your win/android/ios applications. Once the components has been installed in the IDE, it load a json file with all the various translations. This particular json will be created and maintained using the editor I've created. GitHub repo In the repo you can find a quick install guide, a simple tutorial and the source code. I have decided to use this approach because a .json file is easy to maintain and it's basically a text file so the file size is, in general, not a problem at all. Here's an usage example extracted from github: procedure TForm1.FormCreate(Sender: TObject); begin //The 'jsonResourceId' is the Identifier of the .json file that contains the //translated strings. It has to be loaded in the IDE as resource (RCDATA) Language1.setSource('jsonResourceId'); Language1.setLanguage('Default'); end; procedure TForm1.Button1Click(Sender: TObject); begin Language1.setLanguage('it'); //The caption is now 'casa' Label1.Caption := Language1.localize('home'); Language1.setLanguage('fr'); //The caption is now 'maison' Label1.Caption := Language1.localize('home'); end; Edited January 2, 2019 by Alberto Miola 1 Share this post Link to post
Sherlock 663 Posted January 3, 2019 So can the language be switched in the running application? Share this post Link to post
Guest Posted January 3, 2019 1 hour ago, Sherlock said: So can the language be switched in the running application? Well, of course you can call a method on an instance and assign values to controls properties at runtime. That is what you do with Language1.setLanguage('fr'); //The caption is now 'maison' Label1.Caption := Language1.localize('home'); What I would expect from an I8N framework is to handle this translation almost automatic (for the "static" parts of the forms/frames). Application.SetLanguage('en-us'); So that should be enough. Share this post Link to post
Sherlock 663 Posted January 3, 2019 Correct. Apparently I am still hung over and party mode wont shut off. Sorry about that. Share this post Link to post