mbostock/d3 — pull request #1651 by danielsu (2013-11-29 10:06:14+00:00)
Title: I18n (internationalization and localization) at runtime

Dear Mike Bostock,
out of the box D3.js is shipped with english text labels for months and week names.
In my WebApp users can select their favourite language.
I do not like to store multiple D3 files, differing only at a few rows of string definitions.
With this patch, you could overwrite the labels to any language you like.
As far as I know, renaming this strings later does not produce side effects, because calculations e. g. european and us calendar weeks are already done.

1) import d3.js
2) set localised strings like
switch ( locale ) {
case 'de':
d3.time.setLocalizedStrings( MyLocalizations.localeStrings.de.dayNames,
MyLocalizations.localeStrings.de.dayNamesShort,
MyLocalizations.localeStrings.de.monthNames,
MyLocalizations.localeStrings.de.monthNamesShort );
// localizeD3DateFormat: use german presets
break;
case 'fr':
d3.time.setLocalizedStrings( MyLocalizations.localeStrings.fr.dayNames,
MyLocalizations.localeStrings.fr.dayNamesShort,
MyLocalizations.localeStrings.fr.monthNames,
MyLocalizations.localeStrings.fr.monthNamesShort );
break;
case 'en': ...........
3) start using d3

So it is possible to rewrite the labels to any language you like without shipping multiple files of almost the same content.
Is there a better way to do so?
What is your oppinion?

Kind regards,
Daniel Suess from Berlin