1
0
mirror of synced 2024-11-22 04:56:08 +03:00

Allow for a partial dictionary in language

This closes https://github.com/select2/select2/issues/3202.
This commit is contained in:
Kevin Brown 2015-04-02 10:52:31 -04:00
parent 01160f29d8
commit 00a78bdb1e
7 changed files with 56 additions and 6 deletions

View File

@ -4471,7 +4471,14 @@ S2.define('select2/defaults',[
options.translations = languages;
} else {
options.translations = new Translation(options.language);
var baseTranslation = Translation.loadPath(
this.defaults.amdLanguageBase + 'en'
);
var customTranslation = new Translation(options.language);
customTranslation.extend(baseTranslation);
options.translations = customTranslation;
}
return options;

File diff suppressed because one or more lines are too long

9
dist/js/select2.js vendored
View File

@ -4471,7 +4471,14 @@ S2.define('select2/defaults',[
options.translations = languages;
} else {
options.translations = new Translation(options.language);
var baseTranslation = Translation.loadPath(
this.defaults.amdLanguageBase + 'en'
);
var customTranslation = new Translation(options.language);
customTranslation.extend(baseTranslation);
options.translations = customTranslation;
}
return options;

File diff suppressed because one or more lines are too long

View File

@ -257,7 +257,14 @@ define([
options.translations = languages;
} else {
options.translations = new Translation(options.language);
var baseTranslation = Translation.loadPath(
this.defaults.amdLanguageBase + 'en'
);
var customTranslation = new Translation(options.language);
customTranslation.extend(baseTranslation);
options.translations = customTranslation;
}
return options;

View File

@ -0,0 +1,28 @@
module('Options - Translations');
var $ = require('jquery');
var Options = require('select2/options');
test('partial dictionaries can be passed', function (assert) {
var options = new Options({
language: {
searching: function () {
return 'Something';
}
}
});
var translations = options.get('translations');
assert.equal(
translations.get('searching')(),
'Something',
'The partial dictionary still overrides translations'
);
assert.equal(
translations.get('noResults')(),
'No results found',
'You can still get English translations for keys not passed in'
);
});

View File

@ -71,6 +71,7 @@
<script src="options/data-tests.js" type="text/javascript"></script>
<script src="options/deprecated-tests.js" type="text/javascript"></script>
<script src="options/translation-tests.js" type="text/javascript"></script>
<script src="options/width-tests.js" type="text/javascript"></script>
<script src="selection/allowClear-tests.js" type="text/javascript"></script>