Closed fonemi closed 5 years ago
Can't be easily fixed in 2.0. Closing it unless there's a bright new idea.
For me even if the language in config/web.php is set to "en" this problem happens. In vendor/bower/jquery-ui/ui/i18n folder there is no datepicker-en.js. There are only en-AU, en-GB, and en-NZ versions. Any idea why is that and how I can fix this problem? I'm on Yii 2.0.35.
I guess when the language of a website is "en" we don't need a language file for datepicker and that's why jQueryUI doesn't provide a datepicker-en.js, so why is Yii trying to load such a script?
Quick and dirty "solution" for cases when the language is set to 'en-US' and cant be changed, just add in the config/web.php file the following:
'components'=>[
...
'assetManager' => [
'bundles' => [
'yii\jui\DatePickerLanguageAsset' => [
'autoGenerate' => false,
]
]
],
]
@martin-paliza solution works well to avoid that error in browser. To change widget's language, as current language in yii2, you can create a custom AssetBundle & register it at "main.php" layout template like:
backend\assets\DatePickerAllLanguagesAsset::register($this);
`<?php
namespace backend\assets;
use yii\web\AssetBundle;
class DatePickerAllLanguagesAsset extends AssetBundle {
public $sourcePath = '@bower/jquery-ui/ui';
public $jsOptions = array(
'position' => \yii\web\View::POS_END
);
public $js = [
'i18n/datepicker-af.js',
'i18n/datepicker-ar-DZ.js',
// ...and other js files
];
}`
By the way, if you are compressing all files in a single minified one, maybe you have to put this "DatePickerAllLanguagesAsset" at the end in the "bundles" list , or at least after "yii\jui\JuiAsset"
hope this helps :D
What steps will reproduce the problem?
Set
$app->language = 'en-US'
, use DatePickerWidget anywhere in page.What's expected?
If language JS file doesn't exist, it shouldn't be included.
What do you get instead?
404 not found error in javascript console of the browser.
Additional info