Is it possible to translate this component's Month and Day names?
Or are you planning to create Tsi* versions of some or all of the VCL 'Windows 10' components?
At this time it is the TCalendarPicker I would like to be able to translate.
Malcolm
TCalendarPicker
Re:
Hello,
I am interested in translating the TCalendarPicker component..any news about this?
Regards.
Massimo.
Re: TCalendarPicker
Hello,
You can use the following events:
TCalendarPicker.OnCalendarDrawMonthItem
TCalendarPicker.OnCalendarDrawYearItem
TCalendarPicker.CalendarHeaderInfo.OnDrawDayOfWeek
to modify the text displayed in TCalendarPicker through DrawParams.Text and Text variables. Unfortunately for the header of TCalendarPicker you would need to handle the OnDrawHeader event and re-paint it completely.
Note: remember that you will need to "know" what is current user's locale and how it is related to the languages in your application in order to be able to get the translated text.
Note #2: as these elements initially displayed in user's language I would recommend to leave them as they are.
Below is a sample code for automatic translation using the TCalendarPicker.OnCalendarDrawMonthItem and TCalendarPicker.CalendarHeaderInfo.OnDrawDayOfWeek events:
This code assumes that running user's locale is the same as first language in dispatcher (Russian in my case) and Dispatcher's TranslationMemoryOption.Active property is True. And Strings property of TsiLang is filled with translations for days of week and month names:

You can use the following events:
TCalendarPicker.OnCalendarDrawMonthItem
TCalendarPicker.OnCalendarDrawYearItem
TCalendarPicker.CalendarHeaderInfo.OnDrawDayOfWeek
to modify the text displayed in TCalendarPicker through DrawParams.Text and Text variables. Unfortunately for the header of TCalendarPicker you would need to handle the OnDrawHeader event and re-paint it completely.
Note: remember that you will need to "know" what is current user's locale and how it is related to the languages in your application in order to be able to get the translated text.
Note #2: as these elements initially displayed in user's language I would recommend to leave them as they are.
Below is a sample code for automatic translation using the TCalendarPicker.OnCalendarDrawMonthItem and TCalendarPicker.CalendarHeaderInfo.OnDrawDayOfWeek events:
Code: Select all
procedure TForm4.CalendarPicker1CalendarDrawMonthItem(Sender: TObject;
DrawParams: TDrawViewInfoParams; CalendarViewViewInfo: TCellItemViewInfo);
var
S: string;
begin
if siLangDispatcher1.ActiveLanguage <> 1 then
begin
if siLangDispatcher1.TranslationMemory(DrawParams.Text, siLangDispatcher1.Language, S) then
DrawParams.Text := S;
end;
end;
procedure TForm4.HeaderInfoDrawDayOfWeek(Sender: TObject;
DrawParams: TDrawParams; DayNumber: Integer; var Text: string);
var
S: string;
begin
if siLangDispatcher1.ActiveLanguage <> 1 then
begin
if siLangDispatcher1.TranslationMemory(Text, siLangDispatcher1.Language, S) then
Text := S;
end;
end;

Re: TCalendarPicker
Hello,
thank you for your help.
I will try your suggestions.
Regards.
Massimo.
thank you for your help.
I will try your suggestions.
Regards.
Massimo.