Recent

Author Topic: Monthname not correctly localized  (Read 3238 times)

wp

  • Hero Member
  • *****
  • Posts: 13270
Monthname not correctly localized
« on: February 11, 2013, 10:09:33 pm »
I am using Lazarus under a German Win32. When I convert a date in March to a string I do not get the correct localized string für March ("M?rz" instead of "März"). See screenshot of the output of the following code

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var
  d: TDate;
  s: String;
begin
  d := EncodeDate(2000,3,1);
  s := DateToStr(d) + #13 +
       FormatDateTime('DD MMMM YYYY', d) + #13 +
       DefaultFormatSettings.LongMonthNames[3];
  ShowMessage(s);
end;

The project settings are at their default (English, multilingual), but nothing changes when I select German.

This looks as if the month names are not localized correctly. Or am I doing something wrong?

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Monthname not correctly localized
« Reply #1 on: February 11, 2013, 10:18:27 pm »
Code: [Select]
       s := DateToStr(d) + #13 +
       AnsiToUTF8(FormatDateTime('DD MMMM YYYY', d)) + #13 +
       DefaultFormatSettings.LongMonthNames[3];

wp

  • Hero Member
  • *****
  • Posts: 13270
Re: Monthname not correctly localized
« Reply #2 on: February 11, 2013, 10:36:24 pm »
Thanks. And the AnsiToUTF8 should also be applied to DefaultFormatSettings.LongMonthNames. I always get trapped by the UTF8 conversion...

 

TinyPortal © 2005-2018