How to translate Clarion Calendar?

I wanted to know how I can translate the default C9 calendar template to Portuguese.
I would like to translate there, the SUN, MON, TUE… and Months

1 Like

Calendar is provided with full sources - see ABUTILUI.INC and ABUTIL.* files. You can change them as you like. Things to change are:

  • replace CHARSET:ANSI in FONT attributes to CHARSET:Default
  • change occurrences of the MS Sand Serif font to some TrueType font (e.g. Arial, Tahoma, Segoe UI)
  • replace names of days of weeks and months to Portuguese
  • English texts on buttons to Portuguese

I would changed flat BUTTONs to REGIONs+BOXes. It would work more smooth but requires more work.

A few pictures of the code in AbUtilUI.INC may make it easier to grasp quickly. You can put this AbUtilUI.INC edited for Portuguese file in your project folder and it will be compiled instead of the one in LibSrc due to the way the RED file includes project files first:

You can see the Day of Week (SUN-SAT) headings on the Window are STRNG('MMM') that get replaced at runtime by ClarionDayOfTheWeekShort[base_col]. The Month name is a STRING(@s15),USE(?MonthYear). I also show the Window preview ontop.

Above you see that BUTTON('Today') and BUTTON('Close') are part of the Window declaration. Easy to change but wish they were also variables.

Shown below there are 4 groups with Day/Month names that replace the STRING('MMM') and STRING(@s15),USE(?MonthYear)` on the windows.


The way this is setup is is very close to being able to NOT need to modify the .INC source code to change to Portuguese. CalendarBaseClass would need methods to change the Day and Month name variables so it could be done at runtime once when your program opens, or any time it wants to change language.

CalendarBaseClass.SetDayName PROCEDURE(BYTE DayNumber, STRING ShortName, LongName)
  ClarionDayOfTheWeekShort[ DayNumber ] = ShortName
  ClarionDayOfTheWeekLong [ DayNumber ] = LongName

CalendarBaseClass.SetMonthName PROCEDURE(BYTE MonthNumber, STRING ShortName, LongName)
  ClarionMonthListShort[ MonthNumber ] = ShortName
  ClarionMonthListLong [ MonthNumber ] = LongName

The second problem is the Today/Close button literals would need Static Strings similar to Day/Month and code to set them at runtime and resize the button (use PROP:NoWidth)

 BUTTON('&Today'),AT(5,101,30,13),USE(?Today),FONT('Microsoft Sans Serif', 8,COLOR:Black,FONT:regular,CHARSET:ANSI),FLAT
 BUTTON('&Close'),AT(73,101,30,13),USE(?Exit),FONT('Microsoft Sans Serif', 8,COLOR:Black,FONT:regular,CHARSET:ANSI),FLAT

The CalendarSmallClass has an empty .Setup(),Virtual method provided to inherit and modify the window. You can derive your own Portuguese_SmallCalendar Class(CalendarSmallClass) and in your .Setup(),Derived find those Today and Close buttons and change them. Plus iterate the controls and make Font changes @Also suggested. There is also an .IsHoliday(),Virtual you can derive to color Holiday buttons.

Well after all that typing … thinking about it more the simplest thing to do is edit that UI.INC file as you need it, but then you cannot change language at runtime.

1 Like

I was very excited to learn there are OTHER CalendarClasses one could use! Thank you Carl! :clap:
And to think they were under my nose all this time :man_facepalming:

How to change the Calendar Class:
Global Properties → Classes
“Calendar Class:” CalendarSmallClass


Question 1: Carl, you mentioned one could just edit the or copy it and save it in the current APP project folder! hmm where does one include THIS new file name UI.INC in the APP?
“After Global INCLUDEs” ??

Question 2: How can one change the Start DAY of the week from Sun to Mon?

1 Like

Question 2:
SELF.FirstWeekDay = 1 (Monday)

1 Like

Thank you Marius! That worked!

Instead of UI.INC my post should have said AbUtilUI.INC, I have edited that post.

The way the compiler uses the RED file if it finds a AbUtilUI.INC in your project it will take that instead of the one in LibSrc.

So copy AbUtilUI.INC into your project folder and leave it named that way. Then change the language.

If you want that calendar in all your projects you could put that AbUtilUI.INC file in your Clarion\Accessory\LibSrc\Win folder.

1 Like