dateAxisRenderer, i18n and JS loacle settings

1,679 views
Skip to first unread message

The Brn

unread,
Jul 15, 2011, 3:31:11 AM7/15/11
to jqplot...@googlegroups.com
Hi,

first of all: jqPlot is an great framework.

I'm using dateAxisRenderer as in the example explained (http://
www.jqplot.com/tests/zooming.php). The data is coming from PHP by
using JSON.
So I have 2 Questions.
1.) how to display local month & day names?
I know, that the jquery.jqplot.min.js includes the different, regional
names. But, how to apply this in the example above?

2.) I have an strange behavior, since I'm using jqPlot in my
application.
An jqPlot graph and an jQuery date picker are components on the same
website.
The jQuery date picker works well. All the names of month and day are
displayed in the local language (which is german in my case). After
implementing the jqPlot example, the date-format from the jQuery
Datepicker changed to something like Chinese or Japanese (strange
signs).
....and the jqPlot displayed the names still in English (see 1.) )

What's going wrong there? Is it possible, that jqPlots "resets" the
"locale" Settings on client side?
By the way, navigator.language.indexOf() returns "de" Isn't it
possible to use that method to decide what reginal setting to use?

Thank you,
Brn.

Chris Leonello

unread,
Jul 17, 2011, 10:21:16 AM7/17/11
to jqplot...@googlegroups.com
Yes, date axes support localization since the 1.0.0a builds.  I separated out date handling into a new library, jsdate.  You can find jsdate documentation at:


1.) how to display local month & day names?
 
Localization should be handled automatically for German.  English, French, German, Spanish, Russian, Arabic and Portuguese are currently supported.  If you had a new language you wanted to add which wasn't supported, you could look at docs here:


I am testing for locale by using:

document.getElementsByTagName('html')[0].lang

This may not be returning the right value in all cases.  I'll look into using the navigator object as well.

The jQuery date picker works well. All the names of month and day are
displayed in the local language (which is german in my case). After
implementing the jqPlot example, the date-format from the jQuery
Datepicker changed to something like Chinese or Japanese (strange
signs).
....and the jqPlot displayed the names still in English (see 1.) )
I am not sure what conflict you have here.  jsdate does not set anything outside of it's namespace.  It does not alter the built in date object or the localization of the page.  If you find a more specific problem with jsdate, please let me know. Sorry I can't be of more help.   

-- 
Chris Leonello
http://www.jqplot.com
--
You received this message because you are subscribed to the Google Groups "jqplot-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/jqplot-users/-/LffkaJagOPIJ.
To post to this group, send email to jqplot...@googlegroups.com.
To unsubscribe from this group, send email to jqplot-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jqplot-users?hl=en.

The Brn

unread,
Jul 18, 2011, 4:05:26 AM7/18/11
to jqplot-users
Hallo Chris,

thank you for your replay.
> http://www.jqplot.com/jsdate-docs
>
> > 1.) how to display local month & day names?
I found the jsDate documentation before, but unfortunately I don't
know, how to use/apply.... where to add the code and so on (I'm new on
OO Javascript)


> I am testing for locale by using:
>
> document.getElementsByTagName('html')[0].lang

That doesn't explain the reason why the datepicker uses asian
characters.

But probably that's the reason, why I get the jqPlot version in
english,
because: document.getElementsByTagName('html')[0].lang on my computer
returns "en" while navigator.language retruns "de". (in Firefox)
So if jqPlot is using document.getElementsByTagName('html')[0].lang,
that will be the reason, why I have an english version of jqPlot.

Could it be an idea to change :

jsDate.regional.getLocale = function () {
var l = jsDate.config.defaultLocale;

if ( document && document.getElementsByTagName('html') &&
document.getElementsByTagName('html')[0].lang ) {
l = document.getElementsByTagName('html')[0].lang;
if (!jsDate.regional.hasOwnProperty(l)) {
l = jsDate.config.defaultLocale;
}
}


Into

jsDate.regional.getLocale = function () {
var l = jsDate.config.defaultLocale;

if ( document && document.getElementsByTagName('html') &&
navigator.language ) {
l = navigator.language;
if (!jsDate.regional.hasOwnProperty(l)) {
l = jsDate.config.defaultLocale;
}
}

??

Thank you, Brn

Chris Leonello

unread,
Jul 18, 2011, 7:18:55 AM7/18/11
to jqplot...@googlegroups.com
That doesn't explain the reason why the datepicker uses asian
characters.

The jQuery date picker works well. All the names of month and day are
displayed in the local language (which is german in my case). After
implementing the jqPlot example, the date-format from the jQuery
Datepicker changed to something like Chinese or Japanese (strange
signs).
....and the jqPlot displayed the names still in English (see 1.) )
I am not sure what conflict you have here.  jsdate does not set anything outside of it's namespace.  It does not alter the built in date object or the localization of the page.  If you find a more specific problem with jsdate, please let me know. Sorry I can't be of more help

I don't know what is causing the asian characters.  I don't think jsdate can do anything to cause this, it doesn't alter any properties of the page or code outside of it's namespace.  It doesn't change the localization in any way, it simple looks at the current localization and decides what to do.

-- 
Chris Leonello
http://www.jqplot.com
--
You received this message because you are subscribed to the Google Groups "jqplot-users" group.

The Brn

unread,
Jul 18, 2011, 7:52:35 AM7/18/11
to jqplot-users
> it doesn't alter any properties of the page or code outside of it's namespace. It doesn't change the localization in any way, it simple looks at the current localization and decides what to do.

Thank you, that was important to know.

Meanwhile I found out, why "document.getElementsByTagName('html')
[0].lang ) " gives me an "en", even the HTML meta information is:
<meta name="language" content="de" />
Because that HTML Code was generated by an PHP Framework, so I didn't
notice the following line until now:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

...after changing this line to <html xmlns="http://www.w3.org/1999/
xhtml" xml:lang="de" lang="de">, document.getElementsByTagName('html')
[0].lang ) returns now "de" and dateAxisRenderer writes german
names! :-)

Unfortunately there was no change at the datpicker (still asian
character)

howsoever - thank you for the time. :-)

Brn
Reply all
Reply to author
Forward
0 new messages