Answer the question
In order to leave comments, you need to log in
Yii 2 select 2 by kartik. Why doesn't Russian language work in ajax search?
Hello.
Tell me why the Russian locale may not work in the widget? The widget's language property is explicitly set to 'ru', but all the captions are still in English.
$form->field($model, 'dir_streets_id')->widget(Select2::classname(), [
'initValueText' => $model->streetDesc, // set the initial display text
'language' => 'ru',
'options' => ['placeholder' => 'Поиск ...'],
'pluginOptions' => [
'allowClear' => true,
'minimumInputLength' => 3,
'language' => [
'errorLoading' => new JsExpression("function () { return 'Загрузка...'; }"),
],
'ajax' => [
'url' => $urlList,
'dataType' => 'json',
'data' => new JsExpression('function(params) { return {q:params.term}; }')
],
'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
'templateResult' => new JsExpression('function(dir_streets_id) { return dir_streets_id.text; }'),
'templateSelection' => new JsExpression('function (dir_streets_id) { return dir_streets_id.text; }'),
],
]);
'language' => [
'errorLoading' => new JsExpression("function () { return 'Загрузка...'; }"),
],
Answer the question
In order to leave comments, you need to log in
Good afternoon.
Does the ru.js file exist in the vendor/kartik-v/yii2-widget-select2/assets/js/i18n directory ?
If it is not there, then there will be no Russian translation.
You also need to check which language is set in the application's configuration file, in the config directory .
return [
'language' => 'ru', // указать русский язык
'components' => [
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question