From 33d8ee8c8f46e139845f319dfb6c47caf8b18a13 Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Tue, 13 May 2014 14:03:31 +0100 Subject: [PATCH] Issue #2240555 by penyaskito: Preselect language when importing translations previously exported. --- core/modules/locale/locale.bulk.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/modules/locale/locale.bulk.js b/core/modules/locale/locale.bulk.js index ba9986b1953..80952d0ad6c 100644 --- a/core/modules/locale/locale.bulk.js +++ b/core/modules/locale/locale.bulk.js @@ -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]); } }); }