TwitterCLDR makes it easier for Ruby developers to build internationally accessible services

TwitterCLDR makes it easier for Ruby developers to build internationally accessible services

In line with Twitter’s move to sponsor the Apache Foundation, the social giant has just recently open sourced its own internationalization library for Ruby, TwitterCLDR — based off of the International Components for Unicode library that IBM provides for Java and C/C++ developers.

This move is a part of the company’s larger trend of consuming and producing open source tech, and like Bootstrap and Cassie, this library has the potential to make things easier for devs while opening it up for contributions from users.

Back to TwitterCLDR, here’s why the library was built:

Here’s a test. Say this date out loud: 2/1/2012

If you said, “February first, 2012”, you’re probably an American. If you said, “January second, 2012”, you’re probably of European or possibly Asian descent. If you said, “January 12, 1902”, you’re probably a computer. The point is that as humans, we almost never think about formatting dates, plurals, lists, and the like. If you’re creating a platform available around the world, however, these kinds of minutiae make a big difference to users.

As explained on Twitter’s engineering blog, the Unicode Consortium “publishes and maintains a bunch of data regarding formatting dates, numbers, lists, and more, called the Common Locale Data Repository (CLDR).” That data is what powers IBM’s library, as well as Twitter’s Ruby-friendly library. Here’s a code example:

Let’s format a date in Spanish (es):
$> "lunes, 12 de diciembre de 2011 21:44:57 UTC -0800"


We’ve got you covered for currencies and decimals too:
$> 1337.localize(:es).to_currency.to_s(:currency => "EUR")
$> "1.337,00 €"
$> 1337.localize(:es).to_decimal.to_s(:precision => 3)
$> "1.337,000"

All in all, Twitter’s move simply makes it easier for Ruby developers to write internationally accessible code. Head over to Twitter’s engineering blog to see examples of the code and to learn more about the project.

➤ TwitterCLDR

Read next: StockTwits launches new responsive design and infinite scrolling interface

Here's some more distraction