GSoC 2010 – 3 weeks summary: June 14th – July 4th

This summary is a little bit unusual as it summaries 3 weeks and not 1 :-). This was pretty busy time for me at univ as with the end of the semester few projects and exams were need to be done / taken. So I focused on these and informed my mentor that I will catch up when holidays begin. So I’m doing it right now ;-).

During the end-of-semester period I managed to do simple things. I refactored some classes in order to conform FLOW3 Coding Guidelines, updated CLDR version in FLOW3 package, did more minor code refactoring. All of the tasks were Karsten’s notices / suggestions.

With the beginning of July my holidays started, so I focused on GSoC project. The most important part I implemented was message formatting (r4694). These classes will be responsible for formatting messages (labels, strings), or to be more precise, replacing the “placeholders” in these messages with formatted values (numbers, date/time, etc). Placeholders have very simple syntax and look like this:

  • {0}, {1} etc – Places string-casted version of a value (number in brackets defines the value’s index from values array provided)
  • {0,number,decimal} or {0,number} – Format as decimal number using pattern from CLDR defined for current locale
  • {0,datetime} – Format as date and time
  • {0,datetime,time,full} – Format only time part, choose the “full” version of pattern from CLDR

Second element in the placeholder defines name of formatter to use. Remaining elements are passed directly to the formatter (for example, NumberFormatter uses only one additional element, defining if format value as decimal, or percentage, but DatetimeFormatter accepts two elements – style (datetime, date or time) and length (full, long, medium, short).

DatetimeFormatter is still subject to change (as you can see, there is some duplication in placeholders, when you write {0,datetime,time,full}, it would be nicer to write {0,time,full}. But this can be changed very easily as formatters are simple classes implementing FormatterInterface, and are automatically loaded if needed.

Formatter classes are the place where the data from CLDR is used. Numbers and date / time are formatted with rules from CLDR.

I managed to do few more commits this week (improved exception hierarchy in Locale, defined public API as Karsten suggested, but it’s not finished yet of course), but I didn’t manage to commit changes I have in my working copy right now. It’s still a lot to be done but I think it will be pretty important commit which will clear up any concerns about the classes already done and how the Locale subpackage is meant to be used.

What I’m doing right now is the Translator class which will translate texts (also using the information about plural forms). But this class needs some kind of messages repository. I’m implementing XLIFF parser so messages will be stored in XLIFF files, but adding support for other file formats in the future will be pretty easy. The new code also imposed changes on older parts (mainly on CLDRModel etc) so I think the class hierarchy will be more robust now.

Tags: ,

blog comments powered by Disqus