[Pas2js] i18n

warleyalex warleyalex at yahoo.com.br
Sun Oct 28 23:03:58 CET 2018


The main point of resourcestring is to allow i18n (internationalization) of
your program.

a) If you'll have to access many times to a resourcestring content, for
instance:

ResourceString
  DuplicateMsg   = 'An item with key %0:s already exists';

with pas2js:
=============
WriteLn( TranslateRS(DuplicateMsg, ['123456789']) );  

will output this string "An item with key 123456789 already exists"

------
In my experiement, I think it's nice to have Translate function as
alternative in pas2js:

TempMessage := Translate('ERR_DATETIME_INVALID',
    [Translate('ERR_DATETIME_TIME'), TimeToStr(now)]);

WriteLn(TempMessage);
WriteLn( DataTypeToStr(dtBoolean) );
WriteLn( Translate('ERR_CMP_DESTROY', ['button1']) );
WriteLn( Translate('APP_LOAD_MESSAGE', ['the main screen']) );
WriteLn( TranslateRS(DuplicateMsg, ['123456789']) );
WriteLn( Translate('DuplicateMsg', ['1234']) );
WriteLn( TJSJSON.stringify(EDuplicate.CreateFmt(DuplicateMsg, ['123'])) );

PREVIEW: https://pas2js.github.io/master/projTranslate/index.html






--
Sent from: http://pas2js.38893.n8.nabble.com/


More information about the Pas2js mailing list