hedgewars/uLocale.pas
changeset 351 29bc9c36ad5f
parent 302 7aca131ecd7f
child 371 731ad6d27bd1
equal deleted inserted replaced
350:c3ccec3834e8 351:29bc9c36ad5f
    38 var s: shortstring;
    38 var s: shortstring;
    39     f: textfile;
    39     f: textfile;
    40     a, b, c: integer;
    40     a, b, c: integer;
    41 begin
    41 begin
    42 {$I-}
    42 {$I-}
    43 AssignFile(f, FileName);
    43 Assign(f, FileName);
    44 reset(f);
    44 reset(f);
    45 TryDo(IOResult = 0, 'Cannot load locale "' + FileName + '"', true);
    45 TryDo(IOResult = 0, 'Cannot load locale "' + FileName + '"', true);
    46 while not eof(f) do
    46 while not eof(f) do
    47       begin
    47       begin
    48       readln(f, s);
    48       readln(f, s);
    59       case a of
    59       case a of
    60            0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b)]:= s;
    60            0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b)]:= s;
    61            1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s;
    61            1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s;
    62            end;
    62            end;
    63       end;
    63       end;
    64 closefile(f)
    64 Close(f)
    65 {$I+}
    65 {$I+}
    66 end;
    66 end;
    67 
    67 
    68 function Format(fmt: shortstring; var arg: shortstring): shortstring;
    68 function Format(fmt: shortstring; var arg: shortstring): shortstring;
    69 var i: integer;
    69 var i: integer;
    70 begin
    70 begin
    71 i:= Pos('%1', fmt);
    71 i:= Pos('%1', fmt);
    72 if i = 0 then Result:= fmt
    72 if i = 0 then Format:= fmt
    73          else Result:= copy(fmt, 1, i - 1) + arg + Format(copy(fmt, i + 2, Length(fmt) - i - 1), arg)
    73          else Format:= copy(fmt, 1, i - 1) + arg + Format(copy(fmt, i + 2, Length(fmt) - i - 1), arg)
    74 end;
    74 end;
    75 
    75 
    76 end.
    76 end.