エンジンクラス
LocalizationTable
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
概要
方法
GetTranslator(localeId: string):Instance |
RemoveEntry(key: string,source: string,context: string):() |
RemoveEntryValue(key: string,source: string,context: string,localeId: string):() |
RemoveTargetLocale(localeId: string):() |
SetContents(contents: string):() |
SetEntries(entries: Variant):() |
SetEntryContext(key: string,source: string,context: string,newContext: string):() |
SetEntryExample(key: string,source: string,context: string,example: string):() |
SetEntryKey(key: string,source: string,context: string,newKey: string):() |
SetEntrySource(key: string,source: string,context: string,newSource: string):() |
コードサンプル
ローカリゼーションテーブル
local LocalizationService = game:GetService("LocalizationService")
local function createLocalizationTable(entries): LocalizationTable
local localTable = Instance.new("LocalizationTable")
localTable.SourceLocaleId = LocalizationService.SystemLocaleId
localTable:SetEntries(entries)
return localTable
end
local entries = {
{
Key = "Hello_World", -- 'expressionKey' を GetString と共に使用します
Values = { -- IETF 言語タグに対応するキーと、その翻訳の辞書。
["ru"] = " !", -- ロシア語
["fr"] = "Bonjour le monde!", -- フランス語
["de"] = "Hallo Welt!", -- ドイツ語
["en-US"] = "Hello world!", -- 英語
["it"] = "Ciao mondo!", -- イタリア語
["pt-BR"] = "Ol Mundo!", -- ポルトガル語
["ja"] = "こんにちは世界!", -- 日本語
["es"] = "Hola Mundo!", -- スペイン語
},
},
}
local helloWorldTable = createLocalizationTable(entries)
local translatorEnglish = helloWorldTable:GetTranslator("en-US")
print(translatorEnglish:FormatByKey("Hello_World"))APIリファレンス
プロパティ
DevelopmentLanguage
Root
方法
GetContents
GetEntries
戻り値
コードサンプル
ローカリゼーションテーブルの使用
local LocalizationService = game:GetService("LocalizationService")
local localizationTable = LocalizationService:FindFirstChild("LocalizationTable")
local entries = {
{
["Key"] = "0001",
["Source"] = "en-us",
["Values"] = {
["0001"] = "こんにちは、ママ、こんにちは、パパ。",
["0002"] = "私はキャンプグラナダにいます。",
["0003"] = "キャンプはとても楽しいです。",
["0004"] = "そして、雨が止めば楽しいこともあると言います。",
},
},
}
localizationTable:SetEntries(entries)
local get_results = localizationTable:GetEntries()
for _index, dict in pairs(get_results) do
for _key, value in pairs(dict["Values"]) do -- 辞書内のすべてのキー、値のペアをループして文字列を印刷
print(value)
end
endGetString
GetTranslator
RemoveEntry
RemoveEntryValue
RemoveKey
SetContents
SetEntries
LocalizationTable:SetEntries(entries:Variant):()
パラメータ
entries:Variant |
戻り値
()
SetEntry
SetEntryContext
SetEntryExample
SetEntryKey
SetEntrySource