[Lazarus] Improving IDE Internationalization

Marcelo Borges de Paula marcbp at terra.com.br
Fri Jan 1 19:18:44 CET 2010

Happy new year to everyone.

   I´m having some troubles when using other compiler messages files to compile Lazarus or 
when using fpc compiled with other message file language than english.
   The fact is that Lazarus IDE has some pieces of code with embedded strings constants. 
   I thought the most common way to solve problems like this was to declare an identifier to it and
moving it to resourcestring header (or file, i.e. LazarusIDEstrconsts)

*** The question is : What should be moved or not moved there ???? ***

Other situation occurs with constant string in logic, like this example from msgview.pp

procedure TMessagesView.MessageViewDrawItem(Sender: TCustomTreeView;
  Node: TTreeNode; State: TCustomDrawState; Stage: TCustomDrawStage;
  var PaintImages, DefaultDraw: Boolean);
  TheText: string;
  ARect: TRect;

->  cHint         = 'Hint: User defined:';
->  cNote         = 'Note: User defined:';
->  cWarning      = 'Warning: User defined:';
  clMsgHint     = clBlue;
  clMsgNote     = clGreen;
  clMsgWarning  = clRed;
  cLeftSpacer   = 0;
  procedure ChangeFontColor(c: TColor);
[-] ...
  if Stage<>cdPostPaint then exit;
  // a paint means, something has changed (scrolling, expand, collapse, resize, ...)

  //DebugLn(['TMessagesView.MessageViewDrawItem Index=',Node.Index,' Count=',MessageTreeView.Items.Count,' TheText="',TheText,'"']);

  { Only use custom colors if not selected, otherwise it is difficult to read }
  if not (cdsSelected in State)
  then begin
->    TheText := Node.Text;
->    if Pos(cNote, TheText) > 0 then
->      ChangeFontColor(clMsgNote)
->    else if Pos(cHint, TheText) > 0 then
->      ChangeFontColor(clMsgHint)
->    else if Pos(cWarning, TheText) > 0 then
->      ChangeFontColor(clMsgWarning);

   If i use other language the code above will not work, since messages are translated.

   I´m trying to figure how to solve this one, but before start sending patches maybe should be wise to
hear what others have to say.
   Maybe we get some guidelines on how to proceed in such situations.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20100101/27d4578b/attachment-0003.html>

More information about the Lazarus mailing list