Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-07

Localized version of my application

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Csányi Pál

Hello!

I have installed Lazarus Version #: 0.9.25 beta Date: 2008-06-18 and FPC Version: 2.2.0 SVN Revision: 15441M i386-linux-gtk 2 (beta).

I made a small project with Lazarus with one Frame, Buttons, Labels and StaticTexts. All these elements have English text as Caption.

I wish to localize this application to Hungarian language.

Following the

http://wiki.lazarus.freepascal.org/Translations_/_i18n_/\ _localizations_for_programs

tutorial I have now the project.po, project.mo, project.hu.po, project.hu.mo files.

In this project I have source files: project.lpr and projectunit1.pas.

project.lpr uses unit projectunit1.pas.

I put the code that should to call TranslateUnitResourceStrings of the LCL translations unit in the project.lpr file:

------------>
program projectunit1;
{$mode objfpc}{$H+}

uses

  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Interfaces, // this includes the LCL widgetset
  Forms
  { you can add units after this }, projectunit1,
  gettext, translations;
{$IFDEF WINDOWS}{$R projectunit1}{$ENDIF}
var
  PODirectory, Lang, FallbackLang: String;
begin
  Application.Title:='project';
  Application.Initialize;
    Lang := '';
    FallbackLang := '';
    PODirectory := 'locales/';
    //projectdirectory/locales/
    GetLanguageIDs(Lang, FallbackLang); // in unit gettext
    TranslateUnitResourceStrings('project', PODirectory +
     'project.%s.po', Lang, FallbackLang);
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
------------<

This dosn't works.

Localization is not so simple as I think?

Please give me some advice what should I do now to get localized my application?

I tried to add a Breakpoint after

GetLanguageIDs(Lang, FallbackLang); // in unit gettext

line to see wether Lang and FallbackLang variables get some values, but I don't know where to find this values after the run of the project stop at this point?

Any advice will be appreciated!

Reply by email

Mattias Gaertner
to Csányi Pál
Show quoted text 76 lines
Hello! I have installed Lazarus Version #: 0.9.25 beta Date: 2008-06-18 and FPC Version: 2.2.0 SVN Revision: 15441M i386-linux-gtk 2 (beta). I made a small project with Lazarus with one Frame, Buttons, Labels and StaticTexts. All these elements have English text as Caption. I wish to localize this application to Hungarian language. Following the http://wiki.lazarus.freepascal.org/Translations_/_i18n_/\ _localizations_for_programs tutorial I have now the project.po, project.mo, project.hu.po, project.hu.mo files. In this project I have source files: project.lpr and projectunit1.pas. project.lpr uses unit projectunit1.pas. I put the code that should to call TranslateUnitResourceStrings of the LCL translations unit in the project.lpr file: ------------> program projectunit1; {$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} Interfaces, // this includes the LCL widgetset Forms { you can add units after this }, projectunit1, gettext, translations; {$IFDEF WINDOWS}{$R projectunit1}{$ENDIF} var PODirectory, Lang, FallbackLang: String; begin Application.Title:='project'; Application.Initialize; Lang := ''; FallbackLang := ''; PODirectory := 'locales/'; //projectdirectory/locales/ GetLanguageIDs(Lang, FallbackLang); // in unit gettext TranslateUnitResourceStrings('project', PODirectory + 'project.%s.po', Lang, FallbackLang); Application.CreateForm(TForm1, Form1); Application.Run; end. ------------< This dosn't works. Localization is not so simple as I think? Please give me some advice what should I do now to get localized my application? I tried to add a Breakpoint after GetLanguageIDs(Lang, FallbackLang); // in unit gettext line to see wether Lang and FallbackLang variables get some values, but I don't know where to find this values after the run of the project stop at this point? Any advice will be appreciated!

Some work has been done on automatic storing the forms strings into .po files and reading them back again. But there are many things left to do. That's why there is only a simple unit (lcl/defaulttranslator.pas) to load the strings. And this comes without documentation and has several limitations.

Maybe it's better to use ResourceStrings.

Mattias

Reply by email

Csányi Pál
to Mattias Gaertner
Mattias Gaertner wrote 17 lines
On Sun, 06 Jul 2008 16:11:48 +0200 (Csányi Pál) wrote: > I wish to localize this application to Hungarian language. > tutorial I have now the project.po, project.mo, project.hu.po, > project.hu.mo files. > > In this project I have source files: project.lpr and > projectunit1.pas. > > project.lpr uses unit projectunit1.pas. > > I put the code that should to call TranslateUnitResourceStrings of the > LCL translations unit in the project.lpr file: > > ------------> > program project;

...

Show quoted text 27 lines
> var > PODirectory, Lang, FallbackLang: String; > > begin > Application.Title:='project'; > Application.Initialize; > Lang := ''; > FallbackLang := ''; > PODirectory := 'locales/'; > //projectdirectory/locales/ > GetLanguageIDs(Lang, FallbackLang); // in unit gettext > TranslateUnitResourceStrings('project', PODirectory + > 'project.%s.po', Lang, FallbackLang); > Application.CreateForm(TForm1, Form1); > Application.Run; > end. > ------------< > > This dosn't works. Some work has been done on automatic storing the forms strings into .po files and reading them back again. But there are many things left to do. That's why there is only a simple unit (lcl/defaulttranslator.pas) to load the strings. And this comes without documentation and has several limitations. Maybe it's better to use ResourceStrings.

Maybe yes but I have a cue to try out DefaultTranslator in my code.

I'm reading now the lcl/defaulttranslator.pas. I like it. :)

I'm a novice in the freepascal and object pascal so I don't know how to call DefaultTranslator?

If you think that that for me it's worth to try it out, then you could, if you want, or have a time, to give to me advices how to use it. Want you?

Reply by email