Skip to content
L'Alabameñu edited this page Apr 14, 2019 · 1 revision

WARNING: The names of methods and modules may change slightly from what they are currently are. Version 1.0 will provide a stable organization/naming system.

Guide to using Intl-CLDR

  1. When to use Intl-CLDR
  2. Modules included
    1. Numbers
    2. Lists
    3. Plurals
  3. Internals

When to use Intl-CLDR

There are many things that we as programmers are used to doing that, while they work fine for our language (and maybe one or two others we speak), we tend to assume are the same universally, but they aren't. Othertimes, we reinvent the wheel for more day-to-day things in our native language. For example, to make a list, we might say

@filenames.join(', ')

But if we want to end it with "and", an industrious coder might say

@filenames[0..*-2].join(', ') ~ ', and ' ~ @filenames.tail;

Using Intl-CLDR, all of this is already defined:

format-list @filenames;                # default has 'and'
format-list(@filenames, :type<unit>);  # no 'and'

It's (1) clearer and (2) will automagically look correct if your user is using a system in a different language. The same can be said for using date/time or number functions. While it's possible to kludge together a way to do scientific numbers or use significant digits, it's much easier and clearer to use:

format-number(25345.329, :scientific);          # 2.5245329E4
format-number(25345.329, :4significant-digits); # 25350
Clone this wiki locally