Opened 6 years ago

Closed 5 years ago

#16979 closed task (fixed)

HTML lang= attribute overrides dojoConfig.locale property

Reported by: George Sexton Owned by: dylan
Priority: high Milestone: 1.10
Component: Documentation Version: 1.8.3
Keywords: Cc:
Blocked By: Blocking:

Description

Given a page with an HTML tag:

<html lang="en">

and a dojo config of:

var dojoConfig={ "parseOnLoad" : true, "locale" : "en-gb"};

a dijit/form/DateTextBox operates as though the locale were "en", not "en-gb" as expected.

While at first glance this seems like the correct behavior, it's actually not.

Say for example, I have a user who is viewing may page.

Browser Accept Language: pt

Page content: en

lang= attribute: en

My page content is English, I don't want to lie to the browser and tell it the content is Portuguese. However, I want the date/time input devices to be localized for the Portuguese Locale. The current behavior does not permit that and should be changed.

So, in general the way dojo SHOULD work is:

If a locale is present on dojoConfig, that locale should override the HTML lang attribute.

Attachments (1)

datebox.html (1018 bytes) - added by George Sexton 6 years ago.
A test case web page that demonstrates the issue.

Download all attachments as: .zip

Change History (7)

Changed 6 years ago by George Sexton

Attachment: datebox.html added

A test case web page that demonstrates the issue.

comment:1 Changed 6 years ago by George Sexton

I just noticed that a lang= attribute on the input widget will override the page locale. This will work for me. I'll defer to the developers of Dojo on what the correct behavior should be.

At minimum, there should be a doc fix in the locale page that talks about the interaction of the LANG attribute overriding the dojoConfig.locale

comment:2 Changed 6 years ago by Adam Peller

This is a known issue, and a design decision that I think we plan to change in 2.0, but the existing situation probably needs to be much better documented. I also noticed that our tests use html lang="en" now for a11y reasons, which may only add to the confusion.

Last edited 6 years ago by Adam Peller (previous) (diff)

comment:3 Changed 6 years ago by bill

Component: Dijit - FormDijit
Milestone: tbd2.0
Owner: changed from Douglas Hays to bill

IIRC, a current limitation of the code is that djConfig.locale must be the same as the lang setting on the <html> node because some modules ignore the lang setting on <html>. But in general the idea in 1.x is that the lang setting overrides djConfig.locale. That works the same way as native HTML, where a lang setting on an ancestor node overrides the page level setting, so hard to claim that it's "wrong".

For performance reasons, in 2.0 we're planning to get rid of parser support for lang, dir etc., i.e. remove the ability to set lang/dir/etc. on any random ancestor node (including <html>) and have it trickle down to the widgets.

What's the URL of the manual page that we should update?

comment:4 Changed 6 years ago by George Sexton

Really, another issue is specificity. If the page is lang=en, and dojoConfig.locale is en-gb, then dojoConfig has greater specificity and should be used.

The two documentation pages that I feel need updated are:

http://dojotoolkit.org/documentation/tutorials/1.8/dojo_config/

that page talks about locale. It was one of the things I used.

The other one is:

http://dojotoolkit.org/documentation/tutorials/1.8/i18n/

Neither page mentions the HTML lang= attribute at the document or widget level. I'm really OK with specifying the lang= at the widget level. It just took me creating a really simplified test case to determine what the real issue was.

Really, just about anything will work, but it needs to be documented.

comment:5 in reply to:  4 Changed 6 years ago by bill

Component: DijitDocumentation
Milestone: 2.0tbd
Owner: changed from bill to dylan
Status: newassigned
Summary: HTML lang= attribute incorrectly overrides dojoConfig.locale propertyHTML lang= attribute overrides dojoConfig.locale property
Type: defecttask

Replying to gsexton:

Really, another issue is specificity. If the page is lang=en, and dojoConfig.locale is en-gb, then dojoConfig has greater specificity and should be used.

Well, that's one way to look at it. But how about this code?

<div lang=en-gb>
     <span lang=en>hi</span>
</div>

Do you think that en-gb should win because it has greater specificity?

Anyway, thanks for the links. I'm assigning this to Dylan, if he wants to update those tutorials to say that for 1.x when using the parser, the lang= setting on an ancestor DOMNode overrides the djConfig.locale setting. That won't be true in 2.0 though. Also that for 1.x or 2.0, you can specify the lang for individual widgets, and that of course overrides the djConfig.locale setting too.

comment:6 Changed 5 years ago by dylan

Milestone: tbd1.10
Priority: undecidedhigh
Resolution: fixed
Status: assignedclosed

This has been fixed in the locale and i18n tutorials, and will go live the next time the web site is updated (probably on Monday).

Note: See TracTickets for help on using tickets.