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.
Building JS Apps with Internationalization (i18n) in Mind
AI Generated Video Summary
1. Introduction to Internationalization
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
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.
3. Character Encoding and Internationalization
So let's talk about some of those common bugs that we see. So the first one is with combining marks. So combining marks is where we take a Unicode code point for the Latin small letter A, and then we add a combining mark code point. Here we have a combining ring above it. That's how it's for a Danish atomic graph name character that has A with a little circle over it, so the A with a little circle over it are two separate code points that combine to make one. So if we take these two separate characters and console log them, we can see what's returned is the A with a little circle above it. Great, but because these are two separate characters, we can see some problems.
So let's move on to tip number two, to wrap all strings in an object for translation. So from a really high-level kind of pseudo code example here we can take a hard-coded hello string of hello world and then, so this is a hard-coded string, this is what not to do, but what we can do instead is take this string and wrap it in an internationalization object where we have a list of resources for each of the different locales. So here we can see English has an object with the key of hello message that equals the key value, the value is hello world.
4. Localization and Translation Solutions
We can display the variable of hello message as the key and return hello world as the value. We can add additional locales in our resource files, such as Japanese with Konnichiwa. Best practice is to store each resource as distinct locales in different files. There are many open source tools available, such as IAT next, GlobalizedJS, PolyGotJS, and Localize. Let's focus on tool agnostic solutions and high-level tips.
And then we can display that variable of hello message as the key and return hello world as the value. So here's this simple example in English and then what we can do is we can add additional locales in our resource files. So here's this locale of Japanese, you know, Konnichiwa. And best practice is to take each of these different resources as distinct locales and store them as different files in your list of files. And there's lots of different ways to do that. There's a lot of really great open source tools that are available. Here's a list of some that I recommend. IAT next, GlobalizedJS, PolyGotJS and Localize. There's a lot more that are excellent systems to basically wrap all of your strings in an object for translation. So I'm not gonna go into the deep guts of these individual implementations, but instead I wanna focus on more solutions that are tool agnostic and talk about sort of big high level tips that you can use across all of these different tools.
5. Testing, Number Formatting, and Layouts
Tip #3: Test in different languages and character sets using the pile of poo test. Tip #4: Wrap numbers, dates, times, and currencies in an object for internationalization. Tip #5: Build flexible layouts to accommodate translated text. Also, consider italics, bold, and line height sizing in different languages. Remember to avoid concatenating strings, handle sorting/filtering/searching in non-English characters, and use consistent locale code handling.
So my tip number five is to build flexible layouts to accommodate translated text. So different languages obviously have different lengths of text. The Adobe Spectrum Design System recommends using these rules. So, depending on the length of your English texts to allow from 300% to 30% expansion of text and to test in these different longer and shorter lengths of text is really important. And then also remember that things like italics and bold and line height sizing can really change in different languages and to consider user readability in complex Japanese or Chinese or Korean characters here. So those are my top five big tips to keep in mind, but there's also a lot of things that are really important in internationalization that I just don't have time to go over today. So some things just to keep in mind also are to avoid concatenating strings because the order of words will change in different languages. And then also to be sure to handle sorting, filtering, and searching in non-English characters. And then be sure to use consistent locale code handling. So our recommendation is to use BCP 47 to define your locales and make sure that wherever the locale is defined is consistent across the full app. And then remember that keyboards and keyboard shortcuts can vary in different regions. And so, be sure to keep that in mind and remember if you have a keyboard shortcut key to check the different regional layouts of keyboards.
6. Cultural Considerations and Language Variety
Left to right changes the layout of your UI for users who read left to right. Cultural considerations are important in internationalization. Having a variety of languages is culturally useful. Enabling different languages and having users navigate in their native tongues is innovative. Avoid assumptions and put the world in the World Wide Web.
And then, of course, left to right changes the layout of your full UI for users who are reading left to right. And so if you are supporting those users, make sure to keep that in mind.
On each of my slides, I have links to further documentation. So please feel free to go in and read that and learn more about how to handle all of these complicated cases. I just unfortunately don't have time to talk about all the amazing things I'd love to talk about today.
But let's move on to cultural considerations to keep in mind in the big picture of internationalization. So, you know, it is completely... If a user is searching for an image to represent a holiday, all of these different images are valid, you know, true, wonderful holidays across the world, and acknowledging different cultures is so important. Also food, you know, if a user is searching for delicious food, I think we would all agree that having a variety, you know, spice and sweet and savory, having all of these different choices is really great and important. And similar to having a variety of delicious food choices, having a variety of languages is culturally useful and important.
So this map represents, each dot represents a language that is currently at risk. So by enabling different languages and having different language users really be able to navigate our apps in their native mother tongues, we are truly innovating and building for the full world of humans across earth. So please join me, avoid your assumptions, broaden your mind and go out there and put the world in the World Wide Web. Thank you so much. Bye-bye. Thank you. Good-bye. Thank you. Good-bye. Bye. Bye. Thank you. Good-bye. Thank you. Bye-bye. Bye-bye. Bye. Thank you. Bye. Thank you.
Good-bye. Thank you. Bye-bye.
Good-bye. Thank you. Bye-bye. Good-bye. Bye-bye. Bye. Good-bye. Bye-bye. Good-bye. Bye. Bye. Bye-bye.
Thank you. Bye-bye. Good-bye. Good-bye. Good-bye.