Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enh Widget DatePicker and DateTimepicker with automatic language support #98

Closed
Enrica-r opened this issue Jun 25, 2014 · 2 comments
Closed

Comments

@Enrica-r
Copy link

Hello Kartik
In my test-fork of your extension I have added automatic language support. If language isn't defined in pluginOptions the init method calls yii::$app->language. To make it more user friendly I have added a "normal" option $language. But this is only necessary if developer wants to set language manually.

Language is set often like en-US. That's why I have added a codeline later in registerAssets to take first two letters ("en").

New entry in common part:

    /** added by Enrica:
     * @var string the locale ID (eg 'fr', 'de') for the language to be used by the date picker.
     * If this property is empty, then the current application language will be used.
     */
    public $language;

New entry in method init:

        if (!isset($this->pluginOptions['language'])){
            $this->pluginOptions['language'] = $this->language ? $this->language : Yii::$app->language;
        }

New entry in method registerAssets:

        if (!empty($this->pluginOptions['language'])) {
            // entered by Enrica: next line only
            $this->pluginOptions['language'] = substr($this->pluginOptions['language'], 0, 2);
            DatePickerAsset::register($view)->js[] = 'js/locales/bootstrap-datepicker.' . $this->pluginOptions['language'] . '.js';

Do you want to add automatic language support? In my application I want to avoid hard coded settings. In my application user's language is stored in user table. After login yii::$app->language will be set by user's language.

@kartik-v
Copy link
Owner

Will consider this as an enhancement.

@kartik-v
Copy link
Owner

Resolved. Extension upgraded to new release v.2.6.0. The documentation site is also updated for use of the new language property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants