Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Commit

Permalink
Merge pull request #90 from emattias/issue87
Browse files Browse the repository at this point in the history
Make i18n strings overridable via Tablesaw object
  • Loading branch information
zachleat committed Feb 19, 2015
2 parents 17aea2a + c63eb70 commit b3c7102
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 36 deletions.
3 changes: 0 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ module.exports = function(grunt) {
concat: {
options: {
banner: '<%= banner %>',
process: {
data: grunt.file.readJSON('src/i18n.json')
},
stripBanners: true
},
jsall: {
Expand Down
15 changes: 0 additions & 15 deletions src/i18n.json

This file was deleted.

9 changes: 2 additions & 7 deletions src/tables.columntoggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@
toolbar: 'tablesaw-bar'
};

this.i18n = {
columnBtnText: '<%= columntoggle.buttonText %>',
columnsDialogError: '<%= columntoggle.dialogError %>'
};

// Expose headers and allHeaders properties on the widget
// headers references the THs within the first TR in the table
this.headers = this.$table.find( 'tr:first > th' );
Expand All @@ -49,7 +44,7 @@
id = tableId + "-popup";
$btnContain = $( "<div class='" + this.classes.columnBtnContain + "'></div>" );
$menuButton = $( "<a href='#" + id + "' class='btn btn-micro " + this.classes.columnBtn +"' data-popup-link>" +
"<span>" + this.i18n.columnBtnText + "</span></a>" );
"<span>" + Tablesaw.i18n.columnBtnText + "</span></a>" );
$popup = $( "<div class='dialog-table-coltoggle " + this.classes.popup + "' id='" + id + "'></div>" );
$menu = $( "<div class='btn-group'></div>" );

Expand All @@ -72,7 +67,7 @@
});

if( !hasNonPersistentHeaders ) {
$menu.append( '<label>' + this.i18n.columnsDialogError + '</label>' );
$menu.append( '<label>' + Tablesaw.i18n.columnsDialogError + '</label>' );
}

$menu.appendTo( $popup );
Expand Down
10 changes: 9 additions & 1 deletion src/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@
*/

if( typeof Tablesaw === "undefined" ) {
Tablesaw = {};
Tablesaw = {
i18n: {
modes: [ 'Stack', 'Swipe', 'Toggle' ],
columns: 'Col<span class=\"a11y-sm\">umn</span>s',
columnBtnText: 'Columns',
columnsDialogError: 'No eligible columns.',
sort: 'Sort'
}
};
}
if( !Tablesaw.config ) {
Tablesaw.config = {};
Expand Down
8 changes: 2 additions & 6 deletions src/tables.modeswitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@
toolbar: 'tablesaw-toolbar'
},
modes: [ 'stack', 'swipe', 'columntoggle' ],
i18n: {
modes: [ '<%= modeswitch.stack %>', '<%= modeswitch.swipe %>', '<%= modeswitch.columntoggle %>' ],
columns: '<%= modeswitch.columns %>'
},
init: function( table ) {
var $table = $( table ),
ignoreMode = $table.attr( S.attributes.excludeMode ),
$toolbar = $table.prev( '.tablesaw-bar' ),
modeVal = '',
$switcher = $( '<div>' ).addClass( S.classes.main + ' ' + S.classes.toolbar ).html(function() {
var html = [ '<label>' + S.i18n.columns + ':' ],
var html = [ '<label>' + Tablesaw.i18n.columns + ':' ],
dataMode = $table.attr( 'data-tablesaw-mode' ),
isSelected;

Expand All @@ -47,7 +43,7 @@

html.push( '<option' +
( isSelected ? ' selected' : '' ) +
' value="' + S.modes[ j ] + '">' + S.i18n.modes[ j ] + '</option>' );
' value="' + S.modes[ j ] + '">' + Tablesaw.i18n.modes[ j ] + '</option>' );
}
html.push( '</select></span></label>' );

Expand Down
5 changes: 1 addition & 4 deletions src/tables.sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
tableToolbar: 'tablesaw-toolbar',
sortButton: pluginName + "-btn"
},
i18n = {
sort: '<%= sort.label %>'
},
methods = {
_create: function( o ){
return $( this ).each(function() {
Expand Down Expand Up @@ -113,7 +110,7 @@
},
addSwitcher = function( heads ){
$switcher = $( '<div>' ).addClass( classes.switcher ).addClass( classes.tableToolbar ).html(function() {
var html = [ '<label>' + i18n.sort + ':' ];
var html = [ '<label>' + Tablesaw.i18n.sort + ':' ];

html.push( '<span class="btn btn-small">&#160;<select>' );
heads.each(function( j ) {
Expand Down

0 comments on commit b3c7102

Please sign in to comment.