Build 305 – Delphi localization improvement (for project without included DRC file)

We always highly recommend using of DRC file in Sisulizer project for Delphi source files (exe, dll etc.). Why? When Delphi compiler compiles a resource string it stores the string as a standard Windows string resource and assigns an ID for the string. Sisulizer uses these IDs as context items.  If you add new resource strings into the application or delete existing ones, the compiler will give most resource strings new IDs. This will most likely cause a situation that you want to avoid, that is, losing of existing translations or replacing these translations with wrong translations. To prevent this you can generate DRC file in Delphi and use it your Sisulizer project. Delphi resource string file (.drc) file allows you to use in Sisulizer  resource string names linked to IDs (e.g. SSampleString equals 4567). The resource string name won’t change unless you intentionally change it. This makes resource string name much better context value as resource string ID. If your generated DRC file is located in this same directory as localized source file e.g. EXE or DLL, Sisulizer automatically detects it and uses it in created project. If Sisulizer can’t detect DRC file, it displays a warning message about this, but don’t worry you can later manually add path to DRC file via “Project” menu -> “Edit source” -> your Delphi source -> “Project” tab -> “DRC file name” field.

Using DRC file in Delphi localization

Sometimes, you haven’t access to DRC file, for example when developer provides you only binary EXE or DLL file(s), but of course, you can localize with Sisulizer a Delphi binary file without specifying the DRC file. In that case Sisulizer to build 305 had used always the resource string IDs as the context. Unfortunately, Delphi after changes in source code changed also these IDs in compiled binary files, and it caused losing of existing translations or replacing these translations with wrong translations. So, we recommended using of this solution only in the rare case, when you don’t plan to update your Delphi files in future. However, from build 305 you can choose method of context assigning for projects without DRC file. Available are two options:

  • String value – Sisulizer uses string values as context values. This is safe even if you modify and recompile your application. However if the application has the same text in two or more resource strings this method brings only one row to the project file. So all instances of the same text will share the same row and you can no longer translate them in a different way. This is default option for new projects.
  • Resource id – Sisulizer uses resource ids as context values. This is potentially dangerous because it is very likely that Delphi compiler will change the resource strings ids next time you compile your project. This will cause lost of translations or switching of existing translations. Please keep in mind that by mixing up translations, text may be longer than your application expect. Both are very hard to fix.

These settings are available via “Project” tab of Delphi source properties, but only when not specified DRC file (when DRC file is specified these options are invisible). You can check it in easy way with our Delphi example. Open our Converter.slp in Sisulizer 2010\VCL\Delphi\Converter folder in Sisulizer data folder (vista, Windows 7) or in Sisulizer installation directory. Open source properties, go to “Project” tab and clear path in “DRC file name” field.

Localizing without drc

Hints

  1. If you want to create a DRC file in Delphi choose “Project” -> “Options” -> “Delphi Compiler” -> “Linking” and set “Map file” to “Detailed”. Whenever you recompile your project Delphi will create a new DRC file that contains updated resource string names and IDs.
    Delphi localization options
  2. Here you can download PDF document about Delhi localization issues written by our CTO. Because described above features were implemented recently, so document doesn’t contain above information. However, I highly recommend to read it.

Janusz

Leave a Reply