English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

AngularJS Internationalization

AngularJS supports built-in internationalization for three types of filters: currency, date, and number. We just need to merge the corresponding JavaScript based on the country's language environment. By default, it considers the browser's locale settings. For example, for the Danish locale, use the following script-

<script src="https://code.angularjs.org/1.2.5/i18n/angular-locale_da-dk.js">
</script>

Example using the Danish language environment

testAngularJS.htm

<html>
   <head>
      <title>Angular JS Forms</title>
   </head>
   
   <body>
      <h2>AngularJS Sample Application</h2>
      
      <div ng-app = "mainApp" ng-controller = "StudentController">
         {{fees | currency }}<br/><br/>
         {{admissiondate | date }}<br/><br/>
         {{rollno | number }}
      </div>
      <script src="https://cdn.staticfile.org/angular.js/1.3.14/angular.min.js"></script>
      <script src="https://cdn.staticfile.org/angular.js/1.3.14/i18n/angular-locale_da-dk.js"></script>
      
      <script>
         var mainApp = angular.module("mainApp", []);
         
         mainApp.controller('StudentController', function($scope) {
            $scope.fees = 100;
            $scope.admissiondate = new Date();
            $scope.rollno = 123.45;
         });
      </script>
      
   </body>
</html>
Test and See‹/›

Output Results

Open the file in a web browsertestAngularJS.htmand view the results.

Example using the browser's language environment

testAngularJS.htm

<html>
   <head>
      <title>Angular JS Forms</title>
   </head>
   
   <body>
      <h2>AngularJS Sample Application</h2>
      
      <div ng-app = "mainApp" ng-controller = "StudentController">
         {{fees | currency }}<br/><br/>
         {{admissiondate | date }}<br/><br/>
         {{rollno | number }}
      </div>
      <script src="https://cdn.staticfile.org/angular.js/1.3.14/angular.min.js"></script>
      <!-- <script src="https://cdn.staticfile.org/angular.js/1.3.14/i18n/angular-locale_da-dk.js"></script> -->
      
      <script>
         var mainApp = angular.module("mainApp", []);
         
         mainApp.controller('StudentController', function($scope) {
            $scope.fees = 100;
            $scope.admissiondate = new Date();
            $scope.rollno = 123.45;
         });
      </script>
      
   </body>
</html>
Test and See‹/›

Output Results

Open the file in a web browsertestAngularJS.htmand view the results.