1
0
mirror of synced 2024-11-25 06:16:08 +03:00

Added Spanish translation and fixed the example

This commit is contained in:
Kevin Brown 2014-11-05 11:25:41 -05:00
parent 69fb428e01
commit c7e8f81595
11 changed files with 126 additions and 191 deletions

View File

@ -9,7 +9,8 @@ module.exports = function (grunt) {
];
fullIncludes = [
'jquery'
'jquery',
'select2/compat/matcher'
].concat(includes);
var i18nModules = [];

1
dist/js/i18n/es.js vendored Normal file
View File

@ -0,0 +1 @@
window.$=window.$||{},function(){$&&$.fn&&$.fn.select2&&$.fn.select2.amd&&(define=$.fn.select2.amd.define,require=$.fn.select2.amd.require),define("select2/i18n/es",[],function(){return{inputTooShort:function(e){var t="Por favor, introduzca "+remainingChars+" car";return remainingChars==1?t+="ácter":t+="acteres",t},loadingMore:function(){return"Cargando más resultados…"},noResults:function(){return"No se encontraron resultados"}}}),require("jquery.select2"),$.fn.select2.amd={define:define,require:require}}();

View File

@ -1636,49 +1636,6 @@ define('select2/i18n/en',[],function () {
};
});
define('select2/compat/matcher',[
], function () {
function oldMatcher (matcher) {
function wrappedMatcher (params, data) {
var match = $.extend(true, {}, data);
if (params.term == null || $.trim(params.term) === '') {
return match;
}
if (data.children) {
for (var c = data.children.length - 1; c >= 0; c--) {
var child = data.children[c];
// Check if the child object matches
// The old matcher returned a boolean true or false
var doesMatch = matcher(params.term, child.text, child);
// If the child didn't match, pop it off
if (!doesMatch) {
match.children.splice(c, 1);
}
}
if (match.children.length > 0) {
return match;
}
}
if (matcher(params.term, data.text, data)) {
return match;
}
return null;
}
return wrappedMatcher;
}
return oldMatcher;
});
define('select2/defaults',[
'jquery',
'./results',
@ -1701,8 +1658,7 @@ define('select2/defaults',[
'./dropdown/hidePlaceholder',
'./dropdown/infiniteScroll',
'./i18n/en',
'./compat/matcher'
'./i18n/en'
], function ($, ResultsList,
SingleSelection, MultipleSelection, Placeholder,
Utils, Translation,
@ -2218,6 +2174,49 @@ define('select2/core',[
return Select2;
});
define('select2/compat/matcher',[
], function () {
function oldMatcher (matcher) {
function wrappedMatcher (params, data) {
var match = $.extend(true, {}, data);
if (params.term == null || $.trim(params.term) === '') {
return match;
}
if (data.children) {
for (var c = data.children.length - 1; c >= 0; c--) {
var child = data.children[c];
// Check if the child object matches
// The old matcher returned a boolean true or false
var doesMatch = matcher(params.term, child.text, child);
// If the child didn't match, pop it off
if (!doesMatch) {
match.children.splice(c, 1);
}
}
if (match.children.length > 0) {
return match;
}
}
if (matcher(params.term, data.text, data)) {
return match;
}
return null;
}
return wrappedMatcher;
}
return oldMatcher;
});
define('jquery.select2',[
'jquery',
'select2/core'

View File

@ -1636,49 +1636,6 @@ define('select2/i18n/en',[],function () {
};
});
define('select2/compat/matcher',[
], function () {
function oldMatcher (matcher) {
function wrappedMatcher (params, data) {
var match = $.extend(true, {}, data);
if (params.term == null || $.trim(params.term) === '') {
return match;
}
if (data.children) {
for (var c = data.children.length - 1; c >= 0; c--) {
var child = data.children[c];
// Check if the child object matches
// The old matcher returned a boolean true or false
var doesMatch = matcher(params.term, child.text, child);
// If the child didn't match, pop it off
if (!doesMatch) {
match.children.splice(c, 1);
}
}
if (match.children.length > 0) {
return match;
}
}
if (matcher(params.term, data.text, data)) {
return match;
}
return null;
}
return wrappedMatcher;
}
return oldMatcher;
});
define('select2/defaults',[
'jquery',
'./results',
@ -1701,8 +1658,7 @@ define('select2/defaults',[
'./dropdown/hidePlaceholder',
'./dropdown/infiniteScroll',
'./i18n/en',
'./compat/matcher'
'./i18n/en'
], function ($, ResultsList,
SingleSelection, MultipleSelection, Placeholder,
Utils, Translation,

View File

@ -11171,49 +11171,6 @@ define('select2/i18n/en',[],function () {
};
});
define('select2/compat/matcher',[
], function () {
function oldMatcher (matcher) {
function wrappedMatcher (params, data) {
var match = $.extend(true, {}, data);
if (params.term == null || $.trim(params.term) === '') {
return match;
}
if (data.children) {
for (var c = data.children.length - 1; c >= 0; c--) {
var child = data.children[c];
// Check if the child object matches
// The old matcher returned a boolean true or false
var doesMatch = matcher(params.term, child.text, child);
// If the child didn't match, pop it off
if (!doesMatch) {
match.children.splice(c, 1);
}
}
if (match.children.length > 0) {
return match;
}
}
if (matcher(params.term, data.text, data)) {
return match;
}
return null;
}
return wrappedMatcher;
}
return oldMatcher;
});
define('select2/defaults',[
'jquery',
'./results',
@ -11236,8 +11193,7 @@ define('select2/defaults',[
'./dropdown/hidePlaceholder',
'./dropdown/infiniteScroll',
'./i18n/en',
'./compat/matcher'
'./i18n/en'
], function ($, ResultsList,
SingleSelection, MultipleSelection, Placeholder,
Utils, Translation,
@ -11753,6 +11709,49 @@ define('select2/core',[
return Select2;
});
define('select2/compat/matcher',[
], function () {
function oldMatcher (matcher) {
function wrappedMatcher (params, data) {
var match = $.extend(true, {}, data);
if (params.term == null || $.trim(params.term) === '') {
return match;
}
if (data.children) {
for (var c = data.children.length - 1; c >= 0; c--) {
var child = data.children[c];
// Check if the child object matches
// The old matcher returned a boolean true or false
var doesMatch = matcher(params.term, child.text, child);
// If the child didn't match, pop it off
if (!doesMatch) {
match.children.splice(c, 1);
}
}
if (match.children.length > 0) {
return match;
}
}
if (matcher(params.term, data.text, data)) {
return match;
}
return null;
}
return wrappedMatcher;
}
return oldMatcher;
});
define('jquery.select2',[
'jquery',
'select2/core'

File diff suppressed because one or more lines are too long

46
dist/js/select2.js vendored
View File

@ -2064,49 +2064,6 @@ define('select2/i18n/en',[],function () {
};
});
define('select2/compat/matcher',[
], function () {
function oldMatcher (matcher) {
function wrappedMatcher (params, data) {
var match = $.extend(true, {}, data);
if (params.term == null || $.trim(params.term) === '') {
return match;
}
if (data.children) {
for (var c = data.children.length - 1; c >= 0; c--) {
var child = data.children[c];
// Check if the child object matches
// The old matcher returned a boolean true or false
var doesMatch = matcher(params.term, child.text, child);
// If the child didn't match, pop it off
if (!doesMatch) {
match.children.splice(c, 1);
}
}
if (match.children.length > 0) {
return match;
}
}
if (matcher(params.term, data.text, data)) {
return match;
}
return null;
}
return wrappedMatcher;
}
return oldMatcher;
});
define('select2/defaults',[
'jquery',
'./results',
@ -2129,8 +2086,7 @@ define('select2/defaults',[
'./dropdown/hidePlaceholder',
'./dropdown/infiniteScroll',
'./i18n/en',
'./compat/matcher'
'./i18n/en'
], function ($, ResultsList,
SingleSelection, MultipleSelection, Placeholder,
Utils, Translation,

File diff suppressed because one or more lines are too long

View File

@ -4,6 +4,8 @@ title: Examples - Select2
slug: examples
---
<script type="text/javascript" src="dist/js/i18n/es.js"></script>
<div class="container">
<section id="basic" class="row">
<div class="col-md-4">
@ -343,7 +345,9 @@ $.select2.amd.require(['select2/compat/matcher'], function (oldMatcher) {
<p>
Select2 supports displaying the messages in different languages, as well
as provding your own custom messages that can be displayed.
as provding your own
<a href="options.html#language">custom messages</a>
that can be displayed.
</p>
<p>
@ -352,11 +356,10 @@ $.select2.amd.require(['select2/compat/matcher'], function (oldMatcher) {
</p>
<p>
Note that when tagging is enabled the user can select from pre-existing
options or create a new tag by picking the first choice, which is what
the user has typed into the search box so far.
The language does not have to be defined when Select2 is being
initialized, but instead can be defined in the <code>[lang]</code>
attribute of any parent elements as <code>[lang="es"]</code>.
</p>
</div>
<div class="col-md-8">
<h2>Example code</h2>
@ -565,7 +568,7 @@ $.fn.select2.amd.require(
});
$language.select2({
language: "en"
language: "es"
});
});
</script>

View File

@ -20,8 +20,7 @@ define([
'./dropdown/hidePlaceholder',
'./dropdown/infiniteScroll',
'./i18n/en',
'./compat/matcher'
'./i18n/en'
], function ($, ResultsList,
SingleSelection, MultipleSelection, Placeholder,
Utils, Translation,

21
src/js/select2/i18n/es.js vendored Normal file
View File

@ -0,0 +1,21 @@
define(function () {
return {
inputTooShort: function (args) {
var message = 'Por favor, introduzca ' + remainingChars + ' car';
if (remainingChars == 1) {
message += 'ácter';
} else {
message += 'acteres';
}
return message;
},
loadingMore: function () {
return 'Cargando más resultados…';
},
noResults: function () {
return 'No se encontraron resultados';
}
};
});