在哪里可以找到不同国家/地区的d3.js的语言环境对象 [英] Where can in find the locale objects for d3.js for different countries
问题描述
此网址( https://github.com/mbostock/d3/wiki/Localization)显示了两个有关语言环境的示例
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"]
}
和
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.
请帮助.
推荐答案
D3 不加载任何本地化字符串,它创建一个新对象,该对象通过d3.locale
方法.在D3源文件中,有一些预先定义的定义.您可以在以下位置找到它们:
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:
- https://github.com/d3/d3-format/tree /master/locale
- https://github.com/d3/d3-time -format/tree/master/locale
- https://github.com/d3/d3-format/tree/master/locale
- https://github.com/d3/d3-time-format/tree/master/locale
当您要使用除en-US
之外的其他语言环境的格式时,这是为您提供的示例:
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(...);
这篇关于在哪里可以找到不同国家/地区的d3.js的语言环境对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!