Jump to content
xisto Community
wojta

Help: Change Language On Fly With Delphi delphi 5-8

Recommended Posts

Can't believe I missed this post sorry.Ummm if you mean like the language your'e button captions etc are in I would suggest using simple text files with all the text for your application that you load on application start and can simply change in a function if users want to load another language for the interface.Let's say English is the default and in your Languages directory you have a file called English.txt, if you have an option available to use say Chinese you would simply have a file called Chinese.txt that your program reads in and changes all the button captions etc to reflect this.Remember well though that this could pose a problem if text in English already takes up most of a controls width space as some words in other languages are fairly larger.As for the text file structure for the languages you could either have everything in certain order or just have identification such as:MyButton1=ExitMyButton2=Openetc...When reading in would simply check the left N characters of the line and check to see if it's for example MyButton1= so you know exactly what it is for if it does find it, then use the AnsiMidStr function to grab the text from = onwards.Hope this helps.P.S. Additionally you could visit http://forums.xisto.com/no_longer_exists/and make a post there, there is tons of experts who could help you with this and i'm sure could recomment some nice components that could make this easier for you if that's what you want.

Share this post


Link to post
Share on other sites

Isn't there any pre-defined class in Delphi that defines the CurrentLocale and CurrentCulture ?? If you have them - then surely the tools to switch language are built in too.

 

In any case, you'd have to create a text file as Chesso pointed out - similar copy of the same file for each language you wish to include in your package. Thing is - if those classes are prebuilt - then you don't need to look for MyButton= manually.. rather the word MyButton in the textfile will act as a variable and the compiler will do the job of finding it in the text file for you. You simply call it as MyButton and the associated text will be returned.

 

The same can be done in .NET - I'd written an article on this quite sometime back..

 

It can be found here: VB.NET: Switch Regional Language Automatically

Share this post


Link to post
Share on other sites

Delphi has built in support for building a multi lingual application but iv'e never used it to be honest so I'm really not sure on how it works and whether it's the right thing but it might be worth a try.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.