Reputation: 4561
I'm trying to adapt the dates in my application depending on the localization.
I tried to change the $locale.id = 'fr-fr'
, but it doesn't update the object so texts stays in english (en-us
is the default $locale.id
).
Then I tried to force a language by including this in my index.html
:
<script type="text/javascript" src="../../Scripts/Angular/i18n/angular-locale_fr.js"></script>
But on my controllers, I still get the en-us
on the $locale.id
and all the english translations:
$locale = Object {DATETIME_FORMATS: Object, NUMBER_FORMATS: Object, id: "en-us"}
How can I control/change the $locale
service language ?
Upvotes: 2
Views: 3835
Reputation: 1756
Indeed, $locale.id
is a read-only property, you cannot set the locale this way.
You can have a look at the angular-dynamic-locale where locale can be set dynamically:
tmhDynamicLocale.set('it');
The module itself is well documented on its github page.
The [angular-dynamic-locale] is needed only if you want to switch your locale on the fly, in most cases you just want to set a single locale for your application.
For that, you can read the i18n guide from the angular docs at the section Providing locale rules to Angular where the two ways to specify the locale for your angular application are described:
Upvotes: 1