Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Multilingual part strings (or: string to variable)

Posted on 2002-03-28
Medium Priority
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';
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];

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:

 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]) +

Is there any way to achieve this?

Thanks for help,


Question by:Gamba
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 14

Expert Comment

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.

Author Comment

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

Expert Comment

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.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

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!


Author Comment

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

Thanks for all comments!

LVL 14

Accepted Solution

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

Author Comment

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


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA:…
Suggested Courses

705 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