Closed SudarshanPH closed 3 years ago
any update on this @danielmoncada?
Same problem with de, fr, it, es... any ideas?
I partially solved with import
import localeIt from '@angular/common/locales/it'; import localeDe from '@angular/common/locales/de'; import localeEs from '@angular/common/locales/es'; import localeFr from '@angular/common/locales/fr'; import { DateTimeAdapter, OwlDateTimeIntl } from '@danielmoncada/angular-datetime-picker';
and
registerLocaleData(localeIt, 'it'); registerLocaleData(localeDe, 'de'); registerLocaleData(localeEs, 'es'); registerLocaleData(localeFr, 'fr'); dateTimeAdapter.setLocale(my_internal_language_variable);
in my class constructor, but still remains "set" and "cancel" missing translation. Months and week days are ok.
yes @fdc80 , that is a good workaround but if we want it to work dynamically to many other languages, we cannot always import all the locales right
Thank you very much @fdc80 your pointers were perfect!
What I did was dynamically load the locale I needed. I followed Michaels post: https://indepth.dev/posts/1038/dynamic-import-of-locales-in-angular
and added this method: importAndLoadLocale(locale) {
import('@angular/common/locales/' + locale + '.js').then(module => {
registerLocaleData(module.default);
this.dateTimeAdapter.setLocale(locale);
});
}
My War file is huge with an extra 3200 locale files, but only the one I need is lazily loaded at run time.
Michael also points out that you can limit the languages, but for now, I am going with the 3200 files.
My last issue is the Set and Cancel buttons. I would like to dynamically translate them after I load my language file. I am using ngx-translate.
Any ideas for that?
Thanks, Dave
Hi @davewicklund , in our case, we send hours and minutes static string to a language api which takes care of translations
Sorry, I've been at bit MIA due to the craziness at work lately. I'll do my best to look into this issue.
We got bitten by this same issue; I believe it is due to https://github.com/danielmoncada/date-time-picker/pull/10/commits/407a7f8623f2ee42251e94415f9a2d382ea99b9a which starts to use getLocaleFirstDayOfWeek
, thereby adding a dependency on the registered Angular locales. We used to derive the first day of the month using moment's locale data, but now the default first day of the week is computed eagerly which crashes due to missing Angular locale data.
I opened #115 that addresses this issue.
fixed in latest version 11.0.1, thanks @JoostK !
Hey, if we import { DateTimeAdapter, OwlDateTimeComponent } from 'ng-pick-datetime'; and set locale using this.dateTimeAdapter.setLocale(' fr '), datepicker throws error without displaying anything.
Screenshot of the Initial date-time picker![Screenshot from 2021-02-08 11-02-24](https://user-images.githubusercontent.com/66046247/107198350-ff4f1980-6a1a-11eb-83df-4dc39066b84c.png)
Screenshot of the Date-time picker after changing the locale using this.dateTimeAdapter.setLocale(' fr '), (Note that we get error for all languages)
.
Can we get this issue resolved. Is there any alternate way to work with dynamic change in end user language?