Recent

Author Topic: Example project for translation  (Read 29368 times)

CM630

  • Hero Member
  • *****
  • Posts: 1732
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Example project for translation
« Reply #30 on: December 20, 2013, 01:50:06 pm »
In some languages the sentences might vary, depending on the number of an item.
A simple example: 1 file found and 5 files found found.
If I am not wrong in Russian, for numbers ending on 1;2;3 and 4 there is one suffix for file , and for the other numbers the suffix is different. The main advantage of PO is exactly handling this item.
 So here is what happens:
I added ezFilesFound = '%d files found'; I expected that in the PO file there should be added the necessary info, so I would have several strings corresponding to ezFilesFound. Instead I have one string only.
What shall I do to have the plural forms okay? Is this supported by Lazarus?

Also, there is another issue.
Running an app with the --lang bg or --lang ru has no effect for me- applications keep running in English. The PO files are generated (almost) properly, PO Edit validates the files okay. What could
Then I tried another Lazarus app- Double Commander the following way: doublecmd.exe --lang de . Still no effect.  The interface did not run in German.
What could I have done wrong?
« Last Edit: December 20, 2013, 01:56:25 pm by paskal »
Лазар 4,8 32 bit (sometimes 64 bit); FPC3,2,2

wp

  • Hero Member
  • *****
  • Posts: 13625
Re: Example project for translation
« Reply #31 on: December 20, 2013, 05:43:23 pm »
(1) Plural: As far as I know poedit can handle plural forms, even several plurals as you mention for Russian. I never tried it myself, though. I also don't know how to invoke that feature in the Lazarus code. Google for "poedit plural". If you find out please let us know.

(2) Failure to respect "--lang xx": DefaultTranslator provides the infrastructure, but the program, of course, has to consider that. The demo program in this thread, for example, overrides  (i.e. ignores)  that commandline selection by explicitly calling SetDefaultLang('en') in the OnCreate event of the main form. If that feature is activated in your form use the debugger and step through DefaultTranslator.pas - I've seen a few feature that were not working as I had expected.

hovadur

  • Newbie
  • Posts: 5
Re: Example project for translation
« Reply #32 on: December 21, 2013, 01:04:33 pm »
To make it clear: to have LCL strings translated you copy lclstrconsts.*.po to your languages folder, and then you can modify them in any way you want - LCL translations are completely coupled off of Lazarus.
Can you write it in top comment of main form?

CM630

  • Hero Member
  • *****
  • Posts: 1732
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Example project for translation
« Reply #33 on: January 06, 2014, 02:16:57 pm »
You have a lot of flexibility with MessageDlg.  This code shows how to add some things but it's just garbage to show how to do it.
...
Maybe I should mention a problem with your code, causeing buttons to overlap. I fixed it the following way:
Code: [Select]
  for i:= 0 to RtlMessageDlg.ControlCount-1 do
     begin
       RtlMessageDlg.Controls[i].AutoSize:= True;
       RtlMessageDlg.Controls[i].BiDiMode:= bdRightToLeft;
       TBitBtn(RtlMessageDlg.Controls[i]).Glyph:= Nil;  // Get rid of delphi-like icons
     end;

  RtlMessageDlg.Show;
  for i:=1 to RtlMessageDlg.ControlCount-1 do
     RtlMessageDlg.Controls[i].Left:=RtlMessageDlg.Controls[i-1].Left+RtlMessageDlg.Controls[i-1].Width+2 ;
  RtlMessageDlg.Hide;
 

 RtlMessageDlg.Show; must be used, because otherwise Lazarus cannot calculate the real widths of the controls. If someone knows a better way, please let me know.
Лазар 4,8 32 bit (sometimes 64 bit); FPC3,2,2

CM630

  • Hero Member
  • *****
  • Posts: 1732
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Example project for translation
« Reply #34 on: January 08, 2014, 08:49:38 am »
There is another issue. I have several buttons placed vertically, and I want them to have the same width in a language. I mean, I do not mind if they become wider, but all buttons in a a column (same vertical position) shall have an equal width.
If I set all the buttons to autosize, they will have different widths (like in columns 1, counting from 0). If I do not, there might not be enough space for the text (like in column 0, row 1).
Also, if I have the buttons autosized, then I will have to anchor each button to a button from the same row (normally I would anchor horizontally to the  topmost button of the preceding row).
The only solution I can think of is to use autoresize, after all buttons get autoresized to find the width of the widest control in the column, to disable autoresize and to set the width properties of all the buttons in the column. Then I will have to set the .Left property of all controls in the next column according the width of the previous one... etc.
Could there be a simpler solution?
« Last Edit: January 08, 2014, 08:51:44 am by paskal »
Лазар 4,8 32 bit (sometimes 64 bit); FPC3,2,2

wp

  • Hero Member
  • *****
  • Posts: 13625
Re: Example project for translation
« Reply #35 on: January 08, 2014, 09:20:44 am »
Too strict layouts are always an issue, in Windows for example if you go to a PC running at 120 dpi instead of the usual 96 dpi.

I'd use two left-aligned panels for the two button groups. Add the controls top-aligned and provide sufficient border around the controls to get the spacing that you want. Then, after changing language, iterate through the buttons on each panel and determine the longest button caption (Canvas.TextWidth). Set the width of the owning panel to that textwidth plus the borders around the button plus some pixels for spacing between caption and button border.

CM630

  • Hero Member
  • *****
  • Posts: 1732
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Example project for translation
« Reply #36 on: January 08, 2014, 01:55:03 pm »
That's not much different from my idea, so I guess no one did anything ready like anchoring). I'll try to make an example and put it in the wiki.
Лазар 4,8 32 bit (sometimes 64 bit); FPC3,2,2

CM630

  • Hero Member
  • *****
  • Posts: 1732
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Example project for translation
« Reply #37 on: May 12, 2014, 08:44:00 am »
Just to mention that there is a very serious bug in the Lazarus PO file support.
When a string is flagged as fuzzy the original value shall be displayed, instead of the translated one, but Lazarus apps show „translated“ values.
When I happen to find time for that I will check if it is the bugzilla, unless someone does it before me.
Лазар 4,8 32 bit (sometimes 64 bit); FPC3,2,2

sapper

  • New Member
  • *
  • Posts: 35
Re: Example project for translation
« Reply #38 on: May 18, 2014, 11:23:22 am »
To make it clear: to have LCL strings translated you copy lclstrconsts.*.po to your languages folder, and then you can modify them in any way you want - LCL translations are completely coupled off of Lazarus.

Unfortunately, there's a lot of common dialogs where strings are defined by the OS and cannot be changed that easily...

Can you release a demo project for this. I have no success with this.

I added an OpenDialog to the form and a button to execute it.

I have copied lclstrconsts.de.po to the languages folder but opening the dialog with Deutsch selected the dialog caption is still English.

If I run the project with parameter --lang de and open the dialog it has German caption but buttons "OK" and "Cancel" so I assume "OK" and "Cancel" do not change.

wp

  • Hero Member
  • *****
  • Posts: 13625
Re: Example project for translation
« Reply #39 on: May 18, 2014, 05:18:17 pm »
Quote
Unfortunately, there's a lot of common dialogs where strings are defined by the OS and cannot be changed that easily...
The same here. The problem is that the FileOpenDialog calls Windows resources which cannot be reached by the method presented here.

Back in my Delphi days, I knew of Windows-only versions of the FileDialog where the strings could be replaced at run-time. Unfortunately, I don't find the links any more (www.torry.net?) ... So, if Windows-only is an aption, you'll have to spend some time with Google.

 

TinyPortal © 2005-2018