Solved

Multilingual part strings (or: string to variable)

Posted on 2002-03-28
7
158 Views
Last Modified: 2010-04-04
While trying to translate a project, I got the
following problem:

The message string s
  s:= 'The file ' + fname + ' does not exist';
  ShowMessage(s);
contains two constant strings ('The file ' and
 'does not exist');

The simple way would be to define string ressources or constants, which will be translated separately,
with this result:
  s:= Ressource[currentlanguage,_THE_FILE] + fname +    Ressource[currentlanguage,_DOES_NOT_EXIST];
  ShowMessage(s);

Now I'm looking for a more advanced way (and easier way for the translator) to solve the problem.

E.g. if one could write all parts together into text-files
(one for each language), and parse the language-dependend file, somehow like this:

Textfile:
 FILE_DOES_NOT_EXIST = "The file" + fname + " does not exist";

The constant strings could easily be parsed (e.g. into
a stringlist Parts) and put together.
The problem would be fname, which will be
read as a string, but would have to be converted
into a variable-name. So I would need conversion
from a string to the content of the corresponding
variable name.

s:= Parts[0] + GetVariableContent(Parts[1]) +
    Pars[2];
ShowMessage(s);

Is there any way to achieve this?

Thanks for help,

Gamba



















0
Comment
Question by:Gamba
  • 3
  • 3
7 Comments
 
LVL 14

Expert Comment

by:AvonWyss
ID: 6902215
Use Format().

s:= Format('The file %s does not exist',[fname]);

Format does also accept multiple parameters and allows to change their order. Therefore this makes it ideal for such tasks.
0
 

Author Comment

by:Gamba
ID: 6902287
No way to convert a string into a variable-name?
0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 6902368
Not for common variables, only for components. But trust me, you don't need this and it will work perfectly using Format()! That's what Format() is made for.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 3

Expert Comment

by:VSF
ID: 6903207
I think the best thing to do when creating multiple language app is to use Delphi's native support.
It comes with a wizard that turns to be a best!

Create a new project and click Project >Languages >Add Language on the Delphi main menu!

Hope it helps!

VSF
www.victory.hpg.com.br
www.boatoda.hpg.com.br  
0
 

Author Comment

by:Gamba
ID: 6903493
Ok, Format is a perfect possibilty to solve the
problem. Points for AvonWyss!

Thanks for all comments!

Gamba
0
 
LVL 14

Accepted Solution

by:
AvonWyss earned 100 total points
ID: 6909887
Gamba, in order to award me the points, you need to close the question. Thank you, and happy easter!
0
 

Author Comment

by:Gamba
ID: 6910513
Sorry, I tried to, but EE went offline meanwhile.

Gamba
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now