VibeKoding / Ensiklopedia Β· Fondasi KuatEnsiklopedia Β· Fondasi Kuat / The Hidden Dimensions of Web: Internationalization and AccessibilityThe Hidden Dimensions of Web: Internationalization and Accessibility
VK

The Hidden Dimensions of Web: Internationalization and AccessibilityThe Hidden Dimensions of Web: Internationalization and Accessibility

πŸ“š Ensiklopedia Β· Fondasi KuatEnsiklopedia Β· Fondasi Kuat 🌏 Dual Bahasa (ID / EN) ⚑ VibeKoding Native

Ensiklopedia VibeKoding: The Hidden Dimensions of Web: Internationalization and Accessibility.Ensiklopedia VibeKoding: The Hidden Dimensions of Web: Internationalization and Accessibility.

πŸ’‘ Tips PraktisπŸ’‘ Pro Tip

What is i18n and where does it come from? In the frontend and software engineering world, what we commonly call i18n actually refers to multilingual support (Internationalization). Because there happen to be 18 letters between the first letter i and the last letter n of this English word, the industry coined this specific abbreviation for convenience. Similarly, Accessibility has 11 letters between the first letter a and the last letter y, so it is collectively referred to as a11y. Behind the browser rendering colorful web pages, there are actually two "hidden threads" running in parallel that are often invisible to the naked eye: When you type a URL to visit a web page, how does the browser know whether to show you Chinese or German (i.e., the i18n multilingual process)? While the browser parses HTML into a DOM tree and prepares to draw, how does it also build another "braille tree" specifically for visually impaired users (i.e., the a11y accessibility process)? In this chapter, we will return to the micro-level process of "web page access and rendering" to decode how browsers and frontend engineering silently work in these two areas that embody technological humanistic care.What is i18n and where does it come from? In the frontend and software engineering world, what we commonly call i18n actually refers to multilingual support (Internationalization). Because there happen to be 18 letters between the first letter i and the last letter n of this English word, the industry coined this specific abbreviation for convenience. Similarly, Accessibility has 11 letters between the first letter a and the last letter y, so it is collectively referred to as a11y. Behind the browser rendering colorful web pages, there are actually two "hidden threads" running in parallel that are often invisible to the naked eye: When you type a URL to visit a web page, how does the browser know whether to show you Chinese or German (i.e., the i18n multilingual process)? While the browser parses HTML into a DOM tree and prepares to draw, how does it also build another "braille tree" specifically for visually impaired users (i.e., the a11y accessibility process)? In this chapter, we will return to the micro-level process of "web page access and rendering" to decode how browsers and frontend engineering silently work in these two areas that embody technological humanistic care.

------

1. Language Negotiation in Web Page Access (i18n)1. Language Negotiation in Web Page Access (i18n)

When we type a URL and press Enter, the browser typically silently includes a header in the HTTP request sent to the server: Accept-Language.When we type a URL and press Enter, the browser typically silently includes a header in the HTTP request sent to the server: Accept-Language.

This is like placing an order at a restaurant β€” the browser privately tells the server: "My user prefers Simplified Chinese first; if that's not available, English will do." This is the initial negotiation during web access.This is like placing an order at a restaurant β€” the browser privately tells the server: "My user prefers Simplified Chinese first; if that's not available, English will do." This is the initial negotiation during web access.

1.1 Frontend Engineering and Dictionary Replacement1.1 Frontend Engineering and Dictionary Replacement

In modern frontend frameworks, the page skeleton is usually generated dynamically by JavaScript on the client side. At this stage, the frontend application actively reads the browser's locale preferences (for example, through the navigator.language API), and then fetches the corresponding language "dictionary pack (JSON)" from the server on demand β€” displaying "Confirm" when encountering English, and the corresponding translation for other languages.In modern frontend frameworks, the page skeleton is usually generated dynamically by JavaScript on the client side. At this stage, the frontend application actively reads the browser's locale preferences (for example, through the navigator.language API), and then fetches the corresponding language "dictionary pack (JSON)" from the server on demand β€” displaying "Confirm" when encountering English, and the corresponding translation for other languages.

1.2 The Constraint of Typography: Text Length and RTL Mirroring1.2 The Constraint of Typography: Text Length and RTL Mirroring

But beyond dictionary replacement, true internationalization faces abyss-level challenges during the browser Layout phase.But beyond dictionary replacement, true internationalization faces abyss-level challenges during the browser Layout phase.

Different languages expressing the same meaning may require vastly different lengths of text. For example, German often concatenates multiple word roots into extremely long words. If we use absolute fixed widths when writing CSS, switching to German can easily cause text to overflow its container. Therefore, browsers encourage using the Flexible Box Model (Flexbox) to adapt to different text volumes.Different languages expressing the same meaning may require vastly different lengths of text. For example, German often concatenates multiple word roots into extremely long words. If we use absolute fixed widths when writing CSS, switching to German can easily cause text to overflow its container. Therefore, browsers encourage using the Flexible Box Model (Flexbox) to adapt to different text volumes.

An even more钠覆 challenge lies in reading direction. Languages such as Arabic and Hebrew are read from right to left (Right-to-Left, abbreviated as RTL).An even more钠覆 challenge lies in reading direction. Languages such as Arabic and Hebrew are read from right to left (Right-to-Left, abbreviated as RTL).

When a page switches to such languages, it's not just the text direction that needs to change β€” the browser engine also needs to horizontally mirror the entire web page's content blocks! The browser provides the native dir="rtl" attribute for this purpose. When writing CSS, we should avoid using absolute directional terms β€” for example, using Flexbox's justify-content: flex-start instead of hard-coded margin-left, so that the browser can automatically mirror the layout when the locale changes.When a page switches to such languages, it's not just the text direction that needs to change β€” the browser engine also needs to horizontally mirror the entire web page's content blocks! The browser provides the native dir="rtl" attribute for this purpose. When writing CSS, we should avoid using absolute directional terms β€” for example, using Flexbox's justify-content: flex-start instead of hard-coded margin-left, so that the browser can automatically mirror the layout when the locale changes.

1.3 Goodbye Regex: Embrace the Browser's Intl Standard1.3 Goodbye Regex: Embrace the Browser's Intl Standard

Beyond interface layout, the browser has a powerful built-in "localization formatting engine" at its core. For the same number 1200.5, Americans expect to see $1,200.50, while many European countries prefer using commas as decimal points: € 1.200,50. Date formats vary even more wildly.Beyond interface layout, the browser has a powerful built-in "localization formatting engine" at its core. For the same number 1200.5, Americans expect to see $1,200.50, while many European countries prefer using commas as decimal points: € 1.200,50. Date formats vary even more wildly.

Modern browsers expose the Intl core object (such as Intl.DateTimeFormat and Intl.NumberFormat). By using this API, we only need to specify the current locale code in our code, and the browser will directly call the underlying operating system's data specifications to accurately generate display strings that conform to local conventions.Modern browsers expose the Intl core object (such as Intl.DateTimeFormat and Intl.NumberFormat). By using this API, we only need to specify the current locale code in our code, and the browser will directly call the underlying operating system's data specifications to accurately generate display strings that conform to local conventions.

πŸ‘‡ Interact with the component below to observe how, without changing the source data, the browser completes layout reversal (RTL) and system-level data transformation through underlying APIs:πŸ‘‡ Interact with the component below to observe how, without changing the source data, the browser completes layout reversal (RTL) and system-level data transformation through underlying APIs:

------

2. The Invisible Tree Inside the Browser (a11y)2. The Invisible Tree Inside the Browser (a11y)

Back to the browser's rendering engine. We all know that when the browser parses HTML, it generates a DOM tree, and then combines it with CSS calculations to produce a Render Tree for drawing the interface.Back to the browser's rendering engine. We all know that when the browser parses HTML, it generates a DOM tree, and then combines it with CSS calculations to produce a Render Tree for drawing the interface.

But what is less well known is that during web page access, the browser is actually also building a tree in parallel specifically for the operating system to "see" β€” the AOM tree (Accessibility Object Model).But what is less well known is that during web page access, the browser is actually also building a tree in parallel specifically for the operating system to "see" β€” the AOM tree (Accessibility Object Model).

2.1 Screen Readers and the Essence of Semantics2.1 Screen Readers and the Essence of Semantics

To enable visually impaired users to use computers, operating systems have built-in Screen Reader assistive software (such as macOS's VoiceOver). This type of software "cannot see" the screen's color pixels β€” they rely entirely on the AOM tree exposed by the browser to read web pages aloud.To enable visually impaired users to use computers, operating systems have built-in Screen Reader assistive software (such as macOS's VoiceOver). This type of software "cannot see" the screen's color pixels β€” they rely entirely on the AOM tree exposed by the browser to read web pages aloud.

If a developer uses a plain

tag with CSS styling to create a visually impeccable button, it is perfect in the conventional render tree. But in the AOM tree connected to the screen reader, it is just a meaningless plain text node. Visually impaired users can neither hear a "button" prompt nor select it with the Tab key.If a developer uses a plain
tag with CSS styling to create a visually impeccable button, it is perfect in the conventional render tree. But in the AOM tree connected to the screen reader, it is just a meaningless plain text node. Visually impaired users can neither hear a "button" prompt nor select it with the Tab key.

So why do we repeatedly emphasize "always use semantic HTML tags"? Because when you use