Roblox Localization

TabooHarmony/roblox-brain/skills/gameplay/roblox-localization

作者 TabooHarmony38826be57ee37bcf023e9c2b85681bea3909281c無授權條款收錄於 2026年10月9日更新於 2026年10月9日

Use when implementing Roblox multi-language support, translation tables, auto-translation, locale-specific content, or region detection.

AI 產生的概覽

指導 Roblox 開發者使用 LocalizationService、翻譯表和區域偵測來實作多語言支援。

功能
此技能為在 Roblox 體驗中加入多語言支援提供參考指引。內容涵蓋透過玩家與系統地區設定 ID 進行區域偵測、國家與地區查詢、LocalizationTable 翻譯項目、GUI 自動翻譯,以及透過翻譯器物件進行手動翻譯。它也列出關鍵規則、非同步注意事項和常見陷阱,並指向更完整的參考文件以取得更多細節。
適用情境
適用於在 Roblox 專案中實作多語言支援、翻譯系統、特定地區內容或區域偵測的情境。對象是使用 LocalizationService、LocalizationTable、自動翻譯或國家偵測的開發者。
執行需求
不附帶指令碼,僅為說明文件。假定具備 Luau 與 Studio 的 Roblox 開發環境,並引用隨附的參考文件以取得更多細節。

Roblox Localization

When to Load

Load when implementing multi-language support, translation systems, locale-specific content, or region detection. Covers LocalizationService, LocalizationTable, auto-translation, and country/region detection.

Quick Reference

Locale Detection

  • player.LocaleId: locale the player set for their Roblox account (e.g. en-us, pt-br, ja-jp)
  • LocalizationService.RobloxLocaleId: locale for core/internal features
  • LocalizationService.SystemLocaleId: player's OS locale
  • LocalizationService:GetCountryRegionForPlayerAsync(player): country code from IP geolocation (e.g. US, BR, JP)

Translation Tables

  • LocalizationTable: stores translation entries (key → translations per locale)
  • Parent LocalizationTable under LocalizationService for auto-translation
  • Set GuiBase2d.RootLocalizationTable on GUI objects for per-element tables
  • Studio can auto-extract strings into a table via the Localization Tools plugin

Auto-Translation

  • Auto-translation requires AutoLocalize = true on the GUI and its ancestors, plus a matching table entry
  • Set TextLabel.Text normally; the engine replaces it with the translated string for the player's locale
  • Missing translations fall back to the source text

Manual Translation

luau
local translator = LocalizationService:GetTranslatorForPlayerAsync(player)local translated = translator:Translate(game, "Welcome!")local formatted = translator:FormatByKey("coins_count", {count})

Country/Region Detection

luau
local country = LocalizationService:GetCountryRegionForPlayerAsync(player)if country == "US" then -- USD pricing    -- US offerelseif country == "GB" then    -- UK offerend

Key Rules

  • GetCountryRegionForPlayerAsync is async; wrap in pcall, may fail
  • GetTranslatorForPlayerAsync is async; cache the translator
  • Set RootLocalizationTable to choose a table; keep AutoLocalize true through the ancestor chain
  • Translation entries: SourceText, SourceLocaleId, then en-us, pt-br, etc. columns
  • Export/import tables as CSV from Studio for bulk editing
  • Test with different locales using Studio's locale simulator

Pitfalls

  • Not all locales supported; check player.LocaleId
  • Auto-translation does NOT work on non-GUI text; use manual Translator:Translate
  • GetCountryRegionForPlayerAsync uses IP geolocation, so VPNs give wrong results
  • Missing entries fall back to source text silently

Need more detail? Load references/full.md.

來源與署名

來源:TabooHarmony/roblox-brain位於skills/gameplay/roblox-localization提交38826be

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架