Issue #2240555 by penyaskito: Preselect language when importing translations previously exported.

8.0.x
Nathaniel Catchpole 2014-05-13 14:03:31 +01:00
parent c5c075dfd8
commit 33d8ee8c8f
1 changed files with 5 additions and 3 deletions

View File

@ -14,9 +14,11 @@
var $langcode = $form.find('.langcode-input');
$form.find('.file-import-input')
.on('change', function () {
var matches = $(this).val().match(/\.([\-\w]+)\.po/);
if (matches && $langcode.find('option[value="' + matches[1] + '"]').length) {
$langcode.val(matches[1]);
// If the filename is fully the language code or the filename
// ends with a language code, pre-select that one.
var matches = $(this).val().match(/([^.][\.]*)([\w-]+)\.po$/);
if (matches && $langcode.find('option[value="' + matches[2] + '"]').length) {
$langcode.val(matches[2]);
}
});
}