エンジンクラス
LocalizationService
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
概要
方法
GetCorescriptLocalizations():Instances |
GetCountryRegionForPlayerAsync(player: Instance):string |
GetTableEntries(instance: Instance):{any} |
GetTranslatorForLocaleAsync(locale: string):Instance |
GetTranslatorForPlayer(player: Instance):Instance |
GetTranslatorForPlayerAsync(player: Instance):Instance |
APIリファレンス
プロパティ
方法
GetCorescriptLocalizations
LocalizationService:GetCorescriptLocalizations():Instances
戻り値
Instances
GetCountryRegionForPlayerAsync
パラメータ
戻り値
コードサンプル
プレイヤーの国/地域コードを取得する
local LocalizationService = game:GetService("LocalizationService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local result, code = pcall(LocalizationService.GetCountryRegionForPlayerAsync, LocalizationService, player)
if result and code == "CA" then
print("カナダの友達、こんにちは!")
else
print("GetCountryRegionForPlayerAsyncが失敗しました: " .. code)
endGetTableEntries
GetTranslatorForLocaleAsync
パラメータ
戻り値
コードサンプル
ロケールのための翻訳者を取得して使用する
local LocalizationService = game:GetService("LocalizationService")
local textLabel = script.Parent
local success, translator = pcall(function()
return LocalizationService:GetTranslatorForLocaleAsync("fr")
end)
if success then
local result = translator:Translate(textLabel, "Hello World!")
print("フランス語のこんにちは: " .. result)
else
print("GetTranslatorForLocaleAsync failed: " .. translator)
endGetTranslatorForPlayer
GetTranslatorForPlayerAsync
パラメータ
戻り値
コードサンプル
プレイヤーのための翻訳者を取得して使用する
local LocalizationService = game:GetService("LocalizationService")
local Players = game:GetService("Players")
local textLabel = script.Parent
local success, translator = pcall(function()
return LocalizationService:GetTranslatorForPlayerAsync(Players.LocalPlayer)
end)
if success then
local result = translator:Translate(textLabel, "Hello World!")
print(result)
else
print("GetTranslatorForPlayerAsync failed: " .. translator)
end