Forum > Translations

Translate a String that is not a constant?

(1/2) > >>

MaxM74:
Is it possible to translate a string that isn't a constant?
Let me explain.
Using the WIA interface on Windows, it returns the item name of a Device, for example, Feeder.
Obviously, the string is NOT a constant but a variable.
If I put a string in resourcestring with the value 'Feeder' and the corresponding
Italian translation in the po file 'Caricatore', how can I get it translated?

I tried Format(theVariable, []) but it doesn't work.
Thanks.

Thaddy:
As far as I know that is not possible using po files. These rely on constants.

alpine:

--- Quote from: MaxM74 on July 28, 2025, 11:46:27 am ---Is it possible to translate a string that isn't a constant?
Let me explain.
Using the WIA interface on Windows, it returns the item name of a Device, for example, Feeder.
Obviously, the string is NOT a constant but a variable.
If I put a string in resourcestring with the value 'Feeder' and the corresponding
Italian translation in the po file 'Caricatore', how can I get it translated?

--- End quote ---

I believe you can use the TPOFile class from the Translations unit.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- POF := TPOFile.Create('translation.it.po'); //... Translated := POF.Translate('wia.device.feeder', 'Feeder');
You'll probably have to play around a bit.

Thaddy:
That won't solve it, because the pdf? That is not a constant.

jcmontherock:
You have to set the I18n parm in the project options. The resources strings are automatically included in pot and po files and translated at execution time.

Navigation

[0] Message Index

[#] Next page

Go to full version