\
\
\
@@ -138,6 +139,7 @@
if ( !this.initialized ) {
$( 'body' ).prepend( this.$menu );
+ this.i18n();
// Initialize with a full search.
// This happens on first time click of uls trigger.
this.defaultSearch();
@@ -148,7 +150,11 @@
this.$languageFilter.focus();
},
- defaultSearch: function() {
+ i18n: function() {
+ this.$element.find( '[data-i18n]' ).i18n();
+ },
+
+ defaultSearch: function () {
this.$resultsView.lcd( 'empty' );
this.$regionFilters.first().regionselector( 'show' );
},
@@ -315,6 +321,12 @@
quickList: null // Array of language codes of function that returns such
};
+ // Define a dummy i18n function, if jquery.i18n not integrated.
+ if( !$.fn.i18n ) {
+ $.fn.i18n = function( option ) {
+ };
+ }
+
$.fn.uls.Constructor = ULS;
} ( jQuery ) );
diff --git a/src/jquery.uls.lcd.js b/src/jquery.uls.lcd.js
index 6e5e3a5..1f4a9a0 100644
--- a/src/jquery.uls.lcd.js
+++ b/src/jquery.uls.lcd.js
@@ -25,21 +25,22 @@
var noResultsTemplate = '\
\
-
\
- No results found\
+ \
+ No results found\
\
\
\
\
- You can search by language name, script name, ISO code of language or \
- you can browse by region:\
- America,\
- Europe,\
- Middle East, \
- Africa,\
- Asia,\
- Pacific or \
- Worldwide languages.\
+ You can search by language name, \
+ script name, ISO code of language or \
+ you can browse by region:\
+ America, \
+ Europe, \
+ Middle East, \
+ Africa, \
+ Asia, \
+ Pacific, \
+ Worldwide.\
\
\
\
@@ -149,7 +150,9 @@
render: function() {
var that = this;
- var regions = { // FIXME Remove this when i18n is in place.
+ var $section, $sectionTitle;
+ var regions = {
+ // These are fallback text when i18n library not present
WW: 'Worldwide',
AM: 'America',
EU: 'Europe',
@@ -158,17 +161,22 @@
AF: 'Africa',
PA: 'Pacific'
};
- var $section;
$.each( $.uls.data.regiongroups, function( regionCode, regionIndex ) {
$section = $( '' ).addClass( 'twelve columns uls-lcd-region-section' ).prop( 'id', regionCode );
- $section.append( $( '
' )
- .addClass( 'eleven columns uls-lcd-region-section offset-by-one' )
- .text( regions[regionCode] ) );
+ $sectionTitle = $( '' )
+ .addClass( 'eleven columns uls-lcd-region-section offset-by-one' )
+ .text( regions[regionCode] );
+ $section.append( $sectionTitle );
that.$element.append( $section );
$section.hide();
that.regionDivs[regionCode] = $section;
} );
this.$noResults.hide();
+ this.i18n();
+ },
+
+ i18n: function( ) {
+ this.$element.find( '[data-i18n]' ).i18n();
},
quicklist: function() {
@@ -184,10 +192,13 @@
var quickList = this.options.quickList;
quickList = quickList.slice( 0, 16 );
quickList.sort( $.uls.data.sortByAutonym );
- var $quickListsection = $( '' ).addClass( 'twelve columns uls-lcd-region-section' ).prop( 'id', 'uls-lcd-quicklist' );
- $quickListsection.append( $( '
' ).addClass( 'eleven columns uls-lcd-region-section offset-by-one' ).text( 'Common languages' ) );
- this.$element.prepend( $quickListsection );
- this.regionDivs[ 'quick' ] = $quickListsection;
+ var $quickListSection = $( '
' ).addClass( 'twelve columns uls-lcd-region-section' ).prop( 'id', 'uls-lcd-quicklist' );
+ var $quickListSectionTitle = $( '
' )
+ .addClass( 'eleven columns uls-lcd-region-section offset-by-one' )
+ .text( 'Common languages' ); // This is placeholder text if jquery.i18n not present
+ $quickListSection.append( $quickListSectionTitle );
+ this.$element.prepend( $quickListSection );
+ this.regionDivs[ 'quick' ] = $quickListSection;
for ( var i = 0; i < quickList.length; i++) {
var $column = this.getColumn( 'quick', i % 4 === 0 );
var langCode = quickList[i];
@@ -200,8 +211,9 @@
);
$column.append( $li );
}
- $quickListsection.show();
- return $quickListsection;
+ $quickListSection.show();
+ $quickListSectionTitle.i18n();
+ return $quickListSection;
},
show: function() {
@@ -222,7 +234,10 @@
noResults: function() {
this.$noResults.show();
var $suggestions = this.quicklist();
- $suggestions.find( 'h3' ).text( 'You may be interested in' );
+ $suggestions.find( 'h3' )
+ .data( 'i18n', 'uls-no-results-suggestion-title' )
+ .text( "You may be interested in:" )
+ .i18n();
this.$noResults.find( 'h2' ).after( $suggestions );
},