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 从公开仓库中收录这些内容。

举报或申请下架