Forum
× Discussions for CodeTyphon Object Pascal Programming Language

Question How to translate library resource strings?

  • Roman
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
2 months 2 weeks ago #14276 by Roman
I am creating a library (simplified example):
library my_library;

uses LCLTranslator;

resourcestring
  LibraryDescription = 'My test library';

function GetLibDesc : string; cdecl; export;
begin
  Result := LibraryDescription;
end;

exports
  GetLibDesc;

initialization
  // How to do translate resourcestring to 'ru' ?!
  SetDefaultLang(''); // no effect!
end.
I can’t understand how to use LCLTranslator.SetDefaultLang (or any other???) so that my function returns a description in the default OS language? my_library.ru.po-file created and placed in the same directory as the library.

Need help!!!

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
2 months 2 weeks ago #14277 by Sternas Stefanos
Replied by Sternas Stefanos on topic How to translate library resource strings?
Did you look the source of
codetyphon\CodeOcean\aa_LCLBasics\samples\multilang\multilang.ctpr
?

PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

  • Roman
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
2 months 2 weeks ago #14278 by Roman
Replied by Roman on topic How to translate library resource strings?
My project do not include any Forms, LCLTranslator generate many compilator errors like "Undefined symbol WSRegisterxxxxxxxx ..."

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
2 months 2 weeks ago - 2 months 2 weeks ago #14279 by Sternas Stefanos
Replied by Sternas Stefanos on topic How to translate library resource strings?
Your library must have
"Interfaces" to use LCLTranslator unit

PilotLogic Architect and Core Programmer
Last edit: 2 months 2 weeks ago by Sternas Stefanos.

Please Log in or Create an account to join the conversation.

  • Roman
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
2 months 2 weeks ago #14280 by Roman
Replied by Roman on topic How to translate library resource strings?

Sternas Stefanos wrote: Your library must have
"Interfaces" to use LCLTranslator unit

This does not help: DLL is not processed, resourcestrings are not translated.

Please Log in or Create an account to join the conversation.

More
2 months 2 weeks ago #14281 by fredvs
Replied by fredvs on topic How to translate library resource strings?
Hello.

Imho, LCL is not suited for libraries.
It has to much dependencies.

Fre;D

Please Log in or Create an account to join the conversation.

  • Roman
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
2 months 2 weeks ago - 2 months 2 weeks ago #14282 by Roman
Replied by Roman on topic How to translate library resource strings?

fredvs wrote: Imho, LCL is not suited for libraries.
It has to much dependencies.

I agree. And what in this case to do?
Last edit: 2 months 2 weeks ago by Roman.

Please Log in or Create an account to join the conversation.

More
2 months 2 weeks ago #14283 by fredvs
Replied by fredvs on topic How to translate library resource strings?

Roman wrote:

fredvs wrote: Imho, LCL is not suited for libraries.
It has to much dependencies.

I agree. And what in this case to do?


Try to use only units with less dependencies.
What do you want to achieve?

If you want to work with po files, you only need text-stuff dependencies.

I did not check yet LCLTranslator unit but maybe you can use some methods from it in your library code, without the need to link to all LCL stuffs.

Fre;D
The following user(s) said Thank You: Roman

Please Log in or Create an account to join the conversation.

  • Roman
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
2 months 1 week ago #14311 by Roman
Replied by Roman on topic How to translate library resource strings?
I solved my problem like this:
var
  S : string;

initialization
  S := GetModuleName(hInstance);
  S := ExtractFilePath(S) + 'lang\' + ChangeFileExt(ExtractFileName(S),'.%s.mo');
  TranslateResourceStrings(S);

Maybe this is a stupid solution, but it works :whistle:

Please Log in or Create an account to join the conversation.