2015-06-05 20:17:55 +00:00
|
|
|
/**
|
2017-05-19 22:12:53 +00:00
|
|
|
* DO NOT EDIT THIS FILE.
|
|
|
|
* See the following change record for more information,
|
2017-05-23 14:30:14 +00:00
|
|
|
* https://www.drupal.org/node/2815083
|
2017-05-19 22:12:53 +00:00
|
|
|
* @preserve
|
|
|
|
**/
|
2015-06-05 20:17:55 +00:00
|
|
|
|
2014-01-25 02:37:16 +00:00
|
|
|
(function ($, Drupal) {
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.behaviors.importLanguageCodeSelector = {
|
2021-12-18 06:12:16 +00:00
|
|
|
attach(context, settings) {
|
|
|
|
const form = once('autodetect-lang', '#locale-translate-import-form');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2021-08-10 10:05:02 +00:00
|
|
|
if (form.length) {
|
2021-12-18 06:12:16 +00:00
|
|
|
const $form = $(form);
|
|
|
|
const $langcode = $form.find('.langcode-input');
|
2017-05-19 22:12:53 +00:00
|
|
|
$form.find('.file-import-input').on('change', function () {
|
2022-01-17 16:08:33 +00:00
|
|
|
const matches = this.value.match(/([^.][.]*)([\w-]+)\.po$/);
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2021-12-18 06:12:16 +00:00
|
|
|
if (matches && $langcode.find(`option[value="${matches[2]}"]`).length) {
|
2022-01-17 16:08:33 +00:00
|
|
|
$langcode[0].value = matches[2];
|
2017-05-19 22:12:53 +00:00
|
|
|
}
|
|
|
|
});
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
2012-09-01 01:59:54 +00:00
|
|
|
}
|
2021-12-18 06:12:16 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
2017-05-19 22:12:53 +00:00
|
|
|
})(jQuery, Drupal);
|