angular-material-datetimepicker icon indicating copy to clipboard operation
angular-material-datetimepicker copied to clipboard

Locale issue

Open jekcom opened this issue 7 years ago • 4 comments

When switching locale language in real time the calendar is translated but the date in the textbox is not being translated. That's the input

<input type="text" id="endDate" class="form-control" format="MMM D, YYYY" style="width:150px" placeholder="{{'forever' | translate}}" ng-model="validUntilDate" ok-text="{{'ok' | translate}}" cancel-text="{{'cancel' | translate}}" today-text="{{'today' | translate}}" mdc-datetime-picker="" time="false" date="true" lang="{{vm.languageCode}}" close-text="Close" /> first i do vm.languageCode = 'en'; moment.locale('en'); then switching to french vm.languageCode = 'fr' ; moment.locale('fr');

Notice the textbox on the right is not beeing translated

untitled-1

jekcom avatar Apr 05 '17 13:04 jekcom

Yes, it's because the format is a moment format. When we set moment.locale('fr'), it will affect only the next time we use moment. Maybe we could do something with https://github.com/urish/angular-moment

hexadecy avatar Apr 06 '17 04:04 hexadecy

@jekcom maybe this can be a workaround?

$scope.changeLanguage = function() {
  $translate.use($scope.selectedLang);
  moment.locale($scope.selectedLang);
};

From demo.js

hexadecy avatar Aug 15 '17 13:08 hexadecy

Hello, I have the same issue (format date don't update if we change the moment local (we have to change the date and it works) Does anyone have a solution?

Geoffrey-Dere avatar Aug 24 '17 10:08 Geoffrey-Dere

https://stackoverflow.com/questions/31706054/angularjs-dynamic-locale

hexadecy avatar Aug 25 '17 04:08 hexadecy