mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-03 12:20:32 +02:00
Examples/Translations: Fix UTF8 in DefaultFormatSettings.
This commit is contained in:
parent
58ba82e9fe
commit
26494a14f9
@ -13,6 +13,7 @@ inherited Form2: TForm2
|
||||
Top = 16
|
||||
Width = 57
|
||||
Caption = 'LblTodayIs'
|
||||
Color = clDefault
|
||||
ParentColor = False
|
||||
end
|
||||
object LblMoney: TLabel[1]
|
||||
@ -21,6 +22,7 @@ inherited Form2: TForm2
|
||||
Top = 40
|
||||
Width = 53
|
||||
Caption = 'LblMoney'
|
||||
Color = clDefault
|
||||
ParentColor = False
|
||||
ParentFont = False
|
||||
end
|
||||
@ -93,6 +95,7 @@ inherited Form2: TForm2
|
||||
Width = 231
|
||||
AutoSize = False
|
||||
Caption = 'LblSum'
|
||||
Color = clDefault
|
||||
ParentColor = False
|
||||
end
|
||||
end
|
||||
|
@ -83,9 +83,9 @@ begin
|
||||
method here to get that label translated. }
|
||||
CalculateSum;
|
||||
|
||||
{ There is a complication for the labels LblTodayIs which displays the current
|
||||
date, and with LblMoney which displays some amount of money with the currency
|
||||
sign.
|
||||
{ In old versions there was a complication for the labels LblTodayIs which
|
||||
displays the current date, and with LblMoney which displays some amount of
|
||||
money with the currency sign.
|
||||
Formatting for these data is extracted from the DefaultFormatSettings.
|
||||
The resulting strings are encoded in ansi and do not display locale-specific
|
||||
characters. To get this right they have to be converted to UTF8.
|
||||
@ -94,16 +94,31 @@ begin
|
||||
typical code pages. Therefore, we use'll a more general procedure based on
|
||||
ConvertEncoding which allows to specify the source code page which had been
|
||||
determined when UpdateFormatSettings had been called in the LocalizedForms
|
||||
unit. }
|
||||
unit.
|
||||
|
||||
This has been changed since Laz 2.2.0. The old conversion code is left
|
||||
here commented for comparison.
|
||||
}
|
||||
s := FormatDateTime(DefaultFormatSettings.LongDateFormat, Date());
|
||||
{
|
||||
s := ConvertEncoding(
|
||||
FormatDateTime(DefaultFormatSettings.LongDateFormat, date), // string to convert
|
||||
FormatDateTime(DefaultFormatSettings.LongDateFormat, d), // string to convert
|
||||
CodePage, // source encoding as defined by "CodePage"
|
||||
EncodingUTF8 // destination encoding - UTF8
|
||||
);
|
||||
LblTodayIs.Caption := Format(rsTodayIs, [s]);
|
||||
}
|
||||
{ Note: "ConvertEncoding" requires the unit LConvEncoding in the uses clause. }
|
||||
LblTodayIs.Caption := Format(rsTodayIs, [s]);
|
||||
|
||||
s := DefaultFormatSettings.CurrencyString;
|
||||
|
||||
{ Now the same with LblMoney... }
|
||||
LblMoney.Caption := Format('%.*n %s', [
|
||||
DefaultFormatSettings.CurrencyDecimals,
|
||||
10.0e6,
|
||||
DefaultFormatSettings.CurrencyString
|
||||
]);
|
||||
{
|
||||
LblMoney.Caption := ConvertEncoding(
|
||||
Format('%.*n %s', [
|
||||
DefaultFormatSettings.CurrencyDecimals,
|
||||
@ -112,6 +127,7 @@ begin
|
||||
]),
|
||||
CodePage, EncodingUTF8
|
||||
);
|
||||
}
|
||||
|
||||
{ The items of TRadiogroup are not translated automatically. }
|
||||
with RadioGroup do begin
|
||||
|
Loading…
Reference in New Issue
Block a user