Forum > LCL

Internationalization in Custom Controls

(1/1)

kupferstecher:
Hello all,

I made a multi language application using the LCL's i18n capabilities. For LCL controls (TButton, TLabel etc.) and ResourceStrings this works fine.
For custom controls, e.g. a button based on TCustomControl, currently I do the translations using a ResourceString and assigning the captions "manually" for each button which is quite some effort. I'd like to implement the i18n capabilities in the control.

So my question is, how to implement a string property in a custom control to be 'i18n'-sensitive? I.e. to be listed in the po-file by Lazarus and to be translated automatically by the LCLTranslator.

A web and forum search didn't bring me further.

Regards~

wp:
A rough guess: Declare the string as TTranslateString?

taazz:
published properties?

kupferstecher:
It works  :)

Thanks for both your answers!

The string has to be declared as TTranslateString as public property. After (!) the package is installed in Lazarus the translation works like on any other Control.


--- 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";}};} ---type TFancyButton = class(TCustomControl)  ...  protected    fButtonCaption: TTranslateString;    procedure SetButtonCaption(ACaption: TTranslateString);  published    property Caption : TTranslateString read fButtonCaption write SetButtonCaption;
EDIT: Added in the Wiki.
http://wiki.freepascal.org/Everything_else_about_translations#Control_design_with_internationalization_capability

Navigation

[0] Message Index

Go to full version