Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#15391 closed defect (fixed)

addCustomFormats documentation is incorrect

Reported by: freddefisk Owned by: Adam Peller
Priority: undecided Milestone: 1.9
Component: Documentation Version: 1.7.2
Keywords: Cc: Rawld Gill
Blocked By: Blocking:

Description

The live documentation http://livedocs.dojotoolkit.org/dojo/date/locale/addCustomFormats is incorrect:

require(["dojo/date/locale", "dojo/i18n!dojo/cldr/nls/gregorian"], function(locale, gregorian){
	var bundle = {
		timeFormat-custom: "HH:mm:ss.zzzz",
		dateFormat-custom: "d-MMMM-y"
	};
	locale.addCustomFormats(gregorian, bundle);
});

addCustomFormats takes package name and bundle name as arguments. This is what I came up with. It works for me, but I'm not sure it's correct:

require(["dojo/_base/kernel", "dojo/date/locale", "dojo/i18n"], function(kernel, locale, i18n){
	var bundle = {
		timeFormat-custom: "HH:mm:ss.zzzz",
		dateFormat-custom: "d-MMMM-y"
	};
	i18n.cache("mypackage/nls/gregorian/" + kernel.locale, bundle);
	locale.addCustomFormats("mypackage", "gregorian");
});

Change History (6)

comment:1 Changed 8 years ago by bill

Owner: set to Adam Peller
Status: newassigned

comment:2 Changed 7 years ago by freddefisk

Seems like i18n.cache has changed from a function to an object in [28456]. So the new example code should be

require(["dojo/_base/kernel", "dojo/date/locale", "dojo/i18n"], function(kernel, locale, i18n){
	var bundle = {
		timeFormat-custom: "HH:mm:ss.zzzz",
		dateFormat-custom: "d-MMMM-y"
	};
	i18n.cache["mypackage/nls/gregorian/" + kernel.locale] = bundle;
	locale.addCustomFormats("mypackage", "gregorian");
});

comment:3 Changed 7 years ago by freddefisk

I updated the live doc according to my latest comment. If this is the correct usage, this ticket can be closed.

comment:4 Changed 7 years ago by Adam Peller

Cc: Rawld Gill added

comment:5 Changed 7 years ago by Adam Peller

Resolution: fixed
Status: assignedclosed

freddefisk, thank you for correcting the docs. I believe addCustomFormats has always taken two strings. The bundle could also be loaded using require and the i18n! plugin, but I think i18n.cache should be valid also.

comment:6 Changed 7 years ago by Adam Peller

Milestone: tbd1.9
Note: See TracTickets for help on using tickets.