roblox-localization
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRoblox Localization
Roblox 本地化
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.
当需要实现多语言支持、翻译系统、特定区域设置内容或地区检测时加载。涵盖LocalizationService、LocalizationTable、自动翻译以及国家/地区检测功能。
Quick Reference
快速参考
Locale Detection
区域设置检测
- — locale the player set for their Roblox account (e.g.
player.LocaleId,en-us,pt-br)ja-jp - — locale for core/internal features
LocalizationService.RobloxLocaleId - — player's OS locale
LocalizationService.SystemLocaleId - — country code from IP geolocation (e.g.
LocalizationService:GetCountryRegionForPlayerAsync(player),US,BR)JP
- — 玩家为其Roblox账户设置的区域设置(例如
player.LocaleId、en-us、pt-br)ja-jp - — 核心/内部功能使用的区域设置
LocalizationService.RobloxLocaleId - — 玩家操作系统的区域设置
LocalizationService.SystemLocaleId - — 通过IP地理定位获取的国家代码(例如
LocalizationService:GetCountryRegionForPlayerAsync(player)、US、BR)JP
Translation Tables
翻译表
- — stores translation entries (key → translations per locale)
LocalizationTable - Parent under
LocalizationTablefor auto-translationLocalizationService - Set on GUI objects for per-element tables
GuiBase2d.RootLocalizationTable - Studio can auto-extract strings into a table via the Localization Tools plugin
- — 存储翻译条目(键 → 各区域设置对应的翻译内容)
LocalizationTable - 将作为
LocalizationTable的子对象,以启用自动翻译LocalizationService - 在GUI对象上设置,为元素指定专属翻译表
GuiBase2d.RootLocalizationTable - 可通过Studio中的Localization Tools插件自动提取字符串到翻译表中
Auto-Translation
自动翻译
- Roblox auto-translates GUI text if is set and entries exist
RootLocalizationTable - Set normally — the engine replaces it with the translated string for the player's locale
TextLabel.Text - Missing translations fall back to the source text
- 如果设置了且存在对应条目,Roblox会自动翻译GUI文本
RootLocalizationTable - 正常设置即可,引擎会将其替换为符合玩家区域设置的翻译文本
TextLabel.Text - 缺失的翻译内容会回退到源文本
Manual Translation
手动翻译
luau
local translator = LocalizationService:GetTranslatorForPlayerAsync(player)
local translated = translator:Translate(game, "Welcome!")
local formatted = translator:FormatTranslate(game, "Coins: {0}", {count})luau
local translator = LocalizationService:GetTranslatorForPlayerAsync(player)
local translated = translator:Translate(game, "Welcome!")
local formatted = translator:FormatTranslate(game, "Coins: {0}", {count})Country/Region Detection
国家/地区检测
luau
local country = LocalizationService:GetCountryRegionForPlayerAsync(player)
if country == "US" then -- USD pricing
elseif country == "GB" then -- GBP pricing endluau
local country = LocalizationService:GetCountryRegionForPlayerAsync(player)
if country == "US" then -- USD定价
elseif country == "GB" then -- GBP定价 endKey Rules
关键规则
- is async — wrap in pcall, may fail
GetCountryRegionForPlayerAsync - is async — cache the translator
GetTranslatorForPlayerAsync - Auto-translation only works on GUI elements with set
RootLocalizationTable - Translation entries: ,
SourceText, thenSourceLocaleId,en-us, etc. columnspt-br - Export/import tables as CSV from Studio for bulk editing
- Test with different locales using Studio's locale simulator
- 是异步方法 — 需用pcall包裹,可能调用失败
GetCountryRegionForPlayerAsync - 是异步方法 — 建议缓存翻译器
GetTranslatorForPlayerAsync - 自动翻译仅对设置了的GUI元素生效
RootLocalizationTable - 翻译条目需包含、
SourceText,以及SourceLocaleId、en-us等区域设置列pt-br - 可从Studio中导出/导入CSV格式的翻译表,以便批量编辑
- 使用Studio的区域设置模拟器测试不同区域设置下的效果
Pitfalls
注意事项
- Not all locales supported — check
player.LocaleId - Auto-translation does NOT work on non-GUI text — use manual
Translator:Translate - uses IP geolocation — VPNs give wrong results
GetCountryRegionForPlayerAsync - Missing entries fall back to source text silently
Need more detail? Load .
references/full.md- 并非所有区域设置都受支持 — 需检查
player.LocaleId - 自动翻译对非GUI文本无效 — 请使用手动方法
Translator:Translate - 基于IP地理定位 — VPN会导致结果不准确
GetCountryRegionForPlayerAsync - 缺失的翻译条目会自动回退到源文本,无提示
需要更多细节? 加载。
references/full.md