Forum
23:48
10/08/2009
Hello Tony,
Before making more large changes in "i18n\grid.locale-XX.js" I suggest to implement very small changes which will alow to include multiple languages on one page and be make able to choose the best language of jqGrid dynamically based on the web browser language. Additionally one will be able to switch dinamically between languages.
The first problem is "How to load many grid.locale-XX.js without overwriting the information". To make it possible I suggest to $.jgrid.regional with will be obect with the properties corresponds the names like "en", "en-US", "en-GB", "en-IN" and so on. As the value of the properties will be the same information from grid.locale-XX.js which are currently from $.jgrid. For the compatibility with existing code the same information which will be placed in $.jgrid.regional.en and $.jgrid.regional["en-US"] will be placed or overwrite the current settings from the $.jgrid.
Moreover the script from grid.locale-XX.js should work also in case of thisting $.jgrid object.
I suggest to change grid.locale-XX.js from the current structure
$.jgrid = {
defaults : {
...
};
})(jQuery);
to the following
var locInfo = {
defaults : {
...
};
$.jgrid = $.jgrid || {};
if (!$.jgrid.hasOwnProperty("regional")) { $.jgrid.regional = {}; }
$.jgrid.regional.en = $.jgrid.regional["en-US"] = locInfo;
$.extend($.jgrid, locInfo);
})(jQuery);
After the changes in all files it will be possible to load many grid.locale-XX.js on one page. The language information from the last JS-file will be used as the current language.
To switch to another language one should call
If the grid is already created one should unload it with respect of GridUnload and create one more time.
I made two demos: one simple and another more advanced which demonstrate all can work and how ona can additionally dinamically choose the best jqGrid language before creating of jqGrid. The choice will be based on the language of the web browsers (navigator.language || navigator.browserLanguage). One can include in jqGrid small functions to simplyfy dynamicaly choice of jqGrid language.
I hope that this new functionality will be the first step to the better globalization of jqGrid.
Best regards
Oleg
12:32
Moderators
30/10/2007
Oleg,
I'm not ready to implemet now your suggestion.
I must think something and IMHO we should apply more general (radical) solution.
Let see what will be with jQuery globalization plugin
https://github.com/jquery/jquery-global
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
12:50
10/08/2009
Tony,
what globalization plugin do is another problem. In my last suggestion with $.jgrid,$.jgrid.regional[] I try to solve problem mostly with pure jqGrid texts from grid.locale-XX.js and not to solve the problem in date and number format for example.
To be able to write international application using jqGrid jqgrid should support including of more then one grid.locale-XX.js files. The choice of the language based on the language of the browser (like in the second example), getting the information from cookie or allowing the user to make a choice is already details. The first problem is to get the possibility to hold more then one language information in the jqgrid. I suggest to use $.jgrid,$.jgrid.regional[] for the porpose to be more close with the names used in the datepicker of jQuery UI (like $.datepicker.regional['fr'] or $.datepicker.regional.fr).
Best ragards
Oleg
14:14
Moderators
30/10/2007
Hello Oleg,
From what I see (I'm not 100% sure since no time to test) there is a problem , when we try to have two grids in the same page one in German and one in Russian which is the purpose of this change.
Suppose the second created grid is in Russian. You work with this grid -form edit and all possible things search and etc. For now do not work with the first one German. After time you want to open the search form in the first grid (German) and then surprise the translation is in Russian.
IMHO the lang should be set in the grid options and we shold load the appropriate translations – i.e all methods that use translations to be changed something like this by example
searchGrid : function (p) {
var lang = this[0].p.language;
p = $.extend({
….
}, $.jgrid.search[lang], p || {});
or something similar.
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
22:16
10/08/2009
Tony,
I agree with you that my current suggestion not allows to have two grids in different languages on one page. First of all it is not a standard requirement. One can of couse implement the language setting as the new option of jqGrid, which I would find very good. One can also use additionally $.jgrid.currentLanguage property (with the value like 'de', or 'en-US') together with the $.jgrid.regional[] array. So one can use this[0].p.language if it is defined and call $.extend with $.jgrid.regional[lang].search. If language option is not defined in jqGrid one can use $.jgrid.currentLanguage.
I made my suggestion so like I wrote as originally ony to make minimal changes in the current jqGrid code and make all as more as possible compatible with the previous versions of jqGrid. If you are ready to make small changes at the begining of all jqGrid methods which used any settings from grid.locale-XX.js if would be better of course. The changes in the methods should be like you described in your last post I will find it very good.
The only thing which probably would be good to impelent additionally would be a special value for new language jqGrid parameter which will mean to make the choose based on the web browsers language (navigator.language || navigator.browserLanguage). In the case jqGrid can choose the most close language from the languages found in the $.jgrid,$.jgrid.regional[] array. If for example only 'en-US' are included one can get it also for the 'en-IN' (India) language of the web browser. One can have also default langauge (like "en-US" or other value which can be redefined) for the case that no easy language mapping can pe resolved.
Because jqGrid are used in many many countries the btter internationalization of jqGrid can be very important in my opinion.
Best regards
Oleg
Most Users Ever Online: 715
Currently Online:
50 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66