Angular provide great support for i18n/l10n.
You can find the guide here
The requirements for our application determines how we can implement this support.
- If our application requires only a single locale or the end users of our application belongs only to a particular locale then we can restrict our application scope for i18n/l10n to only that locale
You can find a good explanation of how we can achieve such things in one of my previous answers here.
- If we want to serve a particular component, directive or part to display in some other format or locale then we can go for some directives components or even a filter for that
You can find an example fiddle for such implementation using a filter can be found here
function MyController($scope) {
$scope.property = {
price: 50000000.557
}
}
function toLocaleCurrencyFilter($filter) {
return function(amount, currencySymbol, fractionSize, locale) {
var returnValue = Number(parseFloat(amount)).toLocaleString(locale, {
minimumFractionDigits: parseInt(fractionSize),
maximumFractionDigits: parseInt(fractionSize),
});
returnValue = returnValue + " " + currencySymbol
return returnValue;
};
}
angular.module('myApp', [])
.controller('MyController', ['$scope', MyController])
.filter('toLocaleCurrency', ['$filter', toLocaleCurrencyFilter]);
- If we want dynamic locale then you need to reload browser with the new locale settings by saving it into local storage to take effect.
you can use the solution described in 1 with some dynamic nature.