File tree 6 files changed +70
-6
lines changed
6 files changed +70
-6
lines changed Original file line number Diff line number Diff line change 13
13
< script type ="text/javascript " src ="../source/js/PivotView.js "> </ script >
14
14
< script type ="text/javascript " src ="../source/js/DataController.js "> </ script >
15
15
< script type ="text/javascript " src ="../source/js/MDXParser.js "> </ script >
16
+ < script type ="text/javascript " src ="../source/js/PivotLocale.js "> </ script >
16
17
< script type ="text/javascript " src ="../source/js/ExcelExport.js "> </ script >
17
18
<!-- endbuild -->
18
19
< style >
95
96
}
96
97
97
98
setup = {
98
- container : document . getElementById ( "pivot" ) , // HTMLElement which will contain table.
99
- dataSource : {
99
+ container : document . getElementById ( "pivot" ) // HTMLElement which will contain table.
100
+ //, locale: "en" // language to use (default: browser default or "en")
101
+ , dataSource : {
100
102
MDX2JSONSource : "http://" + location . hostname + ":57773/SAMPLES" ,
101
103
// MDX2JSON server address
102
104
basicMDX : typeof req === "object" ? req . basicMDX : req
103
105
//, pivot: "name of data source.pivot" // name of data source to apply pivot rules
104
106
//[ , namespace: "SAMPLES" ] // current namespace : default namespace
105
107
//[ , username: "USER" ] // user name : default user
106
108
//[ , password: "" ] // user password : default password
107
- } ,
108
- triggers : { //
109
+ }
110
+ , triggers : { //
109
111
// drillDown: function ({Object { level: {number}, mdx: {string} }}) {}
110
112
//, drillThrough: function ({Object { level: {number}, mdx: {string} }}) {}
111
113
//, back: function ({Object { level: {number} }}) {}
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " LightPivotTable" ,
3
3
"author" : " ZitRo" ,
4
- "version" : " 1.0.0-beta.9 " ,
4
+ "version" : " 1.0.0-beta.10 " ,
5
5
"description" : " A lightweight pivot table for MDX2JSON source for InterSystems Cache" ,
6
6
"main" : " test/testServer.js" ,
7
7
"repository" : {
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ Then use global object constructed from <i>LightPivotTable</i>:
37
37
``` js
38
38
var setup = { // Object that contain settings. Any setting may be missed.
39
39
container: document .getElementById (" pivot" ) // HTMLElement which will contain table.
40
+ [, locale: " en" ] // language to use (default: browser default or "en")
40
41
, dataSource: {
41
42
MDX2JSONSource: " http://localhost:57772/SAMPLES" , // MDX2JSON server address
42
43
basicMDX: typeof req === " object" ? req .basicMDX : req
Original file line number Diff line number Diff line change @@ -481,7 +481,7 @@ DataController.prototype.resetRawData = function () {
481
481
isCaption : true ,
482
482
source : { } ,
483
483
noDrillDown : true ,
484
- value : navigator . language === "ru" ? "Всего" : "Total"
484
+ value : pivotLocale . get ( 0 )
485
485
} ;
486
486
applyHeaderStyle ( summary [ i ] , false ) ;
487
487
} else {
Original file line number Diff line number Diff line change @@ -322,6 +322,8 @@ LightPivotTable.prototype.init = function () {
322
322
_ . pivotView . _backClickHandler . call ( _ . pivotView ) ;
323
323
} ;
324
324
325
+ if ( this . CONFIG [ "locale" ] ) { pivotLocale . setLocale ( this . CONFIG [ "locale" ] ) ; }
326
+
325
327
this . refresh ( ) ;
326
328
327
329
} ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Light pivot localization.
3
+ *
4
+ * @scope {pivotLocale} - Sets the pivotLocale scope variable.
5
+ * @param {string } [locale] - Two-letter language code.
6
+ * @constructor
7
+ */
8
+ var PivotLocale = function ( locale ) {
9
+
10
+ this . LOCALE = "" ;
11
+
12
+ this . setLocale ( locale || navigator . language ) ;
13
+
14
+ } ;
15
+
16
+ /**
17
+ * Editable locales.
18
+ *
19
+ * @type {{ru: string, en: string, de: string}[] }
20
+ */
21
+ PivotLocale . prototype . LOCALES = [
22
+ { "ru" : "Всего" , "en" : "Total" , "de" : "Summe" }
23
+ ] ;
24
+
25
+ /**
26
+ * @param {string } locale - Two-letter code locale.
27
+ */
28
+ PivotLocale . prototype . setLocale = function ( locale ) {
29
+
30
+ var i , locales = [ ] ;
31
+
32
+ locale = locale . toLowerCase ( ) ;
33
+
34
+ if ( this . LOCALES [ 0 ] . hasOwnProperty ( locale ) ) {
35
+ this . LOCALE = locale ;
36
+ } else {
37
+ for ( i in this . LOCALES [ 0 ] ) { locales . push ( i ) ; }
38
+ console . warn (
39
+ "LightPivot: locale " + locale + " is not supported. Currently localized: "
40
+ + locales . join ( ", " ) + "."
41
+ ) ;
42
+ this . LOCALE = "en" ;
43
+ }
44
+
45
+ } ;
46
+
47
+ /**
48
+ * Get the localized phrase.
49
+ *
50
+ * @param {number } index - Index of phrase.
51
+ * @returns {string } - Localized string.
52
+ */
53
+ PivotLocale . prototype . get = function ( index ) {
54
+
55
+ return ( this . LOCALES [ index ] || { } ) [ this . LOCALE ] || "{not localized}" ;
56
+
57
+ } ;
58
+
59
+ var pivotLocale = new PivotLocale ( ) ;
You can’t perform that action at this time.
0 commit comments