SiComponents Home Page SiComponents Forums
Here you will be able to get help and share your experience
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

resourcestring -> the official solution

 
Post new topic   Reply to topic    SiComponents Forums Forum Index -> TsiLang Components Suite
View previous topic :: View next topic  
Author Message
Pumper



Joined: 17 Feb 2011
Posts: 3

PostPosted: Thu Feb 17, 2011 4:40 pm    Post subject: resourcestring -> the official solution Reply with quote

Hi there,

I've read through all of the topic of resourcestring. It seems to me that using resourcestring or const is not the best way. I have a project what I want to translate to several languages. At this time all of MessageDlg's strings are in one separate unit in resourcestring or const section. Several times those uses same strings. I've decided to take the effort and one time refactor all of the codes what are necessary.

So, here is my question:

What is the best/official way to store these strings of all MessageDlg?

Thank you

Regards,
Pumper
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2096

PostPosted: Mon Feb 21, 2011 11:39 am    Post subject: Reply with quote

Hello,

If you've meant to translate the text message displayed in MessageDlg() functions, then (if you consider to reduce the size of translations and easier manintainance of the code) I would suggest to create one common unit which will define all the strings used in the dialogs (this even could be a datamodule in order to simplify the translation), like:
var
sGlobalMsg1: string = 'Some message';
sGlobalMsg2: string = 'Another message';

Then translate this unit using TsiLang Expert and just refer to all these global strings from other units. This will centralize all these strings as well as will skip duplicates as the same string could be reused.

Hope this helps.
Back to top
View user's profile Send private message
Pumper



Joined: 17 Feb 2011
Posts: 3

PostPosted: Tue Feb 22, 2011 11:11 am    Post subject: Reply with quote

Dear Isiticov,

Thank you for your help. I've tried to do as you described, but it seems something went wrong. Here is how my DM looks:

Code:
unit Unit_Forditas;

interface

uses
  SysUtils, Classes, Unit_DM, siComp, siLngLnk;

type
  TForditas = class(TDataModule)
    siLangLinked: TsiLangLinked;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Forditas: TForditas;

// Általános stringek
  rsT1ReXIndulVarj: String = 'Kérem várjon, a rendszer indítása folyamatban van...';
  rsAdatbazis: String = 'Adatbázis';

...

//Form_Stat_SzamlaJegyzek
  rsFStat_SzamlaJegyzek_PDFFileNev: String = 'SzamlakJegyzeke';
  rsFStat_SzamlaJegyzek_PDFCim: String = 'Számlák jegyzéke';
  rsFStat_SzamlaJegyzek_DatumSzures: String = 'Dátum szűrés: ';

implementation

{$R *.dfm}

end.


Unfortunately when I open the Translation Editor I can't find these strings in General Translations. None of them. Sad

Have I made something wrong? All of other forms are working properly.

Thank you.

Regards,
Pumper
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2096

PostPosted: Thu Feb 24, 2011 1:32 pm    Post subject: Reply with quote

Hello,

Source strings won't be picked up automatically into Tsilang. You will need to perform some additional steps.
Please use Tsilang Expert (Delphi menu Tools) and then in TsiLang Expert's menu please use File | Const section | With form.
This will scan the source of the unit and add the necessary code for translating the strings.
You can find detailed description of this in TsiLang Manual as well as at http://www.tsilang.com/press/en/how_to_make_multilingual_application.html (Step 4).
Hope this helps.
Back to top
View user's profile Send private message
Pumper



Joined: 17 Feb 2011
Posts: 3

PostPosted: Wed Mar 09, 2011 4:58 pm    Post subject: Reply with quote

Dear Igor,

Thank you for your answer. It is working as you described but I won't use because it makes me big mess in the source code.

I decided to use arrays in the string unit because it much cleaner. I have to change my source either ways. Like this:

Code:
unit Unit_Forditas;

interface

const
  NySz = 2; // Number of translations


  rsT1ReXIndulVarj: array [1..NySz] of string = (
    'Kérem várjon, a rendszer indítása folyamatban van...',
    'Please wait the system is starting up...');

  rsAdatbazis: array [1..NySz] of string = (
    'Adatbázis',
    'Database');
...


And the changes in the code:

Code:
if InputQuery(rsFReg_EmailCimModositas[siLangDispatcher.ActiveLanguage], rsFReg_EmailCimKerdes[siLangDispatcher.ActiveLanguage], S) then begin
...



Have a nice day
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SiComponents Forums Forum Index -> TsiLang Components Suite All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by p h p B B  © 2001, 2005 p h p B B  Group