3

this url (https://github.com/mbostock/d3/wiki/Localization) shows two examples for locales

en_US:
    {
    "decimal": ".",
    "thousands": ",",
    "grouping": [3],
    "currency": ["$", ""],
    "dateTime": "%a %b %e %X %Y",
    "date": "%m/%d/%Y",
    "time": "%H:%M:%S",
    "periods": ["AM", "PM"],
    "days": ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",   "Saturday"],
    "shortDays": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
    "months": ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
    "shortMonths": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
    }

and

ru_RU:
{
"decimal": ",",
"thousands": "\u00A0",
"grouping": [3],
"currency": ["", " руб."],
"dateTime": "%A, %e %B %Y г. %X",
"date": "%d.%m.%Y",
"time": "%H:%M:%S",
"periods": ["AM", "PM"],
"days": ["воскресенье", "понедельник", "вторник", "среда", "четверг", "пятница", "суббота"],
"shortDays": ["вс", "пн", "вт", "ср", "чт", "пт", "сб"],
"months": ["января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря"],
"shortMonths": ["янв", "фев", "мар", "апр", "май", "июн", "июл", "авг", "сен", "окт", "ноя", "дек"]
 }

where can i find all the countries objects?

I am not able to find anything relevant on the page.

Help please.

gaurav5430
  • 12,934
  • 6
  • 54
  • 111
allel
  • 855
  • 1
  • 12
  • 22
  • 2
    d3 allows you to create a new locale, but it does not give you a list of existing locales to choose from. it does not seem to have an existing map or list of locales. you have to define them yourselves based on your requirement. after defining you can use them to localize your strings in d3 – gaurav5430 Feb 17 '16 at 08:50

1 Answers1

5

D3 does not load any localization strings, it creates a new object that handles the localization via d3.locale method. In the D3 source, there are some pre-made definitions; you can find them at:

When you want to use the format of another locale than en-US, this is an example for you:

var esLocaleDef = {...}; // your definition, you can copy from es-Es.js file in the above folder.
var esLocale = d3.locale(esLocaleDef);

// use esLocale.numberFormat instead of d3.format
var esNumberFormat = esLocale.numberFormat(...);

// use esLocale.timeFormat instead of d3.time.format
var esTimeFormat = esLocale.timeFormat(...);
dskrvk
  • 1,318
  • 15
  • 24
Hieu Le
  • 8,288
  • 1
  • 34
  • 55