- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How does internationalization work in JavaScript?
In this article, you will understand how internationalization works in JavaScript. Internationalization is the process of preparing software so that it can support local languages and cultural settings. It can include changing the date and time format, changing the metric system format, language format, etc.
Example 1
In this example, let’s understand the changing of date and time formats.
var inputDate = new Date(1990, 2, 25); console.log("The date is defined as: ") console.log(inputDate) console.log("The date in United Kingdom format is: ") console.log(new Intl.DateTimeFormat('en-GB').format(inputDate)); console.log("The date in American format is: ") console.log(new Intl.DateTimeFormat('en-US').format(inputDate));
Explanation
Step 1 − Define a dateTime value to ‘inputDate’ variable.
Step 2 − Convert the date time value specific to the United Kingdom format using DateTimeFormat('en-GB') function. Display the value after conversion.
Step 3 − Convert the date time value specific to the United States format using DateTimeFormat('en-US') function. Display the value after conversion.
Example 2
var inputNumber = 2153.93; console.log("The number is defined as: ") console.log(inputNumber) console.log("The number after converting to France format is: ") console.log(new Intl.NumberFormat('it-FR').format(inputNumber)); console.log("The number after converting to American format is: ") console.log(new Intl.NumberFormat('us-US').format(inputNumber));
Explanation
Step 1 − Define a numeric value to ‘inputNumber’ variable.
Step 2 − Convert the numeric value specific to the France format using the NumberFormat('it-FR') function. Display the value after conversion.
Step 3 − Convert the numeric value specific to the United States format using the NumberFormat('us-US') function. Display the value after conversion.
To Continue Learning Please Login
Login with Google