Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

internationalization of dates on the web

Does anyone have any good "architecture" for the internationalization of dates? like in English its Monday, Chinese: 星期一, Dutch: maandag, Japanese: 月曜日

So my first idea is to create some sort of class that stores the strings of Monday to Sunday in 59 different languages. Apparently this isn't scalable at all, imagine now I need to display "12:34 A.M, Monday, 1st Jan 2000" I will then need another translation for A.M, P.M, the months (both long and short forms), the ordinals, etc, etc.

It's too much work, what's the solution?

like image 992
Pacerier Avatar asked May 09 '11 11:05

Pacerier


People also ask

What is internationalization in website?

Website internationalization is a term used to describe the process companies go through to make their websites more effective at reaching potential customers and business partners in other countries.

What is internationalization in HTML?

Internationalization of HTML takes place at two levels: (1) the characters in the text (apart from the markup) should be able to represent non-western alphabets, such as Cyrillic, Arabic, Hebrew, Japanese, etc.; (2) in addition, for correct display and other operations, it is sometimes necessary to explicitly indicate ...

What is date localization?

Date and time localization is quite an important topic when it comes to developing applications and software systems in multiple languages. Date and time are written and read in different ways in different countries.

What is I18N in Web?

Internationalization (i18n) is the process of preparing software so that it can support local languages and cultural settings. An internationalized product supports the requirements of local markets around the world, functioning more appropriately based on local norms and better meeting in-country user expectations.


2 Answers

Paul Irish said

date.js was abandoned and the version on the homepage is buggy.

and

moment.js is supergood and should be your first pick for date parsing, manip and formatting.

So I guess you people looking for a reliable date javascript library with i18n should use moment.js

like image 127
Julien Avatar answered Nov 10 '22 00:11

Julien


The approach you suggest is not scalable. The Microsoft approach deals with 350 cultures; it has been suggested that there are 160 globally traded currencies etc. Maintaining a class that deals with this range of possibilities is a potential nightmare in the making.

@Aron suggests that your question is a duplicate of Internationalization in Javascript. One of the links in an answer to that question suggests a scalable and maintainable way forward. I would not normally advocate a Microsoft approach, but in this case they do seem to have the right idea for an architecture. Separate out the locale specific material into classes that can be incorporated into your application. Reference the locale specific material by a key based only on the culture (or locale). Don't attempt to maintain culture specific material yourself - unless you HAVE to, you really don't want to go there.

like image 22
Chris Walton Avatar answered Nov 10 '22 00:11

Chris Walton