Generate RES (stringtable) file from a resourcestring Unit

Asked

Viewed 696 times

1

I’m studying some sources of how to internationalize the software, and in the example I have the software has a Unit with constant strings (captions, etc), something like:

unit Resources;
interface
resourcestring
  CompanyName = '***';
implementation
end.

And another one with the Ids for each string to then call via:

System.SysUtils{$ELSE}SysUtils{$ENDIF}.LoadStr(ID)

The project has an RES file, something like Strconsts.res, which he calls in the program directive:

{$R StrConsts.res}

res has only one Stringtable, with all the Ids and the referring strings, what I wanted to know is how to generate the res file from Unit resourcestring.

3 answers

0

Old question, but I made a small software to facilitate the process of creating *.resfiles. If it is still useful to someone, the link to the project is this: Resmaker

Below, prints of software windows:

Main Window Janela Principal

Settings window Janela Configurações

0

The best way to do this I discovered was by looking at the Fastreports components. Basically they use two Units:

1) frxrcClass.pas = Unit containing subtitles.

2) frxRes.pas = Unit with subtitle swap functions.

In each form or Unit you declare "uses frxClass, frxRes" and can call the Get function to swap each desired label.

Take a look, if you are interested, you can rewrite the functions for your use. I hope I’ve helped!!!

  • i understood what you wrote, but I’m wondering how to generate the RES file.

0


To create a file type . res follow the steps below:

1) Create and save a text file with extension ". rc" with the information you want. Example: test.rc

2) At the DOS command prompt, run the following command BRCC32 test.rc

Note: The BRCC32 file is available in the Delphi bin directory.

  • In this case what information would I put in the file . rc? I did not want to write the STRINGTABLE, but generate from the unite with the resourcestring.

  • You choose what information you want to place. If you want to create a file (.res) for languages, you should put variables with the original label, for example: label1=Name; label2=Address.... or put generics that will be identified, such as: lblNome=Name, lblEndereco=Address.... I particularly recommend not creating file. res for languages, because it makes it difficult for the user to change subtitles. In this case, any text file is better for the user because it can edit by any text editor.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.