[Pas2js] resourcestrings structure

warleyalex warleyalex at yahoo.com.br
Fri Aug 9 19:01:26 CEST 2019


DWscript translates resourcestring using another approach:
All resource strings get an index are stored in a global JS-side array named
"$R". Each time they are accessed, it is through a "$R[index]". This
approach have the pros and cons, it has less overhead but if if you wish to
switch language :(

---------------------------
{ filename: res.pas }

unit res;

uses Classes;

interface

resourcestring
  SInvalidFormat = '"Invalid format specifier : %s';
  SDuplicateName =  'Duplicate component name: %s';

implementation

end.

(...)
====================
begin
  console.log( SInvalidFormat );
  console.log( SDuplicateName );
end;
***************************************



JS output:

var $R =  
    ["Missing argument in format %s",
    "Invalid format specifier : %s",
    "Invalid argument index in format: %s",
    "List capacity (%s) exceeded.",
    "List count (%s) out of bounds.",
    "List index (%s) out of bounds",
    "Operation not allowed on sorted list",
    "String list does not allow duplicates",
    "Cannot use find on unsorted list",
    "Invalid component name: %s",
    "%s is not a valid boolean.",
    "Duplicate component name: %s",
    "Invalid date: %s",
    "Invalid time format: %s",
    "Invalid date format: %s",
    "Cannot read property %s",
    "Cannot write property %s",
    "Unknown property: %s",
    "Indexed property %s needs parameters",
    "Invalid class typecast",
    "Invalid integer value: %s",
    "Invalid floating-point value: %s",
    "Invalid date-time value: %s",
    "Invalid currency value: %s",
    "%d is not a valid day of the week",
    "Invalid date/timestamp : %s",
    "%d %d %d is not a valid dateweek",
    "Year %d does not have a day number %d",
    "Year %d, month %d, Week %d and day %d is not a valid date.",
    "Year %d Month %d NDow %d DOW %d is not a valid date",
    "%f Julian cannot be represented as a DateTime",
    "%d:%d:%d.%d is not a valid time specification",
    "%s is not a valid GUID value",
    "Illegal Nil stream for TReader constructor",
    "Invalid value for property",
    "Invalid stream format",
    "Unknown property: %s",
    "Unknown property type %d",
    "Ancestor class for %s not found.",
    "Unsupported property variant type %d",
    "Error reading %s%s%s: %s",
    "Invalid property path",
    "Property is read-only",
    "Class %s not found",
    "Illegal Nil stream for TWriter constructor",
    "Invalid property type from streamed property: %d",
    "Wrong token type: %s expected",
    "Invalid floating point number: %s",
    "Invalid integer number: %s",
    "Unterminated string",
    "Wrong token type: %s expected but %s found",
    "Wrong token symbol: %s expected but %s found",
    " (at %d,%d, stream offset %.8x)",
    "Unterminated byte value",
    "Invalid property",
    "Seek is not implemented for class %s",
    "Stream reading is not implemented for class %s",
    "Stream writing is not implemented for class %s",
    "Could not read data from stream",
    "Could not write data to stream",
    "Could not allocate memory",
    "Invalid Stream size"];

(...)
console.log( $R[1] ); // for the key SInvalidFormat
console.log( $R[11] ); // for the key SDuplicateName




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


More information about the Pas2js mailing list