Welcome, Guest
Username: Password: Remember me
Discussions for CodeTyphon Object Pascal Programming Language
  • Page:
  • 1

TOPIC:

How to translate library resource strings? 4 years 1 month ago #14276

  • Roman
  • Roman's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 87
  • Thank you received: 0
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.

How to translate library resource strings? 4 years 1 month ago #14277

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4502
  • Thank you received: 1096
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.

How to translate library resource strings? 4 years 1 month ago #14278

  • Roman
  • Roman's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 87
  • Thank you received: 0
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.

How to translate library resource strings? 4 years 1 month ago #14279

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4502
  • Thank you received: 1096
Your library must have
"Interfaces" to use LCLTranslator unit
PilotLogic Architect and Core Programmer

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

Last edit: by Sternas Stefanos.

How to translate library resource strings? 4 years 1 month ago #14280

  • Roman
  • Roman's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 87
  • Thank you received: 0

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.

How to translate library resource strings? 4 years 1 month ago #14281

  • fredvs
  • fredvs's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 205
  • Thank you received: 1
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.

How to translate library resource strings? 4 years 1 month ago #14282

  • Roman
  • Roman's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 87
  • Thank you received: 0

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

I agree. And what in this case to do?

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

Last edit: by Roman.

How to translate library resource strings? 4 years 1 month ago #14283

  • fredvs
  • fredvs's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 205
  • Thank you received: 1

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.

How to translate library resource strings? 4 years 1 month ago #14311

  • Roman
  • Roman's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 87
  • Thank you received: 0
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.

  • Page:
  • 1