Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Help: Change Language On Fly With Delphi, delphi 5-8
wojta
post Apr 20 2006, 03:56 PM
Post #1


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 23
Joined: 18-April 06
Member No.: 12,839



Hi guys, what is the best option for delphi if I want to change languages on fly in my applications?

thx

Wojta
Go to the top of the page
 
+Quote Post
Chesso
post Jun 8 2006, 03:54 AM
Post #2


Teh Coder
Group Icon

Group: Members
Posts: 1,053
Joined: 18-April 06
From: Australia
Member No.: 12,833



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=Exit
MyButton2=Open
etc...

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 www.delphipages.com/threads 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.
Go to the top of the page
 
+Quote Post
miCRoSCoPiC^eaRt...
post Jun 8 2006, 08:28 AM
Post #3


PsYcheDeLiC dR3aMeR
Group Icon

Group: Admin
Posts: 2,242
Joined: 29-January 05
From: Nakorn Chaisri, Thailand
Member No.: 2,411



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
Go to the top of the page
 
+Quote Post
Chesso
post Jun 8 2006, 12:21 PM
Post #4


Teh Coder
Group Icon

Group: Members
Posts: 1,053
Joined: 18-April 06
From: Australia
Member No.: 12,833



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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Resources For Beginner Delphi Programmer ?(11)
  2. Uploading File Using Delphi To A Php Upload Script(4)
  3. Can Delphi Be Used For Distributed Appz?(1)
  4. Keyboard Simulation(3)
  5. Delphi 6 And XP(2)
  6. Hide Delphi's Splash Screen - Delphi 6(0)


 



- Lo-Fi Version Time is now: 6th September 2008 - 05:55 AM