Building JS Apps with Internationalization (i18n) in Mind

Rate this content
Bookmark

At Adobe we build products for the world, this talk with provide a high level overview of internationalization (i18n), globalization (g11n), and localization (l10n) best practices. Why these are important and how to implement in design, UX, and within any JS codebase - using vanilla JS examples, and top open source library recommendations.

This talk has been presented at JSNation 2022, check out the latest edition of this JavaScript Conference.

FAQ

The speaker is Naomi Meier, who works on the globalization engineering team at Adobe.

The presentation is about building JavaScript apps with internationalization in mind.

The key definitions covered are localization, internationalization, and globalization.

An example problem discussed is the different syntax for names across various languages and how it affects internationalization.

Unicode is a standard for encoding text in different languages, and it is important for ensuring consistent representation of characters across different systems.

Common internationalization bugs in JavaScript include issues with combining marks, which can cause problems in string manipulation.

The 'normalize' method in JavaScript is used to return the Unicode normalization form of a string, helping to avoid issues with combining marks.

Wrapping all strings in an object for translation helps manage different locales and makes it easier to internationalize an app.

The JSINTL object is an API in JavaScript that provides tools for internationalization, such as formatting numbers, dates, and times according to locale.

Tips include allowing for text expansion, considering different line heights, and testing layouts with texts of varying lengths.

Naomi Meyer
Naomi Meyer
21 min
20 Jun, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

This Talk discusses building JavaScript apps with internationalization in mind, addressing issues such as handling different name formats, using Unicode for compatibility, character encoding bugs, localization and translation solutions, testing in different languages, accommodating translated text in layouts, cultural considerations, and the importance of enabling different languages for users. The speaker also mentions various open source tools for internationalization. The Talk concludes with a reminder to avoid assumptions and embrace diversity in the World Wide Web.

1. Introduction to Internationalization

Short description:

Hello, JS Nation! Thanks for joining me today! I'm really excited to share with you all some ideas about building JavaScript apps with internationalization in mind. My name is Naomi Meier, and I work on the globalization engineering team at Adobe where I do internationalization engineering for a lot of different Adobe apps. Let's start with a name example. So this is a very common string that we see often in English, where folks introduce themselves with the syntax of, Hello, my name is Naomi Meyer. So this is my first name or given name in blue, followed by my last name, family name or surname. So if we take this simple string and translate it here into Japanese, Hindi, Hebrew, Arabic, Korean and Chinese, we can see that that syntax of first name, last name is sometimes switched. Sometimes it's last name, first name and obviously sometimes the text is read left to right. Sometimes the text is read right to left. And so this is kind of just a really visual representation of how we can identify a user's name differently across different locales. This is how Google handles that problem with when you create a Google account, you enter a first name and a last name as distinct data fields. But Twitter recently came out with a great solution to this problem where they have just a simple name field where a user can go in and enter their name and their native script and their native first name, last name, last name, first name kind of syntax. And it will be stored as one distinct field. So I think this is a really cool solution to the username internationalization problem.

Hello, JS Nation! Thanks for joining me today! I'm really excited to share with you all some ideas about building JavaScript apps with internationalization in mind. My name is Naomi Meier, and I work on the globalization engineering team at Adobe where I do internationalization engineering for a lot of different Adobe apps.

So, this is where you can find me online, on my Twitter and my website. And if there's anything that you're feeling passionately about, please let me know. I would love to continue this conversation online. So, here's our agenda for today. I'm going to start with a name example and then move into some definitions of localization, internationalization, globalization, just to kind of level set and make sure that we're all on the same page. And then I'll move into my top five tips to avoid the most common mistakes that we find with internationalizing JavaScript. And then end on culturalization. So overall, the aim of this kind of general presentation is to encourage you all to create experiences that are equally usable, relevant, and meaningful for users all across the globe, and to really amplify the voices of our global users. So I would like to invite you all and encourage you, you know, my fellow JS coders to go out there and really put the world in the world wide web. So let's talk about how we can do that.

Let's start with a name example. So this is a, you know, a very common string that we see often in English, where folks introduce themselves with the syntax of, Hello, my name is Naomi Meyer. So this is my first name or given name in blue, followed by my last name, family name or surname. So if we take this simple string and translate it here into Japanese, Hindi, Hebrew, Arabic, Korean and Chinese, we can see that that syntax of first name, last name is sometimes switched. Sometimes it's last name, first name and obviously sometimes the text is read left to right. Sometimes the text is read right to left. And so this is kind of just a really visual representation of how we can identify a user's name differently across different locales. And this is kind of a high level problem that we're trying to solve with internationalization. My name is kind of a simple American English name. Here's an example of some other names from Brazil and Portuguese, Russia and India. Kind of common names and how they don't necessarily fit easily into this simple first name, last name paradigm. And some of the challenges that we're facing here. So this is how Google handles that problem with when you create a Google account, you enter a first name and a last name as distinct data fields. So users from regions and languages that don't necessarily follow that paradigm are going to have troubles. But Twitter recently came out with a great solution to this problem where they have just a simple name field where a user can go in and enter their name and their native script and their native first name, last name, last name, first name kind of syntax. And it will be stored as one distinct field. So I think this is a really cool solution to the username internationalization problem. So now that our heads are kind of thinking more deeply about internationalization, let's move on to some definitions.

2. Language Granularity and Unicode

Short description:

When it comes to language, there are different levels of granularity: translation, localization, internationalization, and globalization. Culture plays a significant role in how users interact with digital experiences. Expanding digital content into different languages is crucial. Tip number one is to use Unicode everywhere, ensuring compatibility across different systems and programming languages.

So what are we talking about here? When we start at the most granular level, we have translation where, you know, hello becomes ola, konichiwa, bonjour. Then the next sort of level of granularity would be localization. And that's, you know, in English we spell localization with Z in the United States. But if you go over to the United Kingdom, localization is spelt with an S. And so those are both English, but they're different regional dialectic variations. So that's sort of the level of locale that we get into with localization.

The next sort of level up of granularity is internationalization. And this is more on the engineering side, where we wrap the application in tools for internationalization so that they can be shipped in translated forms. So this is where we go into the pipes, where we if, if a software is a house, we'll reach into the pipes, change them out. And create a system that can be easily translated. Then the next level of granularity is globalization, and these kind of all fall under this umbrella of globalization or G11N. And important to note that these are numeric acronyms. So for globalization we take the first character G, followed by the number of characters and then the last character N. And the more I think about these sort of big ideas, culture is deeply rooted in our thinking patterns and it affects how our users interact with and benefit from digital experiences. So internationalization or globalization really go way beyond translation. And by acknowledging cultural characteristics and really celebrating the differences, we're creating with innovation and sort of accessibility and building products for the whole world of users.

So if we look at these two visualizations, we can see that the majority of people on earth do not speak English as their first language. But we can see that the majority of digital content is in English right now. So this is really an opportunity for us to expand digital content online into different languages for users all across the world to use in their native mother tongues. So let's talk about the top five tips for how we can do that. So tip number one is to use Unicode everywhere. So to start, what is Unicode? I'm sure we're all very familiar with seeing this line in our HTML tags where we say meta char set equals UTF 8 for web. So what is UTF? UTF is the Unicode transformation format. Unicode, right? So here's how UTF is represented across 8, 16, and 32 bits, for the character A and the character O, in Japanese. And so UTF 8 is most common on the web. UTF 16 is used by Java and Windows, and 32 are used by Linux and various Unix systems. So UTF is really cool because it's reversible, and so conversions between all are algorithmically based and fast and prevent lossless round-tripping. So we know that many programming languages will directly use one of these UTF encodings. But as JavaScript engineers, which UTF is JavaScript? This is really important when we think about encoding. And whether you're in Reactor, Angular, View, or Spelt, they're all under the hood encoded in the same way.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

How do Localise and Personalize Content with Sanity.io and Next.js
React Advanced Conference 2021React Advanced Conference 2021
8 min
How do Localise and Personalize Content with Sanity.io and Next.js
Sanity.io provides a content platform for structured content that replaces traditional CMS. Their solution allows businesses to structure and query content anywhere using the Sanity studio and open source React application. The talk focuses on solving the challenge of sending personalized data to users in a static website environment using Next.js Vercel for hosting and Sanity for content querying and delivery. The Sanity studio allows for modeling pages, articles, and banners, with banners being shown to visitors based on their country. The solution involves using Grok queries to fetch the right banner based on country information, demonstrating personalization based on localization and dynamic content querying.
End-to-end i18n
React Advanced Conference 2021React Advanced Conference 2021
26 min
End-to-end i18n
Thanks for joining my talk on end-to-end internationalization. I'll walk you through internationalizing a React app, covering translated strings, currency and date formatting, translator management, and injecting translated strings back into the app. The constants used throughout the app define localization settings and translations. The React Intel library is used for managing translations, and custom functions are created for consistent date and number formatting. The translation process involves extracting strings, using tools like PO Edit, and compiling the translated strings into JSON files for the React app.
Internationalizing React
React Summit Remote Edition 2021React Summit Remote Edition 2021
29 min
Internationalizing React
The Talk discusses the challenges of adding and maintaining new languages in a React application and suggests ways to make the process easier. It defines internationalization as the process of architecting an application for localization and explains that localization involves adapting the content and experience for a specific locale. The speaker recommends using libraries for internationalization and provides resources for learning more about the topic. The Talk also addresses edge cases and difficulties with multiple dialects or languages, translation processes, and right-to-left CSS libraries.
Emoji Encoding, � Unicode, & Internationalization
JSNation Live 2020JSNation Live 2020
34 min
Emoji Encoding, � Unicode, & Internationalization
This Talk explores the UTF-8 encoding and its relationship with emojis. It discusses the history of encoding, the birth of Unicode, and the importance of considering global usage when building software products. The Talk also covers JavaScript's encoding issues with Unicode and the use of the string.prototype.normalize method. It highlights the addition of emoji support in Unicode, the variation and proposal process for emojis, and the importance of transparency in emoji encoding. The Talk concludes with the significance of diverse emojis, the recommendation of UTF-8 for web development, and the need to understand encoding and decoding in app architecture.
Localization for Real-World Use-Cases: Key Learnings from Onboarding Global Brands
React Summit 2022React Summit 2022
8 min
Localization for Real-World Use-Cases: Key Learnings from Onboarding Global Brands
I'm going to talk about localisation in the real world and how Sanity, a platform for structured content, focuses on content as data and flexible internationalization. Sanity allows for multiple languages in different markets, providing customization options for content visibility based on location. The platform offers a flexible approach to content creation and customization, allowing organizations to internationalize their content based on their specific needs. With Sanity's query language and the brand new version of Sanity Studio, developers have more flexibility than ever before.
i18n Was the Missing Piece: Let 70%+ of the Users in the World to Access Your Apps
JSNation 2023JSNation 2023
13 min
i18n Was the Missing Piece: Let 70%+ of the Users in the World to Access Your Apps
Today's Talk explores the impact of I18n and DEX for developers, the challenges of I18n, and the importance of understanding different approaches. It discusses determining languages and regions using IP address, browser settings, and URL patterns. The Talk also covers translation loading, using the i18xProvider, and addressing issues such as URL parameters and maintaining translation files. Additionally, it explores connecting with a Content Management System, implementing folder level translation, and utilizing code splats for dynamic routes.

Workshops on related topic

Localizing Your Remix Website
React Summit 2023React Summit 2023
154 min
Localizing Your Remix Website
WorkshopFree
Harshil Agrawal
Harshil Agrawal
Localized content helps you connect with your audience in their preferred language. It not only helps you grow your business but helps your audience understand your offerings better. In this workshop, you will get an introduction to localization and will learn how to implement localization to your Contentful-powered Remix website.
Table of contents:- Introduction to Localization- Introduction to Contentful- Localization in Contentful- Introduction to Remix- Setting up a new Remix project- Rendering content on the website- Implementing Localization in Remix Website- Recap- Next Steps