首頁 / Skills / 網頁與介面設計 / 介面國際化適配 UI Internationalization
網頁與介面設計

介面國際化適配 UI Internationalization

AIBarsMITSkill 語言: 英文
授權已核對不含腳本低風險
演示真實執行紀錄 · claude-sonnet-5-5 · 2026年10月
Using the ui-internationalization skill, review and plan the work to add German, Japanese and Arabic to an English-only React dashboard. Facts: strings are inline in components; dates are formatted as MM/DD/YYYY by hand; buttons and tabs have fixed pixel widths; the CSS uses margin-left and text-align:left; plurals are done with count === 1; there is no language switcher.
Skill: ui-internationalization

I haven't opened the code, so this review is based only on the facts you gave. I can't cite files or line numbers yet, and step 1 of the plan is a code audit to find them.

Assumptions to confirm

  • Languages: German (de), Japanese (ja) and Arabic (ar), plus English. Arabic means RTL has to be built in from the start.
  • Arabic region: The choice affects the calendar, numerals and currency. For example, ar-SA defaults to the Islamic calendar, while ar-EG and ar-AE use Gregorian. I recommend ar-AE or ar-EG with Latin digits unless the product team says otherwise.
  • Currency and time zone: These should stay independent of language.
  • Translations: I'm assuming they come from people or a vendor, so the catalog needs translator context.
  • Charts: I don't know if the dashboard has charts, and I'd check. Axes, legends and tooltips would need RTL handling too.

Review findings

Hard-coded text

  • Inline strings in components. Every label, placeholder, tooltip, aria-label, error message and page title needs a catalog key. Fix: adopt a library (react-intl or i18next with ICU), use stable keys, and add a translator description for each key.
  • count === 1 plurals. This is wrong for Arabic, which has six plural categories (zero, one, two, few, many, other). It is also wrong for Japanese, which has only "other". Fix: use ICU {count, plural, ...} messages. Arabic needs all six forms written out.
  • Likely string concatenation. Inline strings usually come with count + " items in " + name patterns. Fix: whole messages with named placeholders. I'd grep for + " and template literals in JSX.
  • Ambiguous one-word labels. Words like "Open" or "Filter" can be a verb or a noun. Fix: separate keys per meaning.

Formatting

  • Hand-written MM/DD/YYYY. This is wrong for all three new languages. Fix: Intl.DateTimeFormat(locale, options), with dates stored as ISO or timestamps. Check whether the data layer holds already-formatted strings.
  • Numbers, currency, percentages. These are probably formatted by hand too. Fix: use Intl.NumberFormat, with currency as an explicit code and not derived from the language.
  • Other formatters. Relative time ("3 days ago"), lists, and sorting should use Intl.RelativeTimeFormat, Intl.ListFormat and Intl.Collator.
  • Language and region. Keep these as separate settings.

Layout and truncation

  • Fixed pixel widths on buttons and tabs. German will overflow them and clip. Fix: remove the widths and use min-width, padding and flex or grid with gap. Where truncation is unavoidable, use an ellipsis plus a tooltip or accessible name.
  • Fixed heights. Check for these as well, since text will wrap to more lines.
  • Verification. Use pseudo-localization (about 40% longer, accented, in brackets) to find every clipped element before real translations exist.

Scripts and fonts

  • No lang on the document. Set <html lang> per locale. This is needed for Japanese glyph selection, since the Han characters render differently under ja.
  • Font stack. Add Japanese and Arabic fallbacks; a Latin-only stack will give inconsistent system fallbacks. Check that the bold weights exist for those scripts.
  • Typography.
    • Give Japanese more line-height.
    • Remove any italic emphasis, any forced uppercase, and any letter-spacing on Arabic. Letter spacing breaks Arabic joining.
    • Don't truncate strings by character index; use Intl.Segmenter if any code does.

RTL

  • margin-left and text-align: left. These will break the Arabic layout. Fix: switch to margin-inline-start, padding-inline, text-align: start, inset-inline-* and border-inline-*. Do this by codebase-wide search and replace, then review each hit. Also check for float, left: / right:, and translateX.
  • dir. Set dir="rtl" on the root for Arabic.
  • Icons. Audit them one by one. Mirror chevrons, back and next arrows, and progress bars. Don't mirror logos, play/pause icons, clocks or numerals.
  • Mixed-direction content. Wrap user-generated or unknown-direction text in <bdi>. Give email, URL and code fields dir="ltr".
  • Charts. If there are any, decide deliberately whether to mirror the time axis. Numerals and axis values stay LTR.

Routing and switching

  • No language switcher. Add one labeled in each language's own name (English, Deutsch, 日本語, العربية), with no flags.
  • Locale order. Use saved choice, then URL, then browser Accept-Language, then default. Don't force a redirect.
  • Persistence. Remember the choice.
  • URLs and SEO. If the dashboard is public, use a path prefix per language with hreflang, x-default and canonical URLs. If it's behind a login, a saved preference may be enough, but I'd confirm.
  • Fallback. Missing translations fall back to English and log the gap. Raw keys should never show.

Plan

  1. Audit (about 1–2 days). Grep for hard-coded strings, count ===, manual date code, width: in px, and left/right/margin-left. This gives a real inventory and effort estimate. Confirm the Arabic region and numeral choice, the translation source, and whether the app has charts or is public.
  2. Foundation.
    • Pick the i18n library and set up the message catalog, with the en catalog as the source.
    • Add a locale provider, a lang/dir setter and the switcher.
    • Add the font stacks and a pseudo-locale.
    • Add a lint rule against literal JSX text (e.g. eslint-plugin-i18next).
  3. Layout and CSS (can run in parallel with step 4). Remove fixed widths and convert to logical properties. Make buttons and tabs flexible, and audit icons for mirroring. Verify with the pseudo-locale and with Arabic under dir="rtl".
  4. Extract strings. Move them component by component into the catalog, with translator notes and ICU plurals. Replace concatenation with whole messages.
  5. Formatting layer. Make one helper module wrapping Intl.* for dates, numbers, currency, lists and relative time. Replace every manual format and store dates as ISO or timestamps.
  6. Translation. Send the catalog to translators with context, including the six Arabic plural forms. Flag legal text, examples and region-specific content for review.
  7. QA and verification. Run every screen in en, de, ja, ar at phone and desktop widths. Test plurals with counts of 0, 1, 2, 5 and a large number (Arabic needs 0, 1, 2, 3–10, 11–99 and 100+ to cover all forms). Compare dates and numbers across two regions. Check lang and dir in the DOM. Search again for leftover hard-coded strings.

Order and risk: the CSS conversion (step 3) and string extraction (step 4) are the largest pieces of work. RTL is the riskiest because it touches every component, so do it early and not at the end.

Not checked: I haven't looked at the codebase, run anything, or tested any real RTL or translated text. All of the above comes from the facts you listed.

If you'd like, I can start with step 1 once you point me at the project directory. The working directory appears to be empty.

Real run in an isolated folder with only this skill installed. Only the Skill and Read tools were enabled, so no command was run and no file was written. The scenario is fictional and the model had no access to the code. The model proposed a plan and listed what it could not check.

它做什麼

把國際化(介面具備被在地化的能力)與在地化(翻譯本身)分開,只負責前者。共六條規則:介面上看得到的文字不寫在程式碼裡(用帶具名佔位符的完整訊息,絕不拼接片段,複數用標準機制而不是 count === 1);日期、數字、貨幣、清單與相對時間用依地區格式化的 Intl 介面;用邏輯 CSS 屬性與偽在地化讓版面能適應不同長度的文字;處理文字系統、字體與換行(lang、zh-Hans 與 zh-Hant、字體備援、中日韓的表現);支援由右至左的版面(dir,鏡像該鏡像的、不鏡像不該鏡像的,雙向文字隔離);以及設計語言切換、地區選擇順序、網址、hreflang 與備援。

還涵蓋

讓語言、地區、貨幣與時區彼此獨立;把日期存成時間戳;靈活的姓名與地址表單;給訊息鍵提供譯者脈絡;以及宣布完成前要核對的清單。

適合什麼場景

加入第二種語言、為只有英文的產品加入德語、日語或阿拉伯語,以及檢視一個「一翻譯就崩」的介面。

說明與風險

低風險:純指令檔,沒有腳本,不連網、不寫檔。它不做任何翻譯,也不評判翻譯品質;機器翻譯或未經審校的譯文需要精通該語言的人審閱,法律、醫療或帶地區屬性的內容需要當地審核。它看不到你的程式碼,也不能執行,所以會列出沒有檢查的部分,例如真實的由右至左算繪。部分 `Intl` 功能需要對照你的瀏覽器核對支援情況。AIBars 原創(MIT)。已用一個虛構的 React 儀表板試用過一次。