Forum > Translations

Translating resource strings from FCL units

(1/3) > >>

prof7bit:
I am currently in the process of making use of the i18n features to have my little application speak more that only one language and so far the experience has been great (it is actually orders of magnitudes simpler than many of the older howtos suggest, it's actually just one Entry in uses and everything begins to work like magic).

My Application includes a parser for a simple DSL and it this parser will in turn use TFPExpressionParser to parse numerical expressions with variables.

Now I have translated all my own parsing error messages, but occasionally I also must output errors that are coming straight out of TFPExpressionParser.

Luckily TFPExpressionParser is defining a section of resourcestrings with its own error messages, so I can theoretically translate these 40 or so strings also.

Question:
What is the best way to convince lazarus to include the strings from this unit in the .pot file? Currently the only way I have found is to add this file to the project in the project inspector, but then it will have its full path to the fpc source directory on my PC. It works, strings appear in the .pot and can be translated, but I don't like to have to specify a path to the fpc sources on my machine. There should be a way to add this as part of the FCL requirement.

The FCL is added to my project as a requirement, but obviously I don't want to translate the entire FCL, so it won't include them by default, so there should be some other way to mark a specific file for inclusion in the translation.

Would this be a reasonable feature request or am I missing some other way to do what I want?

wp:
For example, to include translated LCL strings in my project, I simply copy the translated .po files to my project languages directory. I guess that this should be working with FCL translation files in the same way.

Be careful with FPExpressionParser in a multi-language project because it will not accept the FormatSettings of the destination language - it insists on the point as decimal separator; I had posted a patch to fix this but it was rejected.

prof7bit:

--- Quote from: wp on September 16, 2021, 11:58:53 am ---Be careful with FPExpressionParser in a multi-language project because it will not accept the FormatSettings of the destination language - it insists on the point as decimal separator; I had posted a patch to fix this but it was rejected.

--- End quote ---

This is actually an advantage for me. I'm using it to parse a simple imperative script language to control a potting glue dispense machine. The expressios in this script should actually be language agnostic, it should still be able to parse the same existing scipts after I switch the language from English to German. I only want the error messages translated.


--- Quote from: wp on September 16, 2021, 11:58:53 am ---For example, to include translated LCL strings in my project, I simply copy the translated .po files to my project languages directory. I guess that this should be working with FCL translation files in the same way.

--- End quote ---
I'm going to try this.

But just copying a few files over won't work or would it? Lazarus generates only one big .pot file for all strings, regardless which unit they came from, so I would have to copy-paste the translated lines into my own .po file. Or just remove the entry in my project inspector again after I have translated it myself, it would not delete the existing entries in the po files, or woudl it? Going to try this next

Edit:
No, it will remove the entries, not only from the .pot but also from the .po files.

prof7bit:

--- Quote from: wp on September 16, 2021, 11:58:53 am ---I guess that this should be working with FCL translation files in the same way.

--- End quote ---

It turns out that such a thing as translated FCL translation files do not yet exist, so I have to get them translated by myself anyways.

prof7bit:
If I put them into a separate file and call TranslateResourceStrings() with that file it will translate these strings but then all other strings in my application which would normally be automatically translated by DefaultTranslator will become untranslated again.

It seems I can only use one translation file at a time, and it must be named after my application executable name.

Edit: I need to use TranslateUnitResourceStrings() and call it with the unit name, then it will translate the strings from this unit and leave everything else untouched.

Navigation

[0] Message Index

[#] Next page

Go to full version