التدويل (i18n)
صمّم وطوّر مكوّنات تتكيف بسلاسة مع اللغات والثقافات والتفضيلات الإقليمية المختلفة
التدويل (i18n) درس مجاني في Design Systems & Component Libraries على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Design Systems & Component Libraries، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Design Systems & Component Libraries 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Intro to Internationalization
Internationalization (i18n) is the process of designing and developing your components and applications so they can be easily adapted to different languages, regional differences, and technical requirements of a target country, region, or culture.
Think of it as preparing your product for the world! It's not just about translation, but about making sure your UI works everywhere.
Understanding Locale
A locale is a set of parameters that defines the user's language, country, and any special variant preferences that should be used to present information.
en-US: English (United States)fr-CA: French (Canada)es-MX: Spanish (Mexico)
These codes help your system know how to format things correctly.
Translating Text with Keys
Instead of hardcoding text directly into your components, you use translation keys. These keys are like placeholders.
For example, instead of "Hello", you might use a key like "greeting.hello". Your application then looks up the actual translated text for that key based on the user's locale.
Code: Dynamic Greetings
Here's a conceptual example of how translation keys work. The getTranslatedString function would fetch the correct text based on the locale from a translation file.
public class Greeter {
public static String getTranslatedString(String key, String locale) {
if (locale.equals("en-US")) {
if (key.equals("greeting.hello")) return "Hello!";
if (key.equals("action.welcome")) return "Welcome!";
} else if (locale.equals("es-MX")) {
if (key.equals("greeting.hello")) return "¡Hola!";
if (key.equals("action.welcome")) return "¡Bienvenido!";
}
return "Translation missing for " + key;
}
public static void main(String[] args) {
String userLocale = "es-MX"; // Imagine this comes from user settings
System.out.println(getTranslatedString("greeting.hello", userLocale));
userLocale = "en-US";
System.out.println(getTranslatedString("action.welcome", userLocale));
}
}Adapting Dates & Times
Dates and times are presented differently around the world. For example, "03/04/2023" means March 4th in the US but April 3rd in many other countries.
Your design system components should use locale-aware formatting utilities to display dates and times correctly for the user's region.
Formatting Numbers & Money
Number formats also vary. The decimal separator can be a dot (.) or a comma (,).
- US:
1,234.56 - Germany:
1.234,56
Currencies need their symbol and correct placement (e.g., $100.00 vs. 100,00 €).
Handling Text Direction
Most languages read from Left-to-Right (LTR). However, languages like Arabic, Hebrew, and Farsi read from Right-to-Left (RTL).
For RTL languages, the entire layout of your components needs to be mirrored. This includes text alignment, icon placement, and the flow of elements.
Cultural Imagery
Sometimes, images, icons, or even videos need to change based on the user's culture or region.
A picture that resonates well in one country might be confusing or even offensive in another. Your design system should support managing and delivering locale-specific assets.
Design Systems for i18n
A design system is key for good i18n because it provides:
- Centralized Translations: All strings managed in one place.
- Adaptable Components: Components designed to handle varying text lengths and RTL layouts.
- Consistent Formatting: Standardized date, time, and number formatting.
This ensures a consistent global experience.
i18n Quick Check
You're building a button component for your design system. Which of these is the BEST practice for displaying the button's text to support internationalization?
i18n Recap
We've explored Internationalization (i18n), understanding that it's more than just translation.
- We learned about locales and how they define regional preferences.
- We saw how to use translation keys for dynamic text.
- We discussed adapting dates, numbers, currencies, and layouts (RTL).
- And finally, how a design system provides a powerful foundation for building globally-ready components.
Keep these principles in mind for truly global products!
الأسئلة الشائعة
هل درس «التدويل (i18n)» مجاني؟
نعم — نص درس «التدويل (i18n)» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Design Systems & Component Libraries، انتقل إلى CoddyKit PRO. تتضمن دورة Design Systems & Component Libraries 4 دروس في المجموع.
ماذا ستتعلم في «التدويل (i18n)»؟
صمّم وطوّر مكوّنات تتكيف بسلاسة مع اللغات والثقافات والتفضيلات الإقليمية المختلفة تتمرن على Design Systems & Component Libraries مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Design Systems & Component Libraries؟
لا تُشترط خبرة سابقة. Design Systems & Component Libraries على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.
كم من الوقت يستغرق درس «التدويل (i18n)»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Design Systems & Component Libraries هذا؟
نعم. كل درس في Design Systems & Component Libraries يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.