Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#10784 closed defect (wontfix)

form.DateTextBox doesn't support dynamic language switch

Reported by: timdp Owned by:
Priority: high Milestone: tbd
Component: Dijit - Form Version: 1.4.0
Keywords: dijit i18n Cc:
Blocked By: Blocking:

Description

When loading additional languages using djConfig.extraLocale, the DateTextBox? does not switch languages when it's "lang" attribute is set.

The below example illustrates the problem.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<style>
@import "dojo/resources/dojo.css";
@import "dijit/themes/tundra/tundra.css";
@import "dijit/themes/tundra/Calendar.css";
</style>
</head>
<body>
<div id="localLong" type="text" name="date1" value="2005-12-30"
					dojoType="dijit.form.DateTextBox"
					constraints="{min:'2004-01-01',max:'2006-12-31',formatLength:'long'}"
					required="true"
					trim="true"
					invalidMessage="Invalid date." > 
</div> 
<button id="switch">Switch language</button>

</body>
<script src="dojo/dojo.js" djconfig="locale:'en-gb', extraLocale:['de-de']"></script>
<script>

dojo.addOnLoad(function () {
	dojo.require("dijit.dijit");
	dojo.require("dijit.form.DateTextBox");
	dojo.require("dojo.parser");
	dojo.parser.parse();

	var x = new mywidget({}, dojo.byId("widget"));
	
	dojo.connect(dojo.byId("switch"), "onclick", null, function() {
		var dtb = dijit.byId("localLong");
		alert(dtb);
		dtb.lang = "de-de";
		dtb.startup();
		dtb.validate(dtb.value, dtb.constraints);
	});
});</script>
</html>

Change History (7)

comment:1 Changed 10 years ago by timdp

Sorry, you'll need to lose the "var x =" line - I meant to strip that out.

comment:2 Changed 10 years ago by Adam Peller

Component: InternationalizationDijit
Owner: Adam Peller deleted

The 'lang' attribute is non-mutable... that should probably be documented. There isn't any support for changing this dynamically on any widget AFAIK or triggering a re-draw of the Calendar UI, in general. However, you can destroy and reinstantiate the widget with the new lang.

comment:3 Changed 10 years ago by Adam Peller

Resolution: wontfix
Status: newclosed

Confirmed that we documented this -- lang [const]

comment:4 Changed 10 years ago by timdp

How will the docs get updated off the back of this please?

Also, could you provide an example of how to destroy/recreate with all the same attributes (apart from lang!) in place?

comment:5 Changed 10 years ago by dante

not sure about the first question. the second could be:

var englishDefaults = {
    lang: "en", id:"bar", something:"else"
} 

var x = new dijit.form.DateTextBox(englishDefaults);
x.destroy();

var germanDefaults = dojo.mixin({}, englishDefaults, { lang:"de" });
var gx = new dijit.form.DateTextBox(germanDefaults);

comment:6 Changed 10 years ago by Adam Peller

So it's non-obvious and I'm not sure our doc tools render tags in our doc like [const] but it is in the source. From 1.4.1:

74	        // lang: [const] String
75	        //              Rarely used.  Overrides the default Dojo locale used to render this widget,
76	        //              as defined by the [HTML LANG](http://www.w3.org/TR/html401/struct/dirlang.html#adef-lang) attribute.
77	        //              Value must be among the list of locales specified during by the Dojo bootstrap,
78	        //              formatted according to [RFC 3066](http://www.ietf.org/rfc/rfc3066.txt) (like en-us).
79	        lang: "",

comment:7 Changed 8 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.