angularjs - Angular translate - format dates -


i using angular translate app localization. i'd dynamically change date format depending on user's locale.

  • if locale french : format dd/mm/yyyy
  • if locale english/us : format mm/dd/yyyy
  • ...and on depending on locale's default date format

how can achieve (cleanly) angular translate ?

maybe out of date, don't think angular-translate has localization. here solution (yet clean)

if loading once per page reload use angular-i18n enough. install , put js file html

bower install angular-i18n

<script src="/bower_components/angular-i18n/angular-locale_your-locale.js"></script> 

if want load dynamically angular-dynamic-locale :

bower install angular-dynamic-locale

<script src="mypath/tmhdynamiclocale.js"></script> 

your js:

angular.module('myapp', ['tmh.dynamiclocale', ...])  angular.module('myapp').controller('mycontroller', [..., 'tmhdynamiclocale',     function… {         tmhdynamiclocale.set('en');     } ]) 

note, made sure check repo's readme usage of localelocationpattern(string)


Comments