Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
6bef1c25
Commit
6bef1c25
authored
Feb 27, 2014
by
andy5
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use default appliaction language in DatePicker
Fix
https://github.com/yiisoft/yii2/issues/2562
parent
ad06b80e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
5 deletions
+19
-5
DatePicker.php
extensions/jui/DatePicker.php
+19
-5
No files found.
extensions/jui/DatePicker.php
View file @
6bef1c25
...
@@ -7,11 +7,12 @@
...
@@ -7,11 +7,12 @@
namespace
yii\jui
;
namespace
yii\jui
;
use
Yii
;
use
yii\helpers\Html
;
use
yii\helpers\Html
;
use
yii\helpers\Json
;
use
yii\helpers\Json
;
/**
/**
* DatePicker renders a
n
datepicker jQuery UI widget.
* DatePicker renders a datepicker jQuery UI widget.
*
*
* For example:
* For example:
*
*
...
@@ -45,10 +46,22 @@ use yii\helpers\Json;
...
@@ -45,10 +46,22 @@ use yii\helpers\Json;
class
DatePicker
extends
InputWidget
class
DatePicker
extends
InputWidget
{
{
/**
/**
* @var array the list of supported languages.
*/
public
static
$languageList
=
[
'af'
,
'ar-DZ'
,
'ar'
,
'az'
,
'be'
,
'bg'
,
'bs'
,
'ca'
,
'cs'
,
'cy-GB'
,
'da'
,
'de'
,
'el'
,
'en-AU'
,
'en-GB'
,
'en-NZ'
,
'eo'
,
'es'
,
'et'
,
'eu'
,
'fa'
,
'fi'
,
'fo'
,
'fr-CA'
,
'fr-CH'
,
'fr'
,
'gl'
,
'he'
,
'hi'
,
'hr'
,
'hu'
,
'hy'
,
'id'
,
'is'
,
'it'
,
'ja'
,
'ka'
,
'kk'
,
'km'
,
'ko'
,
'ky'
,
'lb'
,
'lt'
,
'lv'
,
'mk'
,
'ml'
,
'ms'
,
'nb'
,
'nl-BE'
,
'nn'
,
'no'
,
'pl'
,
'pt-BR'
,
'pt'
,
'rm'
,
'ro'
,
'ru'
,
'sk'
,
'sl'
,
'sq'
,
'sr-SR'
,
'sr'
,
'sv'
,
'ta'
,
'th'
,
'tj'
,
'tr'
,
'uk'
,
'vi'
,
'zh-CN'
,
'zh-HK'
,
'zh-TW'
,
];
/**
* @var string the locale ID (eg 'fr', 'de') for the language to be used by the date picker.
* @var string the locale ID (eg 'fr', 'de') for the language to be used by the date picker.
* If this property set to false, I18N will not be involved. That is, the date picker will show in English.
* If this property is not set, then the current application language will be used.
* If the property value is not in the [[languageList]], then date picker will show in English.
*/
*/
public
$language
=
false
;
public
$language
;
/**
/**
* @var boolean If true, shows the widget as an inline calendar and the input as a hidden field.
* @var boolean If true, shows the widget as an inline calendar and the input as a hidden field.
*/
*/
...
@@ -77,12 +90,13 @@ class DatePicker extends InputWidget
...
@@ -77,12 +90,13 @@ class DatePicker extends InputWidget
{
{
echo
$this
->
renderWidget
()
.
"
\n
"
;
echo
$this
->
renderWidget
()
.
"
\n
"
;
$containerID
=
$this
->
inline
?
$this
->
containerOptions
[
'id'
]
:
$this
->
options
[
'id'
];
$containerID
=
$this
->
inline
?
$this
->
containerOptions
[
'id'
]
:
$this
->
options
[
'id'
];
if
(
$this
->
language
!==
false
)
{
$language
=
$this
->
language
===
null
?
Yii
::
$app
->
language
:
$this
->
language
;
if
(
in_array
(
$language
,
static
::
$languageList
))
{
$view
=
$this
->
getView
();
$view
=
$this
->
getView
();
DatePickerRegionalAsset
::
register
(
$view
);
DatePickerRegionalAsset
::
register
(
$view
);
$options
=
Json
::
encode
(
$this
->
clientOptions
);
$options
=
Json
::
encode
(
$this
->
clientOptions
);
$view
->
registerJs
(
"$('#
{
$containerID
}
').datepicker($.extend({}, $.datepicker.regional['
{
$
this
->
language
}
'],
$options
));"
);
$view
->
registerJs
(
"$('#
{
$containerID
}
').datepicker($.extend({}, $.datepicker.regional['
{
$language
}
'],
$options
));"
);
$options
=
$this
->
clientOptions
;
$options
=
$this
->
clientOptions
;
$this
->
clientOptions
=
false
;
// the datepicker js widget is already registered
$this
->
clientOptions
=
false
;
// the datepicker js widget is already registered
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment