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

No time display when not english #79

Closed
Commifreak opened this issue Apr 24, 2017 · 9 comments
Closed

No time display when not english #79

Commifreak opened this issue Apr 24, 2017 · 9 comments

Comments

@Commifreak
Copy link
Contributor

Commifreak commented Apr 24, 2017

When I use english as locale, the Widget uses correct time format (Is use DateTimePicker, so this should be clear.

en-US
1

de-DE
2

Why is the time here missing? Is something unconfigured here?

Field-Config:

	[
		'attribute' => 'show_till',
		'type' => DetailView::INPUT_DATETIME,
		'widgetOptions' => [
			'pluginOptions' => [
				'autoclose' => true
			]
		]
	],
@Commifreak
Copy link
Contributor Author

No idea? Is something wrong with some Yii2 configuration parameters? Id ont got it fixed, yet.

@kartik-v
Copy link
Owner

kartik-v commented Jun 1, 2017

You have to set the language property of the widget to de which must reflect within widgetOptions in your code above.

Read the docs for DateTimePicker widget settings. The language is needed if you need locale specific implementation.

It will default to Yii::$app->language - and if you have already set that to de - then you need to debug the format masks for date time.

@kartik-v kartik-v closed this as completed Jun 1, 2017
@Commifreak
Copy link
Contributor Author

Hi,

I got it - the language is set properly to de, but in the .de locale file, the date format is wrong: https://github.com/kartik-v/yii2-widget-datetimepicker/blob/master/assets/js/locales/bootstrap-datetimepicker.de.js#L16

This would be the file for a datepicker - not for dateTIMEpicker.

Is this fixable through you or should I set this manually? I believe this is a wrong setting for this file.

@kartik-v
Copy link
Owner

kartik-v commented Jun 1, 2017

No just set the pluginOptions['format'] property to what you need.

@kartik-v
Copy link
Owner

kartik-v commented Jun 1, 2017

For example

'pluginOptions' => [
    'format' => 'dd.mm.yyyy hh:ii'
]

But you can submit a PR to change the DE locale file to include a default like above.

@Commifreak
Copy link
Contributor Author

Commifreak commented Jun 1, 2017

But this is hard coded then. This results in fixed format for every language then, right? It should auto-switch. In my eyes the file has wrong format. The file, linked above, should have defaults to:

format: 'dd.mm.yyyy HH:ii:ss' as it's aslo the default for en:

    getDefaultFormat: function (type, field) {
      if (type == 'standard') {
        if (field == 'input')
          return 'yyyy-mm-dd hh:ii';

I see, the language files have different defaults - some with time, some without. But this here is a dateTIMEpicker, so here we should set the time within defaults. If someone wants no time, we should use the https://github.com/kartik-v/yii2-widget-datepicker or am I wrong?

@kartik-v
Copy link
Owner

kartik-v commented Jun 1, 2017

As I mentioned you can submit a pull request to change the default format for german language in the de locale file... these are defaults from the source plugin (maintained by different author).

@Commifreak
Copy link
Contributor Author

Ok, thanks :)

@Commifreak
Copy link
Contributor Author

Ah, now I understand the "why": The original author did not seperated datepicker and datetimepicker and thus your datetimepicker uses the default locale from the developer.

I create a Pull request ;)

This was referenced Jun 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants