[OpenLayers-Dev] status of translation possibilities

Gertjan van Oosten gertjan at West.NL
Sat Oct 20 13:02:15 EDT 2007


As quoted from Lourens Veen:
> I haven't followed this thread that carefully so maybe it has come up
> already, but what about number formats? OL's current scale display uses
> K and M for thousands and millions, which is not how it's commonly done
> on paper maps. I'd really rather have it write out the full number, but
> of course it would then have to use a number format that is appropriate
> to the locale. In Dutch, I would like it to say 1:50.000, while in
> English that would be 1:50,000.
>
> If you're designing i18n anyway...

Well, strictly speaking you're talking about L10n (Localisation).

That's currently beyond MapBuilder's reach, as you would need locale-specific
formatters for that (date, numbers, money).  It is doable; some JavaScript
classes to do this may be available out there.  I haven't taken the effort
to integrate them into MapBuilder though (not enough demand).
Once you have these L10n classes, fitting them into the i18n framework is
easy, as I will show below.

Let's say we start out with:
  var msg = "Scale 1:" + map.scale;
which (if map.scale==25000) would give us "Scale 1:25000", in any language.

Say the message key "mapScale" maps to the message format string "Scale 1:{0}"
in English or "Schaal 1:{0}" in Dutch.  After the I18n step it would be:
  var msg = OpenLayers.String.format("mapScale", msp.scale);
which would give "Scale 1:25000" in English and "Schaal 1:25000" in Dutch.

If we then add L10n, e.g.:
  var formattedNumber = OpenLayers.Something.DecimalFormat(map.scale);
would return the number formatted according to the proper decimal format
for the current locale, e.g. #,### for UK or #.### for NL.

Combining the two:
  var msg = OpenLayers.String.format("mapScale", formattedNumber);
would return the I18n'ed message, and since the formattedNumber is L10n'ed,
the resulting message would be say "Scale 1:25,000" in English and
"Schaal 1:25.000" in Dutch.

As you see, I18n and L10n are quite complementary.  So the two could be
implemented separately (and could even have separate RFC's, which has my
preference).

Regards,
-- 
-- Gertjan van Oosten, gertjan at West.NL, West Consulting B.V., +31 15 2191 600





More information about the Dev mailing list