Internacionalizando React

Rate this content
Bookmark

Aprender 100 idiomas diferentes es un desafío, pero diseñar tu aplicación de React para admitir 100 idiomas no tiene por qué serlo. A medida que tu aplicación web crece y alcanza una audiencia global, la funcionalidad multilingüe se vuelve cada vez más esencial. Entonces, ¿cómo diseñas tu código de manera que sea lo suficientemente flexible como para incluir a todos tus usuarios internacionales? En esta charla, exploraremos qué significa y cómo se ve construir una aplicación de React que admita internacionalización (i18n). Aprenderás varias estrategias diferentes para hacer que tu aplicación sea a prueba de locales con contextos de React y hooks personalizados.

29 min
14 May, 2021

Video Summary and Transcription

La charla aborda los desafíos de agregar y mantener nuevos idiomas en una aplicación de React y sugiere formas de facilitar el proceso. Define la internacionalización como el proceso de diseñar una aplicación para la localización y explica que la localización implica adaptar el contenido y la experiencia para una ubicación específica. El orador recomienda el uso de bibliotecas para la internacionalización y proporciona recursos para aprender más sobre el tema. La charla también aborda casos especiales y dificultades con dialectos o idiomas múltiples, procesos de traducción y bibliotecas de CSS de derecha a izquierda.

Available in English

1. Introducción y Experiencias de Aprendizaje de Idiomas

Short description:

Hola a todos, estoy muy emocionada de poder comenzar la edición remota de React Summit este año. Quiero compartir un poco sobre mis experiencias en el aprendizaje de diferentes idiomas. He aprendido que aprender idiomas es bastante difícil, pero como ingeniera de software, me pregunto si hay una forma de arquitectar nuestra aplicación de React para que agregar y mantener nuevos idiomas no sea tan complicado.

Hola a todos, estoy muy emocionada de poder comenzar la edición remota de React Summit este año. Muchas gracias por venir a mi charla, que trata sobre la internacionalización de aplicaciones React. Si no hemos tenido la oportunidad de conocernos, mi nombre es Daria Carraway. Actualmente soy ingeniera de software en Workday en Boulder, Colorado, en los Estados Unidos. Quiero compartir un poco sobre mis experiencias en el aprendizaje de diferentes idiomas.

Viene una foto embarazosa de mi infancia, así que no se burlen demasiado. Nací en Boulder, Colorado, donde aprendí inglés como primer idioma. Esta es la foto más joven que pude encontrar. También soy mitad china, así que desde muy joven aprendí mandarín. Esta es una foto de mí en la escuela china a la que iba todos los domingos con mi hermana durante muchos años. Esta foto me hace reír mucho.

Cuando llegué al sexto grado, tuve la oportunidad de elegir un idioma para aprender en la escuela. Elegí español. Así que desde el sexto hasta el duodécimo grado, estudié español y al final era bastante fluida. Esta es una foto de mí en séptimo grado, con frenillos y todo. Y algo que he aprendido a lo largo de mi vida, además de que tal vez no necesito flequillo. Además de eso, he aprendido que aprender idiomas es bastante difícil. No tengo una gran memoria, por lo que memorizar vocabulario o gramática en diferentes idiomas puede ser bastante difícil. Bueno, esta soy yo ahora y han pasado muchos, muchos, muchos años desde el duodécimo grado. Y para ser honesta, he perdido muchas de mis habilidades para hablar chino y español. Los entiendo bastante bien, pero mi capacidad para hablarlos no es muy buena y mi capacidad para leer chino es de uno sobre diez. Y así he aprendido, especialmente a medida que envejezco, que mantener los idiomas incluso después de pasar todo ese tiempo aprendiéndolos también es bastante difícil. No tengo muchas oportunidades donde estoy para practicar español o chino así que se quedaron almacenados en la parte trasera de mi cerebro a la que no se puede acceder fácilmente. Al menos eso es lo que se siente. Pero como ingeniera de software, encuentro paralelismos entre mi vida y mi código porque eso es totalmente normal. Por primera vez en mi career estoy en un equipo que tiene que admitir varios idiomas y localizaciones en nuestra aplicación y me pregunto si, aunque los idiomas son difíciles para mí de aprender en la vida, hay una forma de arquitectar nuestra aplicación de react para que agregar y mantener nuevos idiomas no sea tan complicado. Después de todo, siento que enseñar a nuestras aplicaciones a manejar varios idiomas debería ser más fácil que enseñar a nuestros cerebros. Al menos esa es mi teoría. Pero antes de explorar esta teoría, quiero nivelar el vocabulario. El primer término que probablemente hayas visto es internationalization o I18N.

2. Internacionalización y Localización

Short description:

La abreviatura es así porque hay 18 letras entre la I y la N en la palabra internacionalización y supongo que es bastante largo de decir. Pero me gusta pensar en la internacionalización como el proceso de arquitecturar tu aplicación para que cuando ocurra la localización, las cosas simplemente funcionen. La localización es el proceso de adaptar el contenido y la experiencia de tu aplicación para una ubicación específica. Y hay muchos elementos de la localización. Diferentes aplicaciones tendrán que preocuparse por diferentes cosas. Si tienes que admitir la internacionalización, te sugiero que investigues algunas de estas bibliotecas para ver si se adaptan a tus necesidades.

La abreviatura es así porque hay 18 letras entre la I y la N en la palabra internationalization y supongo que es bastante largo de decir. Hay muchas definiciones confusas por ahí para internationalization. Encontré muchas que me resultaron confusas mientras investigaba para esta charla. Pero creo que es así porque internationalization puede significar muchas cosas diferentes para diferentes personas, dependiendo de lo que haga tu aplicación, en qué industria te encuentres, qué tipo de standards debas cumplir.

Pero me gusta pensar en la internationalization como el proceso de arquitecturar tu aplicación para que cuando ocurra la localización, las cosas simplemente funcionen. Entonces, ¿qué es la localización o L10N? La localización es el proceso de adaptar realmente el contenido y la experiencia de tu aplicación para una ubicación específica. Así que la internationalization es como arquitecturarla, y luego la localización es cambiarla. Teóricamente, si has internacionalizado tu aplicación correctamente, cuando ocurra la localización, no deberías tener que hacer mucho.

Y hay muchos elementos de la localización. Esta lista no es exhaustiva. Y, como dije, diferentes aplicaciones tendrán que preocuparse por diferentes cosas. Es posible que debas implementar algunos o todos estos elementos. Realmente depende. Y si tienes que implementar todos o algunos de esos elementos, hay algunas bibliotecas populares de React que están destinadas a ser esa solución arquitectónica de internationalization. Si tienes que admitir la internationalization, te sugiero que investigues algunas de estas bibliotecas para ver si se adaptan a tus necesidades. Pero pensé que sería más divertido en esta charla construir algunas de esas internationalization ... ¿Eso está ... Está. Sí. Sí. Esa es una buena pregunta. En realidad, no estoy seguro si hay, como, una preferencia acordada. Creo que podría depender de ti. Las APIs, creo, son un poco diferentes. Por ejemplo, creo que en el objeto internacional, pasas la cadena de formato cuando lo llamas. Y en toLocaleString, creo que puedes establecer la ubicación una vez y luego siempre usarla después de eso. Así que creo que las APIs son un poco diferentes. También sé que el objeto internacional es un poco más nuevo. Entonces, si estás admitiendo versiones anteriores de IE, por ejemplo, no creo que esté disponible allí. Genial.

3. Edge Cases, Translation, and Resources

Short description:

¿Existen casos especiales o dificultades únicas para países con múltiples dialectos o idiomas? ¿Cómo permites que los traductores traduzcan las cadenas? ¿Podrías repetir las bibliotecas de CSS de derecha a izquierda que te recomendaron? ¿Tienes alguna guía o sitio web, recursos para aprender más sobre internacionalización y cómo integrarlos en tus aplicaciones? Muchas gracias una vez más, Pete. Fue una charla muy agradable de ver.

Otra pregunta es, ¿existen casos especiales o dificultades únicas para países que tienen múltiples dialectos o idiomas? Digamos, por ejemplo, en España, podrías encontrarte con el vasco o el catalán. Sí, es algo de lo que hay que estar consciente. Hay muchos países que tienen diferentes idiomas o incluso escrituras dentro de diferentes idiomas. Pero generalmente, si los defines en tu cadena de localización y el usuario también puede establecer sus preferencias ya sea en su navegador o tal vez si estás trabajando en un sitio web donde las personas crean un inicio de sesión, tal vez puedas hacer que establezcan sus preferencias allí, deberías poder crear una cadena de localización con el país, el idioma y la escritura, y algunas de esas otras propiedades.

De acuerdo. Otra pregunta es, ¿cómo permites que los traductores traduzcan las cadenas? Esa es una buena pregunta. Creo que eso depende completamente y es diferente para cada organización y tal vez para qué empresa trabajas. Si no trabajas para una gran empresa, es posible que uses algo como la API de traducción de Google para traducir en masa algunas de esas cadenas. La empresa para la que trabajo tiene un equipo de traductores especializados en muchos idiomas diferentes, por lo que realmente van y traducen manualmente muchas de las cadenas además de utilizar algunas APIs de machine learning para ayudar también. Creo que depende de cuánta infraestructura de traducción tenga tu empresa y cuánto esté dispuesta a invertir en ella. Wow, el machine learning suena increíble. Tengo que decirte eso. Otra pregunta es, ¿podrías repetir las bibliotecas de CSS de derecha a izquierda que te recomendaron? Recomendar. Puedo. No fue una lista exhaustiva en absoluto, y estas diapositivas se publicarán y podré compartirlas. Pero la que estoy usando es RTL-CSSJS, esa es la que te permite usar objetos de JavaScript en CSS en JS. Otra es RTL-CSS, es como una utilidad normal de CSS. Y también estaba JSS-RTL, que es para cuando escribes CSS en JS con JSS. Hay muchas S's. Lo siento. Sí, hay muchas S's. La última pregunta para ti es, ¿tienes alguna guía o sitio web, recursos para aprender más sobre la internacionalización y cómo integrarla en tus aplicaciones? Sí, tengo una página en GitHub que puedo compartir, puedo tuitearla, que tiene los recursos de toda la investigación que hice para esta charla, y todo lo que mencioné en esta charla también está enlazado allí. El sitio web de Material design tiene una especificación muy buena para los idiomas de derecha a izquierda que encontré increíblemente útil. Es muy detallado, habla sobre iconos específicos y todo lo relacionado con los idiomas de derecha a izquierda, así que definitivamente recomendaría ese recurso también.

Sí, muchas gracias una vez más, Pete. Fue una charla muy agradable de ver. Diste tantas buenas notas sobre la internacionalización, la localización y también ver a tanta gente discutiendo sobre idiomas. Es realmente importante y da vida a la aplicación en general. ¿Hay algo en particular que te gustaría agregar? No, creo que muchas gracias por tenerme aquí. Espero que este sea un tema interesante para mucha gente. Parece que mucha gente habla 3-4 idiomas, así que esto podría ser relevante para muchas personas, lo cual es genial. Muchas gracias, Daria, por darnos una charla realmente genial y venir aquí. Muchas gracias. Por supuesto. Gracias por tenerme. ¡Adiós, adiós!

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

React Advanced Conference 2022React Advanced Conference 2022
25 min
A Guide to React Rendering Behavior
Top Content
React is a library for "rendering" UI from components, but many users find themselves confused about how React rendering actually works. What do terms like "rendering", "reconciliation", "Fibers", and "committing" actually mean? When do renders happen? How does Context affect rendering, and how do libraries like Redux cause updates? In this talk, we'll clear up the confusion and provide a solid foundation for understanding when, why, and how React renders. We'll look at: - What "rendering" actually is - How React queues renders and the standard rendering behavior - How keys and component types are used in rendering - Techniques for optimizing render performance - How context usage affects rendering behavior| - How external libraries tie into React rendering
React Summit Remote Edition 2021React Summit Remote Edition 2021
33 min
Building Better Websites with Remix
Top Content
Remix is a new web framework from the creators of React Router that helps you build better, faster websites through a solid understanding of web fundamentals. Remix takes care of the heavy lifting like server rendering, code splitting, prefetching, and navigation and leaves you with the fun part: building something awesome!
React Advanced Conference 2023React Advanced Conference 2023
33 min
React Compiler - Understanding Idiomatic React (React Forget)
Top Content
React provides a contract to developers- uphold certain rules, and React can efficiently and correctly update the UI. In this talk we'll explore these rules in depth, understanding the reasoning behind them and how they unlock new directions such as automatic memoization. 
React Advanced Conference 2022React Advanced Conference 2022
30 min
Using useEffect Effectively
Top Content
Can useEffect affect your codebase negatively? From fetching data to fighting with imperative APIs, side effects are one of the biggest sources of frustration in web app development. And let’s be honest, putting everything in useEffect hooks doesn’t help much. In this talk, we'll demystify the useEffect hook and get a better understanding of when (and when not) to use it, as well as discover how declarative effects can make effect management more maintainable in even the most complex React apps.
React Summit 2022React Summit 2022
20 min
Routing in React 18 and Beyond
Top Content
Concurrent React and Server Components are changing the way we think about routing, rendering, and fetching in web applications. Next.js recently shared part of its vision to help developers adopt these new React features and take advantage of the benefits they unlock.In this talk, we’ll explore the past, present and future of routing in front-end applications and discuss how new features in React and Next.js can help us architect more performant and feature-rich applications.
React Advanced Conference 2021React Advanced Conference 2021
27 min
(Easier) Interactive Data Visualization in React
Top Content
If you’re building a dashboard, analytics platform, or any web app where you need to give your users insight into their data, you need beautiful, custom, interactive data visualizations in your React app. But building visualizations hand with a low-level library like D3 can be a huge headache, involving lots of wheel-reinventing. In this talk, we’ll see how data viz development can get so much easier thanks to tools like Plot, a high-level dataviz library for quick & easy charting, and Observable, a reactive dataviz prototyping environment, both from the creator of D3. Through live coding examples we’ll explore how React refs let us delegate DOM manipulation for our data visualizations, and how Observable’s embedding functionality lets us easily repurpose community-built visualizations for our own data & use cases. By the end of this talk we’ll know how to get a beautiful, customized, interactive data visualization into our apps with a fraction of the time & effort!

Workshops on related topic

React Summit 2023React Summit 2023
170 min
React Performance Debugging Masterclass
Top Content
Featured WorkshopFree
Ivan’s first attempts at performance debugging were chaotic. He would see a slow interaction, try a random optimization, see that it didn't help, and keep trying other optimizations until he found the right one (or gave up).
Back then, Ivan didn’t know how to use performance devtools well. He would do a recording in Chrome DevTools or React Profiler, poke around it, try clicking random things, and then close it in frustration a few minutes later. Now, Ivan knows exactly where and what to look for. And in this workshop, Ivan will teach you that too.
Here’s how this is going to work. We’ll take a slow app → debug it (using tools like Chrome DevTools, React Profiler, and why-did-you-render) → pinpoint the bottleneck → and then repeat, several times more. We won’t talk about the solutions (in 90% of the cases, it’s just the ol’ regular useMemo() or memo()). But we’ll talk about everything that comes before – and learn how to analyze any React performance problem, step by step.
(Note: This workshop is best suited for engineers who are already familiar with how useMemo() and memo() work – but want to get better at using the performance tools around React. Also, we’ll be covering interaction performance, not load speed, so you won’t hear a word about Lighthouse 🤐)
React Advanced Conference 2021React Advanced Conference 2021
132 min
Concurrent Rendering Adventures in React 18
Top Content
Featured WorkshopFree
With the release of React 18 we finally get the long awaited concurrent rendering. But how is that going to affect your application? What are the benefits of concurrent rendering in React? What do you need to do to switch to concurrent rendering when you upgrade to React 18? And what if you don’t want or can’t use concurrent rendering yet?

There are some behavior changes you need to be aware of! In this workshop we will cover all of those subjects and more.

Join me with your laptop in this interactive workshop. You will see how easy it is to switch to concurrent rendering in your React application. You will learn all about concurrent rendering, SuspenseList, the startTransition API and more.
React Summit Remote Edition 2021React Summit Remote Edition 2021
177 min
React Hooks Tips Only the Pros Know
Top Content
Featured Workshop
The addition of the hooks API to React was quite a major change. Before hooks most components had to be class based. Now, with hooks, these are often much simpler functional components. Hooks can be really simple to use. Almost deceptively simple. Because there are still plenty of ways you can mess up with hooks. And it often turns out there are many ways where you can improve your components a better understanding of how each React hook can be used.You will learn all about the pros and cons of the various hooks. You will learn when to use useState() versus useReducer(). We will look at using useContext() efficiently. You will see when to use useLayoutEffect() and when useEffect() is better.
React Advanced Conference 2021React Advanced Conference 2021
174 min
React, TypeScript, and TDD
Top Content
Featured WorkshopFree
ReactJS is wildly popular and thus wildly supported. TypeScript is increasingly popular, and thus increasingly supported.

The two together? Not as much. Given that they both change quickly, it's hard to find accurate learning materials.

React+TypeScript, with JetBrains IDEs? That three-part combination is the topic of this series. We'll show a little about a lot. Meaning, the key steps to getting productive, in the IDE, for React projects using TypeScript. Along the way we'll show test-driven development and emphasize tips-and-tricks in the IDE.
React Advanced Conference 2021React Advanced Conference 2021
145 min
Web3 Workshop - Building Your First Dapp
Top Content
Featured WorkshopFree
In this workshop, you'll learn how to build your first full stack dapp on the Ethereum blockchain, reading and writing data to the network, and connecting a front end application to the contract you've deployed. By the end of the workshop, you'll understand how to set up a full stack development environment, run a local node, and interact with any smart contract using React, HardHat, and Ethers.js.
React Summit 2023React Summit 2023
151 min
Designing Effective Tests With React Testing Library
Top Content
Featured Workshop
React Testing Library is a great framework for React component tests because there are a lot of questions it answers for you, so you don’t need to worry about those questions. But that doesn’t mean testing is easy. There are still a lot of questions you have to figure out for yourself: How many component tests should you write vs end-to-end tests or lower-level unit tests? How can you test a certain line of code that is tricky to test? And what in the world are you supposed to do about that persistent act() warning?
In this three-hour workshop we’ll introduce React Testing Library along with a mental model for how to think about designing your component tests. This mental model will help you see how to test each bit of logic, whether or not to mock dependencies, and will help improve the design of your components. You’ll walk away with the tools, techniques, and principles you need to implement low-cost, high-value component tests.
Table of contents- The different kinds of React application tests, and where component tests fit in- A mental model for thinking about the inputs and outputs of the components you test- Options for selecting DOM elements to verify and interact with them- The value of mocks and why they shouldn’t be avoided- The challenges with asynchrony in RTL tests and how to handle them
Prerequisites- Familiarity with building applications with React- Basic experience writing automated tests with Jest or another unit testing framework- You do not need any experience with React Testing Library- Machine setup: Node LTS, Yarn