How I Support More Than 100 Languages in My React app...and You Can Too!

Rate this content
Bookmark
SlidesGithub

Does your React app serve a global audience, but is only available in English? Let's change that. In this talk, I'll show you how i18n can become an automatic part of your CI/CD workflow, enabling your team, regardless of size, to deliver your React app in over 100 different languages without any extra effort.

This talk has been presented at React Summit US 2024, check out the latest edition of this React Conference.

FAQ

Richard Kerrigan is a speaker discussing how to add multilingual support to React apps. He works at Microsoft but is not affiliated with the Azure AI team.

Azure AI Translator is highlighted, but similar solutions can be built using AWS, GCP, or any cloud service provider offering document translation services.

Content stored as JSON can be translated at runtime using an API, while HTML and Markdown files can be translated during the CICD process.

Key features include support for over 100 languages, a generous free tier of up to 2 million characters per month, Neural Machine Translation for accuracy, and custom glossaries for specific terminology.

The main topic is about adding multilingual support to React apps, particularly focusing on automatically translating dynamic content using cloud services.

The solution focuses on automatically translating dynamic content such as blog posts created by content creators or end users.

Limitations include inability to handle MVX or JSX TSX files directly, horizontal text output only, and the need for manual validation of translations.

Multilingual support makes web apps more inclusive and convenient for users who speak different languages, enhancing user experience and reach.

It uses Neural Machine Translation, which considers full sentences for more contextually accurate translations, and allows the use of custom glossaries.

Translation can be integrated by using Azure Blob Storage for file storage, Azure Function apps for orchestration, and incorporating translations into the CICD pipeline for HTML and Markdown content.

Richard Carrigan
Richard Carrigan
28 min
22 Nov, 2024

Comments

Sign in or register to post your comment.
Video Summary and Transcription
I'm Richard Kerrigan and I'll show you how to add multilingual support to your React apps. We need a way to support other languages on our websites and web apps without affecting team productivity. We'll explore a low-cost solution using AI and automation. When my team started tackling this problem, we looked at Azure and found the Azure AI Translator service, which offers both ad-hoc text translation and document translation. Key features include language support for over 100 languages and dialects, a generous free tier, Neural Machine Translation for accuracy, and the ability to use custom glossaries. Designing workflow for translating JSON content at runtime or incorporating translation process into CICD workflow for HTML or Markdown files. Exploring how to translate HTML files within a CICD pipeline. Translation service and storage account setup. Function app building and deployment. Configuring translation to Spanish with a glossary in CSV format for file translation. Sending a request to the translator and receiving the translated file. Discussing the problem of websites not offering content in additional languages. Highlighting the benefits of Azure AI Translator and its alternatives. Showcasing different versions of the app for translating JSON, HTML, and markdown content. Checking the progress of the workflow, deployment of Azure resources and function, and translation of markdown files. Quick explanation of infrastructure as code and deployment options. Changing languages shows translated title and excerpt while maintaining original formatting.

1. Introduction and Problem Statement

Short description:

I'm Richard Kerrigan and I'll show you how to add multilingual support to your React apps. We need a way to support other languages on our websites and web apps without affecting team productivity. We'll explore a low-cost solution using AI and automation.

I'm Richard Kerrigan and I'm thrilled to be here today to show you how you can add multilingual support into your React apps. Before we dive into today's topic, let me do some quick housekeeping. Item number 1. Although I do work at Microsoft, I'm in no way affiliated with the Azure AI team, nor am I looking to convince you to adopt Azure as your cloud service provider. As you'll see by the end of this talk, my goal is to demonstrate one possible solution for automatically translating website web app content into other languages and dialects. But you could absolutely build something similar using AWS, GCP, or another cloud service provider that provides a document translation service.

Item number 2. There are already libraries such as React, IATN that allow you to translate static content such as your homepage, header, footer, etc. into other languages using the translations you provide. The solutions I'll be presenting to you today are for automatically translating the dynamic content, such as blog posts created by your team's content creators or even by end users.

Alright, so with those housekeeping items out of the way, let's dive in. First, let's clearly state the problem we're trying to solve. The problem we're trying to solve is that most websites, web apps, only publish content in one language, which is not convenient for users and is not inclusive for people for whom that language is not their primary language. In other words, we need a way to support other languages and dialects on our websites and web apps, without adversely affecting our team's productivity. Now there are various ways we could approach solving the problem, depending on the resources we have available to us. But for the sake of this talk, let's assume that we don't have much budget to dedicate to this feature, nor do we have a team that can translate content for us. So our solution must be low cost and require human interaction only to validate the results. This is a fantastic use case for AI and automation.

2. Azure AI Translator and Workflow Design

Short description:

When my team started tackling this problem, we looked at Azure and found the Azure AI Translator service, which offers both ad-hoc text translation and document translation. Key features include language support for over 100 languages and dialects, a generous free tier, Neural Machine Translation for accuracy, and the ability to use custom glossaries. Limitations include handling specific file types and formatting for certain languages. Depending on how the content is stored, there are three options for translation, with an example provided for translating JSON content.

When my team started tackling this problem, for obvious reasons, we looked at Azure first. Through that research, I found the Azure AI Translator service. This service not only allows for ad-hoc text translation, where you send text directly through the translator and it returns the translated text as JSON, but it also offers document translation, which takes as input one or more files from a blob storage container, translates them, and outputs the translated files into a different blob storage container.

Also, Azure AI Translator service has a few key features that ultimately convinced us that it was the right fit for our needs. The first key feature that was important to us was language support. With over 100 different languages and dialects supported, even including Klingon, Azure AI Translator was definitely the right choice for us. The next key feature for us was cost. Azure AI Translator has a generous free tier of up to 2 million characters translated per month. Another important feature is accuracy. Azure AI Translator uses Neural Machine Translation, or NMT, which takes into context the full sentence and produces more fluid and human-translated-looking translations. The final key feature for us is the ability to use custom glossaries to tweak the translation process.

It's not all sunshine and rainbows, though, so I wanted to also take a moment to call out some of the limitations of Azure AI Translator. Although the service can handle many different file types, it currently isn't able to handle MVX or JSX TSX, so your content will need to be sourced separately from these files in order to be translated. Another limitation is that all translation responses are returned as horizontal, left-to-right, or right-to-left text, so you may need to add rendering logic if you want to display content in a vertical format for applicable languages. Finally, as with any AI implementation, you'll still want to validate the results before deploying them abroad, and you may find that additional tweaking may be needed, which would also require a redeployment and revalidation.

Depending on how the content is stored, there are essentially three options for how to translate it. If your content is stored as JSON, you would most likely want to translate the content during runtime using the Azure Translator API. Here's an example of how you can achieve this. As you can see, we're taking just the pieces of data that need to be translated, namely the title, excerpt, and the content, and sending each piece through the translator. Then, once we have all of the translated content, we're sending it as a response.

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

Scaling Up with Remix and Micro Frontends
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Scaling Up with Remix and Micro Frontends
Top Content
This talk discusses the usage of Microfrontends in Remix and introduces the Tiny Frontend library. Kazoo, a used car buying platform, follows a domain-driven design approach and encountered issues with granular slicing. Tiny Frontend aims to solve the slicing problem and promotes type safety and compatibility of shared dependencies. The speaker demonstrates how Tiny Frontend works with server-side rendering and how Remix can consume and update components without redeploying the app. The talk also explores the usage of micro frontends and the future support for Webpack Module Federation in Remix.
Understanding React’s Fiber Architecture
React Advanced 2022React Advanced 2022
29 min
Understanding React’s Fiber Architecture
Top Content
This Talk explores React's internal jargon, specifically fiber, which is an internal unit of work for rendering and committing. Fibers facilitate efficient updates to elements and play a crucial role in the reconciliation process. The work loop, complete work, and commit phase are essential steps in the rendering process. Understanding React's internals can help with optimizing code and pull request reviews. React 18 introduces the work loop sync and async functions for concurrent features and prioritization. Fiber brings benefits like async rendering and the ability to discard work-in-progress trees, improving user experience.
Full Stack Components
Remix Conf Europe 2022Remix Conf Europe 2022
37 min
Full Stack Components
Top Content
RemixConf EU discussed full stack components and their benefits, such as marrying the backend and UI in the same file. The talk demonstrated the implementation of a combo box with search functionality using Remix and the Downshift library. It also highlighted the ease of creating resource routes in Remix and the importance of code organization and maintainability in full stack components. The speaker expressed gratitude towards the audience and discussed the future of Remix, including its acquisition by Shopify and the potential for collaboration with Hydrogen.
The Eternal Sunshine of the Zero Build Pipeline
React Finland 2021React Finland 2021
36 min
The Eternal Sunshine of the Zero Build Pipeline
For many years, we have migrated all our devtools to Node.js for the sake of simplicity: a common language (JS/TS), a large ecosystem (NPM), and a powerful engine. In the meantime, we moved a lot of computation tasks to the client-side thanks to PWA and JavaScript Hegemony.
So we made Webapps for years, developing with awesome reactive frameworks and bundling a lot of dependencies. We progressively moved from our simplicity to complex apps toolchains. We've become the new Java-like ecosystem. It sucks.
It's 2021, we've got a lot of new technologies to sustain our Users eXperience. It's time to have a break and rethink our tools rather than going faster and faster in the same direction. It's time to redesign the Developer eXperience. It's time for a bundle-free dev environment. It's time to embrace a new frontend building philosophy, still with our lovely JavaScript.
Introducing Snowpack, Vite, Astro, and other Bare Modules tools concepts!
Composition vs Configuration: How to Build Flexible, Resilient and Future-proof Components
React Summit 2022React Summit 2022
17 min
Composition vs Configuration: How to Build Flexible, Resilient and Future-proof Components
Top Content
Today's Talk discusses building flexible, resilient, and future-proof React components using composition and configuration approaches. The composition approach allows for flexibility without excessive conditional logic by using multiple components and passing props. The context API can be used for variant styling, allowing for appropriate styling and class specification. Adding variants and icons is made easy by consuming the variant context. The composition and configuration approaches can be combined for the best of both worlds.
Remix Architecture Patterns
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Remix Architecture Patterns
Top Content
This Talk introduces the Remix architecture patterns for web applications, with over 50% of participants using Remix professionally. The migration from single page applications to Remix involves step-by-step refactoring and offers flexibility in deployment options. Scalability can be achieved by distributing the database layer and implementing application caching. The backend for frontend pattern simplifies data fetching, and Remix provides real-time capabilities for collaborative features through WebSocket servers and Server-SendEvents.

Workshops on related topic

AI on Demand: Serverless AI
DevOps.js Conf 2024DevOps.js Conf 2024
163 min
AI on Demand: Serverless AI
Top Content
Featured WorkshopFree
Nathan Disidore
Nathan Disidore
In this workshop, we discuss the merits of serverless architecture and how it can be applied to the AI space. We'll explore options around building serverless RAG applications for a more lambda-esque approach to AI. Next, we'll get hands on and build a sample CRUD app that allows you to store information and query it using an LLM with Workers AI, Vectorize, D1, and Cloudflare Workers.
High-performance Next.js
React Summit 2022React Summit 2022
50 min
High-performance Next.js
Workshop
Michele Riva
Michele Riva
Next.js is a compelling framework that makes many tasks effortless by providing many out-of-the-box solutions. But as soon as our app needs to scale, it is essential to maintain high performance without compromising maintenance and server costs. In this workshop, we will see how to analyze Next.js performances, resources usage, how to scale it, and how to make the right decisions while writing the application architecture.