Skip to content

Commit c7e8f81

Browse files
committed
Added Spanish translation and fixed the example
1 parent 69fb428 commit c7e8f81

11 files changed

Lines changed: 126 additions & 191 deletions

File tree

Gruntfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ module.exports = function (grunt) {
99
];
1010

1111
fullIncludes = [
12-
'jquery'
12+
'jquery',
13+
'select2/compat/matcher'
1314
].concat(includes);
1415

1516
var i18nModules = [];

dist/js/i18n/es.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/select2.amd.full.js

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,49 +1636,6 @@ define('select2/i18n/en',[],function () {
16361636
};
16371637
});
16381638

1639-
define('select2/compat/matcher',[
1640-
1641-
], function () {
1642-
function oldMatcher (matcher) {
1643-
function wrappedMatcher (params, data) {
1644-
var match = $.extend(true, {}, data);
1645-
1646-
if (params.term == null || $.trim(params.term) === '') {
1647-
return match;
1648-
}
1649-
1650-
if (data.children) {
1651-
for (var c = data.children.length - 1; c >= 0; c--) {
1652-
var child = data.children[c];
1653-
1654-
// Check if the child object matches
1655-
// The old matcher returned a boolean true or false
1656-
var doesMatch = matcher(params.term, child.text, child);
1657-
1658-
// If the child didn't match, pop it off
1659-
if (!doesMatch) {
1660-
match.children.splice(c, 1);
1661-
}
1662-
}
1663-
1664-
if (match.children.length > 0) {
1665-
return match;
1666-
}
1667-
}
1668-
1669-
if (matcher(params.term, data.text, data)) {
1670-
return match;
1671-
}
1672-
1673-
return null;
1674-
}
1675-
1676-
return wrappedMatcher;
1677-
}
1678-
1679-
return oldMatcher;
1680-
});
1681-
16821639
define('select2/defaults',[
16831640
'jquery',
16841641
'./results',
@@ -1701,8 +1658,7 @@ define('select2/defaults',[
17011658
'./dropdown/hidePlaceholder',
17021659
'./dropdown/infiniteScroll',
17031660

1704-
'./i18n/en',
1705-
'./compat/matcher'
1661+
'./i18n/en'
17061662
], function ($, ResultsList,
17071663
SingleSelection, MultipleSelection, Placeholder,
17081664
Utils, Translation,
@@ -2218,6 +2174,49 @@ define('select2/core',[
22182174
return Select2;
22192175
});
22202176

2177+
define('select2/compat/matcher',[
2178+
2179+
], function () {
2180+
function oldMatcher (matcher) {
2181+
function wrappedMatcher (params, data) {
2182+
var match = $.extend(true, {}, data);
2183+
2184+
if (params.term == null || $.trim(params.term) === '') {
2185+
return match;
2186+
}
2187+
2188+
if (data.children) {
2189+
for (var c = data.children.length - 1; c >= 0; c--) {
2190+
var child = data.children[c];
2191+
2192+
// Check if the child object matches
2193+
// The old matcher returned a boolean true or false
2194+
var doesMatch = matcher(params.term, child.text, child);
2195+
2196+
// If the child didn't match, pop it off
2197+
if (!doesMatch) {
2198+
match.children.splice(c, 1);
2199+
}
2200+
}
2201+
2202+
if (match.children.length > 0) {
2203+
return match;
2204+
}
2205+
}
2206+
2207+
if (matcher(params.term, data.text, data)) {
2208+
return match;
2209+
}
2210+
2211+
return null;
2212+
}
2213+
2214+
return wrappedMatcher;
2215+
}
2216+
2217+
return oldMatcher;
2218+
});
2219+
22212220
define('jquery.select2',[
22222221
'jquery',
22232222
'select2/core'

dist/js/select2.amd.js

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,49 +1636,6 @@ define('select2/i18n/en',[],function () {
16361636
};
16371637
});
16381638

1639-
define('select2/compat/matcher',[
1640-
1641-
], function () {
1642-
function oldMatcher (matcher) {
1643-
function wrappedMatcher (params, data) {
1644-
var match = $.extend(true, {}, data);
1645-
1646-
if (params.term == null || $.trim(params.term) === '') {
1647-
return match;
1648-
}
1649-
1650-
if (data.children) {
1651-
for (var c = data.children.length - 1; c >= 0; c--) {
1652-
var child = data.children[c];
1653-
1654-
// Check if the child object matches
1655-
// The old matcher returned a boolean true or false
1656-
var doesMatch = matcher(params.term, child.text, child);
1657-
1658-
// If the child didn't match, pop it off
1659-
if (!doesMatch) {
1660-
match.children.splice(c, 1);
1661-
}
1662-
}
1663-
1664-
if (match.children.length > 0) {
1665-
return match;
1666-
}
1667-
}
1668-
1669-
if (matcher(params.term, data.text, data)) {
1670-
return match;
1671-
}
1672-
1673-
return null;
1674-
}
1675-
1676-
return wrappedMatcher;
1677-
}
1678-
1679-
return oldMatcher;
1680-
});
1681-
16821639
define('select2/defaults',[
16831640
'jquery',
16841641
'./results',
@@ -1701,8 +1658,7 @@ define('select2/defaults',[
17011658
'./dropdown/hidePlaceholder',
17021659
'./dropdown/infiniteScroll',
17031660

1704-
'./i18n/en',
1705-
'./compat/matcher'
1661+
'./i18n/en'
17061662
], function ($, ResultsList,
17071663
SingleSelection, MultipleSelection, Placeholder,
17081664
Utils, Translation,

dist/js/select2.full.js

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11171,49 +11171,6 @@ define('select2/i18n/en',[],function () {
1117111171
};
1117211172
});
1117311173

11174-
define('select2/compat/matcher',[
11175-
11176-
], function () {
11177-
function oldMatcher (matcher) {
11178-
function wrappedMatcher (params, data) {
11179-
var match = $.extend(true, {}, data);
11180-
11181-
if (params.term == null || $.trim(params.term) === '') {
11182-
return match;
11183-
}
11184-
11185-
if (data.children) {
11186-
for (var c = data.children.length - 1; c >= 0; c--) {
11187-
var child = data.children[c];
11188-
11189-
// Check if the child object matches
11190-
// The old matcher returned a boolean true or false
11191-
var doesMatch = matcher(params.term, child.text, child);
11192-
11193-
// If the child didn't match, pop it off
11194-
if (!doesMatch) {
11195-
match.children.splice(c, 1);
11196-
}
11197-
}
11198-
11199-
if (match.children.length > 0) {
11200-
return match;
11201-
}
11202-
}
11203-
11204-
if (matcher(params.term, data.text, data)) {
11205-
return match;
11206-
}
11207-
11208-
return null;
11209-
}
11210-
11211-
return wrappedMatcher;
11212-
}
11213-
11214-
return oldMatcher;
11215-
});
11216-
1121711174
define('select2/defaults',[
1121811175
'jquery',
1121911176
'./results',
@@ -11236,8 +11193,7 @@ define('select2/defaults',[
1123611193
'./dropdown/hidePlaceholder',
1123711194
'./dropdown/infiniteScroll',
1123811195

11239-
'./i18n/en',
11240-
'./compat/matcher'
11196+
'./i18n/en'
1124111197
], function ($, ResultsList,
1124211198
SingleSelection, MultipleSelection, Placeholder,
1124311199
Utils, Translation,
@@ -11753,6 +11709,49 @@ define('select2/core',[
1175311709
return Select2;
1175411710
});
1175511711

11712+
define('select2/compat/matcher',[
11713+
11714+
], function () {
11715+
function oldMatcher (matcher) {
11716+
function wrappedMatcher (params, data) {
11717+
var match = $.extend(true, {}, data);
11718+
11719+
if (params.term == null || $.trim(params.term) === '') {
11720+
return match;
11721+
}
11722+
11723+
if (data.children) {
11724+
for (var c = data.children.length - 1; c >= 0; c--) {
11725+
var child = data.children[c];
11726+
11727+
// Check if the child object matches
11728+
// The old matcher returned a boolean true or false
11729+
var doesMatch = matcher(params.term, child.text, child);
11730+
11731+
// If the child didn't match, pop it off
11732+
if (!doesMatch) {
11733+
match.children.splice(c, 1);
11734+
}
11735+
}
11736+
11737+
if (match.children.length > 0) {
11738+
return match;
11739+
}
11740+
}
11741+
11742+
if (matcher(params.term, data.text, data)) {
11743+
return match;
11744+
}
11745+
11746+
return null;
11747+
}
11748+
11749+
return wrappedMatcher;
11750+
}
11751+
11752+
return oldMatcher;
11753+
});
11754+
1175611755
define('jquery.select2',[
1175711756
'jquery',
1175811757
'select2/core'

dist/js/select2.full.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/select2.js

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,49 +2064,6 @@ define('select2/i18n/en',[],function () {
20642064
};
20652065
});
20662066

2067-
define('select2/compat/matcher',[
2068-
2069-
], function () {
2070-
function oldMatcher (matcher) {
2071-
function wrappedMatcher (params, data) {
2072-
var match = $.extend(true, {}, data);
2073-
2074-
if (params.term == null || $.trim(params.term) === '') {
2075-
return match;
2076-
}
2077-
2078-
if (data.children) {
2079-
for (var c = data.children.length - 1; c >= 0; c--) {
2080-
var child = data.children[c];
2081-
2082-
// Check if the child object matches
2083-
// The old matcher returned a boolean true or false
2084-
var doesMatch = matcher(params.term, child.text, child);
2085-
2086-
// If the child didn't match, pop it off
2087-
if (!doesMatch) {
2088-
match.children.splice(c, 1);
2089-
}
2090-
}
2091-
2092-
if (match.children.length > 0) {
2093-
return match;
2094-
}
2095-
}
2096-
2097-
if (matcher(params.term, data.text, data)) {
2098-
return match;
2099-
}
2100-
2101-
return null;
2102-
}
2103-
2104-
return wrappedMatcher;
2105-
}
2106-
2107-
return oldMatcher;
2108-
});
2109-
21102067
define('select2/defaults',[
21112068
'jquery',
21122069
'./results',
@@ -2129,8 +2086,7 @@ define('select2/defaults',[
21292086
'./dropdown/hidePlaceholder',
21302087
'./dropdown/infiniteScroll',
21312088

2132-
'./i18n/en',
2133-
'./compat/matcher'
2089+
'./i18n/en'
21342090
], function ($, ResultsList,
21352091
SingleSelection, MultipleSelection, Placeholder,
21362092
Utils, Translation,

dist/js/select2.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/examples.html

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
slug: examples
55
---
66

7+
<script type="text/javascript" src="dist/js/i18n/es.js"></script>
8+
79
<div class="container">
810
<section id="basic" class="row">
911
<div class="col-md-4">
@@ -343,7 +345,9 @@ <h1>Multiple languages</h1>
343345

344346
<p>
345347
Select2 supports displaying the messages in different languages, as well
346-
as provding your own custom messages that can be displayed.
348+
as provding your own
349+
<a href="options.html#language">custom messages</a>
350+
that can be displayed.
347351
</p>
348352

349353
<p>
@@ -352,11 +356,10 @@ <h1>Multiple languages</h1>
352356
</p>
353357

354358
<p>
355-
Note that when tagging is enabled the user can select from pre-existing
356-
options or create a new tag by picking the first choice, which is what
357-
the user has typed into the search box so far.
359+
The language does not have to be defined when Select2 is being
360+
initialized, but instead can be defined in the <code>[lang]</code>
361+
attribute of any parent elements as <code>[lang="es"]</code>.
358362
</p>
359-
360363
</div>
361364
<div class="col-md-8">
362365
<h2>Example code</h2>
@@ -565,7 +568,7 @@ <h2>Example code</h2>
565568
});
566569

567570
$language.select2({
568-
language: "en"
571+
language: "es"
569572
});
570573
});
571574
</script>

0 commit comments

Comments
 (0)