* * *

Author Topic: Is there a tool for testing a line (preview)  (Read 272 times)


  • New member
  • *
  • Posts: 40
Is there a tool for testing a line (preview)
« on: April 27, 2018, 04:10:48 pm »
I'm translating Lazarus to Turkish and need a solution for translation lines e.g. view them in action, if the line is a menu text on IDE maybe preview it? It's hard for me to understand the meaning of line without seeing where it is.

Say we have a line with text "Search" (I've come across with things similar to this earlier). This might mean:
* Do string search in source files
* Search a text within settings dialog
* Filter an option on IDE

Can anyone help me?


  • Hero Member
  • *****
  • Posts: 4472
Re: Is there a tool for testing a line (preview)
« Reply #1 on: April 27, 2018, 04:51:49 pm »
From my own translation projects I know that this is a severe issue. The only idea which comes to my mind is this:

I assume that you use poedit or a similar tool for translating. Right-click on the item which you want to translate and from which you want to know the context in which it is used. The context menu of poedit shows the unit and name of the resourcestring, e.g. 'lclstrconsts.rsascannothaveasparent' for the untranslated string "Class %s cannot have %s as parent". It is in unit lclstrconsts and named as "rsascannothaveasparent" -- see screenshot "poedit-contextmenu.png".

Then use the "Search" > "Find in files" command of Lazarus to search all units of Lazarus (or quicker, the lcl folder since lclstrconsts is in here) for the string "rsascannothaveasparent" -- see screenshot "findinfiles.png". In this case I get two occurances: one is the definition of the string in lclstrconsts itself, the other one is the source position where the string is used -- see screen shot "findinfiles-results.png". A click on the second item opens the source file in which the found item is used. Here it is:

Code: Pascal  [Select]
  1. procedure TCustomPage.CheckNewParent(AParent: TWinControl);
  2. begin
  3.   if (AParent<>nil) and (not (AParent is TCustomTabControl)) then
  4.     raise EInvalidOperation.CreateFmt(rsASCannotHaveAsParent, [ClassName,
  5.       AParent.ClassName]);
  6.   inherited CheckNewParent(AParent);
  7. end;

You see here that the string rsASCannotHaveAsParent gets the classnames of an object and its parent as parameters in the CreateFmt command (which internally calls Format()). I know this is not a good example, but I hope you get the idea.

This is a terribly tedious approach, but as a side-effect you get to know Lazarus and its units much better!

Please ask this question also on the Lazarus mailing list. Maxim Ganetsky who takes care of the translations maybe knows a better solution.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10


  • New member
  • *
  • Posts: 40
Re: Is there a tool for testing a line (preview)
« Reply #2 on: April 27, 2018, 05:19:57 pm »
Thanks for the reply, this makes sense. I'm going to try it.



Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus