LocalizationService

Visualizza obsoleti

*Questo contenuto è tradotto usando AI (Beta) e potrebbe contenere errori. Per visualizzare questa pagina in inglese, clicca qui.

Non costruibile
Assistenza
Non Replicato

Il servizio LocalizationService è il servizio responsabile per la gestione della traduzione automatizzata.

Viene utilizzato come storage per LocalizationTable oggetti utilizzati dal rimpiego automatico del testo.

Il servizio localizzazione utilizzerà solo i suoi tavoli localizzazione figli per la sostituzione automatica del testo a meno che GuiBase2d.RootLocalizationTable non sia specificato su un oggetto GUI o sui suoi antenati.

Sommario

Proprietà

  • Sola Lettura
    Non Replicato
    Lettura Parallela

    L'ID locale utilizzato per localizzare le funzionalità principali e interne.

  • Sola Lettura
    Non Replicato
    Lettura Parallela

    L'ID locale che il giocatore locale ha impostato per il suo sistema operativo.

Metodi

Proprietà

RobloxLocaleId

Sola Lettura
Non Replicato
Lettura Parallela

Questa proprietà mostra l'ID locale utilizzato per la localizzazione di funzionalità principali e interne come CoreGui .Restituisce una stringa con il codice a due lettere (ad esempio, en-us ) per il locale.

SystemLocaleId

Sola Lettura
Non Replicato
Lettura Parallela

Questa proprietà mostra l'ID locale che il giocatore locale ha impostato per il suo sistema operativo.

Questo restituirà una stringa con il codice a due lettere (ad esempio, "en-us") per il locale.

Vedi anche Player.LocaleId , l'ID locale che un utente ha impostato per il suo account Roblox che viene utilizzato per localizzare il contenuto in-experience.Questo sarà un valore diverso quando Roblox non supporta ancora localmente quel Giocatore.

Metodi

GetCorescriptLocalizations

Instances

Restituisce un elenco di LocalizationTable oggetti utilizzati per la localizzazione degli script del core.


Restituzioni

Instances

GetTableEntries

Restituisce un Array , dove ogni elemento del Array restituito è se stesso un Array di elementi nello stesso formato descritto in LocalizationTable:GetEntries() .L'ordine degli elementi nel restituito Array è lo stesso ordine in cui sarà cercato il LocalizationTables per tentare la localizzazione automatica per il fornito Instance.Gli elementi di ingresso all'interno di un particolare LocalizationTable sono restituiti in un ordine non specificato.

Questa funzione restituisce le entrate indipendentemente dal fatto che l'oggetto sia un GuiBase2d con GuiBase2d.AutoLocalize abilitato.Un oggetto che è un GuiBase2d non verrà effettivamente localizzato automaticamente a meno che GuiBase2d.AutoLocalize non sia abilitato.

L'ordine delle tabelle è il seguente:

Questa funzione non produce. Non aspetterà fino a quando il cloud LocalizationTable non sarà caricato.

Parametri

instance: Instance
Valore predefinito: "nil"

Restituzioni

Un array di array, in cui ogni array è nello stesso formato come descritto in LocalizationTable:GetEntries() .

GetTranslatorForPlayer

Questa funzione prende un giocatore come argomento e restituisce un'istanza Translator che può essere utilizzata per eseguire traduzioni per quel locale se ne sono disponibili.Gli elementi utilizzati per la localizzazione sono gli elementi forniti dalla gerarchia LocalizationTable sotto LocalizationService nonché dal cloud LocalizationTable, se è disponibile e già caricato.Questo sarà lo stesso insieme di entrate restituite da LocalizationService:GetTableEntries(nil) .

Questa funzione non produce. Non aspetterà fino a quando il cloud LocalizationTable non sarà caricato.

Vedi anche:

Parametri

player: Instance

Il Player che stai ottenendo per il Translator .

Valore predefinito: ""

Restituzioni

L'istanza Translator per il locale specificato.

Campioni di codice

This code sample attempts to retrieve a Translator object for the local player. LocalizationService:GetTranslatorForPlayerAsync() is wrapped in a pcall because it may error. If it does not error and returns a Translator, it translates and prints "Hello World!" in the player's language. If the function errors, it prints "GetTranslatorForLocaleAsync failed:" followed by the error message.

LocalizationService:GetTranslatorForPlayer() can also be used if you'd like to get the player's translator without yielding until the function returns.

Getting and Using a Translator for a Player

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

GetCountryRegionForPlayerAsync

Resa

Restituisce una stringa di codice del paese/regione in base alla geolocalizzazione del client del Giocatore. I codici del paese/regione supportati sono i seguenti:


<th>Paese/Regione</th>
</tr>
</thead>
<tbody>
<tr>
<td>US</td>
<td>Stati Uniti</td>
</tr>
<tr>
<td>GB</td>
<td>Regno Unito</td>
</tr>
<tr>
<td>CA</td>
<td>Canda</td>
</tr>
<tr>
<td>AF</td>
<td>Afghanistan</td>
</tr>
<tr>
<td>AX</td>
<td>Isole Aland</td>
</tr>
<tr>
<td>AL</td>
<td>Albernia</td>
</tr>
<tr>
<td>DZ</td>
<td>Algeria</td>
</tr>
<tr>
<td>AS</td>
<td>Samoa Americane</td>
</tr>
<tr>
<td>AD</td>
<td>Andorra</td>
</tr>
<tr>
<td>AO</td>
<td>Angola</td>
</tr>
<tr>
<td>AI</td>
<td>Anguailla</td>
</tr>
<tr>
<td>AQ</td>
<td>Antartica</td>
</tr>
<tr>
<td>AG</td>
<td>Antigua e Barbuda</td>
</tr>
<tr>
<td>AR</td>
<td>Argentina</td>
</tr>
<tr>
<td>AM</td>
<td>Armenia</td>
</tr>
<tr>
<td>AW</td>
<td>Aruba</td>
</tr>
<tr>
<td>AU</td>
<td>Australia</td>
</tr>
<tr>
<td>AT</td>
<td>Austia</td>
</tr>
<tr>
<td>AZ</td>
<td>Azerbaijan</td>
</tr>
<tr>
<td>BS</td>
<td>Bahamas</td>
</tr>
<tr>
<td>BH</td>
<td>Barcellona</td>
</tr>
<tr>
<td>BD</td>
<td>B Bangladesh</td>
</tr>
<tr>
<td>BB</td>
<td>Barbadossi</td>
</tr>
<tr>
<td>BY</td>
<td>Bielorussia</td>
</tr>
<tr>
<td>BE</td>
<td>Belgio</td>
</tr>
<tr>
<td>BZ</td>
<td>Bielize</td>
</tr>
<tr>
<td>BJ</td>
<td>Benin</td>
</tr>
<tr>
<td>BM</td>
<td>Bermuda</td>
</tr>
<tr>
<td>BT</td>
<td>Butano</td>
</tr>
<tr>
<td>BO</td>
<td>Bolivia</td>
</tr>
<tr>
<td>BQ</td>
<td>Bonaire, Sant'Eustachio e Saba</td>
</tr>
<tr>
<td>BA</td>
<td>Bosnia ed Erzegovina</td>
</tr>
<tr>
<td>BW</td>
<td>Botswana</td>
</tr>
<tr>
<td>BV</td>
<td>Isola di Bouvet</td>
</tr>
<tr>
<td>BR</td>
<td>Brasile</td>
</tr>
<tr>
<td>IO</td>
<td>Territorio dell'Oceano Indiano britannico</td>
</tr>
<tr>
<td>BN</td>
<td>Brunei Darussalam</td>
</tr>
<tr>
<td>BG</td>
<td>Bulgaria</td>
</tr>
<tr>
<td>BF</td>
<td>Burkinabè</td>
</tr>
<tr>
<td>BI</td>
<td>Burundi</td>
</tr>
<tr>
<td>KH</td>
<td>Cambogia</td>
</tr>
<tr>
<td>CM</td>
<td>Camerun</td>
</tr>
<tr>
<td>CV</td>
<td>Cape Verde</td>
</tr>
<tr>
<td>KY</td>
<td>Isole Cayman</td>
</tr>
<tr>
<td>CF</td>
<td>Repubblica Centrafricana</td>
</tr>
<tr>
<td>TD</td>
<td>Camerun</td>
</tr>
<tr>
<td>CL</td>
<td>Cile</td>
</tr>
<tr>
<td>CN</td>
<td>Cina</td>
</tr>
<tr>
<td>CX</td>
<td>Isola di Natale</td>
</tr>
<tr>
<td>CC</td>
<td>Isole Cocos</td>
</tr>
<tr>
<td>CO</td>
<td>Colombia</td>
</tr>
<tr>
<td>KM</td>
<td>Comore</td>
</tr>
<tr>
<td>CG</td>
<td>Congo</td>
</tr>
<tr>
<td>CD</td>
<td>Congo (DRC)</td>
</tr>
<tr>
<td>CK</td>
<td>Isole Cook</td>
</tr>
<tr>
<td>CR</td>
<td>Costa Riva</td>
</tr>
<tr>
<td>CI</td>
<td>Costa d'Avorio</td>
</tr>
<tr>
<td>HR</td>
<td>Croazia</td>
</tr>
<tr>
<td>CW</td>
<td>Curaçao</td>
</tr>
<tr>
<td>CY</td>
<td>Cipro</td>
</tr>
<tr>
<td>CZ</td>
<td>Repubblica Ceca</td>
</tr>
<tr>
<td>DK</td>
<td>Danimarca</td>
</tr>
<tr>
<td>DJ</td>
<td>Djibouti</td>
</tr>
<tr>
<td>DM</td>
<td>Dominica</td>
</tr>
<tr>
<td>DO</td>
<td>Repubblica Dominicana</td>
</tr>
<tr>
<td>EC</td>
<td>Cile</td>
</tr>
<tr>
<td>EG</td>
<td>Egitto</td>
</tr>
<tr>
<td>SV</td>
<td>El Salvatore</td>
</tr>
<tr>
<td>GQ</td>
<td>Guinea Equatoriale</td>
</tr>
<tr>
<td>ER</td>
<td>Eritrea</td>
</tr>
<tr>
<td>EE</td>
<td>Estonia</td>
</tr>
<tr>
<td>ET</td>
<td>Etiopia</td>
</tr>
<tr>
<td>FK</td>
<td>Isole Falkland (Malvinas)</td>
</tr>
<tr>
<td>FO</td>
<td>Isole Fær Øer</td>
</tr>
<tr>
<td>FJ</td>
<td>Isole Fiji</td>
</tr>
<tr>
<td>FI</td>
<td>Finlandia</td>
</tr>
<tr>
<td>FR</td>
<td>Francia</td>
</tr>
<tr>
<td>GF</td>
<td>Guiana francese</td>
</tr>
<tr>
<td>PF</td>
<td>Polinesia francese</td>
</tr>
<tr>
<td>TF</td>
<td>Territori meridionali francesi</td>
</tr>
<tr>
<td>GA</td>
<td>Gabonese</td>
</tr>
<tr>
<td>GM</td>
<td>Giamaica</td>
</tr>
<tr>
<td>GE</td>
<td>Grecia</td>
</tr>
<tr>
<td>DE</td>
<td>Germania</td>
</tr>
</tbody>
Codice

<th>Paese/Regione</th>
</tr>
</thead>
<tbody>
<tr>
<td>GH</td>
<td>Ghana</td>
</tr>
<tr>
<td>GI</td>
<td>Gibilterra</td>
</tr>
<tr>
<td>GR</td>
<td>Grecia</td>
</tr>
<tr>
<td>GL</td>
<td>Groenlandia</td>
</tr>
<tr>
<td>GD</td>
<td>Grenada</td>
</tr>
<tr>
<td>GP</td>
<td>Guadalupa</td>
</tr>
<tr>
<td>GU</td>
<td>Guam</td>
</tr>
<tr>
<td>GT</td>
<td>Giamaica</td>
</tr>
<tr>
<td>GG</td>
<td>Guernsey</td>
</tr>
<tr>
<td>GN</td>
<td>Guerra della Guinea</td>
</tr>
<tr>
<td>GW</td>
<td>Guinea-Bissau</td>
</tr>
<tr>
<td>GY</td>
<td>Guyana</td>
</tr>
<tr>
<td>HT</td>
<td>Hai티</td>
</tr>
<tr>
<td>HM</td>
<td>Isola di Heard e Isole McDonald</td>
</tr>
<tr>
<td>VA</td>
<td>Santa Sede</td>
</tr>
<tr>
<td>HN</td>
<td>Honduras</td>
</tr>
<tr>
<td>HK</td>
<td>Hong Kong</td>
</tr>
<tr>
<td>HU</td>
<td>Ungheria</td>
</tr>
<tr>
<td>IS</td>
<td>Islanda</td>
</tr>
<tr>
<td>IN</td>
<td>India</td>
</tr>
<tr>
<td>ID</td>
<td>Indonesia</td>
</tr>
<tr>
<td>IQ</td>
<td>Iraq</td>
</tr>
<tr>
<td>IE</td>
<td>Irlanda</td>
</tr>
<tr>
<td>IM</td>
<td>Isola di Man</td>
</tr>
<tr>
<td>IL</td>
<td>Israele</td>
</tr>
<tr>
<td>IT</td>
<td>Italia</td>
</tr>
<tr>
<td>JM</td>
<td>Giamaica</td>
</tr>
<tr>
<td>JP</td>
<td>Giappone</td>
</tr>
<tr>
<td>JE</td>
<td>Maglia</td>
</tr>
<tr>
<td>JO</td>
<td>Giordania</td>
</tr>
<tr>
<td>KZ</td>
<td>Kazakistan</td>
</tr>
<tr>
<td>KE</td>
<td>Kenya</td>
</tr>
<tr>
<td>KI</td>
<td>Kiribilati</td>
</tr>
<tr>
<td>KR</td>
<td>Corea</td>
</tr>
<tr>
<td>KW</td>
<td>Kuwait</td>
</tr>
<tr>
<td>KG</td>
<td>Kirghizistan</td>
</tr>
<tr>
<td>LA</td>
<td>Laos</td>
</tr>
<tr>
<td>LV</td>
<td>Lettonia</td>
</tr>
<tr>
<td>LB</td>
<td>Libano</td>
</tr>
<tr>
<td>LS</td>
<td>Lesotho</td>
</tr>
<tr>
<td>LR</td>
<td>Liberia</td>
</tr>
<tr>
<td>LY</td>
<td>Libia</td>
</tr>
<tr>
<td>LI</td>
<td>Lettonia</td>
</tr>
<tr>
<td>LT</td>
<td>Lituania</td>
</tr>
<tr>
<td>LU</td>
<td>Lussemburgo</td>
</tr>
<tr>
<td>MO</td>
<td>Macao</td>
</tr>
<tr>
<td>MK</td>
<td>Macedonia</td>
</tr>
<tr>
<td>MG</td>
<td>Madagascar</td>
</tr>
<tr>
<td>MW</td>
<td>Maldive</td>
</tr>
<tr>
<td>MY</td>
<td>Maleasia</td>
</tr>
<tr>
<td>MV</td>
<td>Maldive</td>
</tr>
<tr>
<td>ML</td>
<td>Mali</td>
</tr>
<tr>
<td>MT</td>
<td>Malta</td>
</tr>
<tr>
<td>MH</td>
<td>Isole Marshall</td>
</tr>
<tr>
<td>MQ</td>
<td>Martinica</td>
</tr>
<tr>
<td>MR</td>
<td>Mauretania</td>
</tr>
<tr>
<td>MU</td>
<td>Mauritius</td>
</tr>
<tr>
<td>YT</td>
<td>Mayotta</td>
</tr>
<tr>
<td>MX</td>
<td>Messico</td>
</tr>
<tr>
<td>FM</td>
<td>Micronesia</td>
</tr>
<tr>
<td>MD</td>
<td>Moldavia</td>
</tr>
<tr>
<td>MC</td>
<td>Mondaco</td>
</tr>
<tr>
<td>MN</td>
<td>Mongolia</td>
</tr>
<tr>
<td>ME</td>
<td>Montenegro</td>
</tr>
<tr>
<td>MS</td>
<td>Monte Serra</td>
</tr>
<tr>
<td>MA</td>
<td>Marocco</td>
</tr>
<tr>
<td>MZ</td>
<td>Mozambico</td>
</tr>
<tr>
<td>MM</td>
<td>Myanmar</td>
</tr>
<tr>
<td>NA</td>
<td>Namibilia</td>
</tr>
<tr>
<td>NR</td>
<td>Nauru</td>
</tr>
<tr>
<td>NP</td>
<td>Nepale</td>
</tr>
<tr>
<td>NL</td>
<td>Paesi Bassi</td>
</tr>
<tr>
<td>AN</td>
<td>Isole Antille Olandesi</td>
</tr>
<tr>
<td>NC</td>
<td>Nuova Caledonia</td>
</tr>
<tr>
<td>NZ</td>
<td>Nuova Zelanda</td>
</tr>
<tr>
<td>NI</td>
<td>Nicaragua</td>
</tr>
<tr>
<td>NE</td>
<td>Nigero</td>
</tr>
<tr>
<td>NG</td>
<td>Nigrazia</td>
</tr>
<tr>
<td>NU</td>
<td>Niue</td>
</tr>
<tr>
<td>NF</td>
<td>Isola di Norfolk</td>
</tr>
<tr>
<td>MP</td>
<td>Isole Marianne settentrionali</td>
</tr>
<tr>
<td>NO</td>
<td>Norvegia</td>
</tr>
<tr>
<td>OM</td>
<td>Omano</td>
</tr>
</tbody>
Codice

<th>Paese/Regione</th>
</tr>
</thead>
<tbody>
<tr>
<td>PK</td>
<td>Pakistano</td>
</tr>
<tr>
<td>PW</td>
<td>Palazzo</td>
</tr>
<tr>
<td>PS</td>
<td>Palestina</td>
</tr>
<tr>
<td>PA</td>
<td>Panama</td>
</tr>
<tr>
<td>PG</td>
<td>Papua Nuova Guinea</td>
</tr>
<tr>
<td>PY</td>
<td>Paraguay</td>
</tr>
<tr>
<td>PE</td>
<td>Perù</td>
</tr>
<tr>
<td>PH</td>
<td>Filippine</td>
</tr>
<tr>
<td>PN</td>
<td>Isole Pitcairn</td>
</tr>
<tr>
<td>PL</td>
<td>Polonia</td>
</tr>
<tr>
<td>PT</td>
<td>Portogallo</td>
</tr>
<tr>
<td>PR</td>
<td>Porto Rico</td>
</tr>
<tr>
<td>QA</td>
<td>Qatar</td>
</tr>
<tr>
<td>RE</td>
<td>Riunione</td>
</tr>
<tr>
<td>RO</td>
<td>Romania</td>
</tr>
<tr>
<td>RU</td>
<td>Federazione Russa</td>
</tr>
<tr>
<td>RW</td>
<td>Rwanda</td>
</tr>
<tr>
<td>BL</td>
<td>Santa Barthelemy</td>
</tr>
<tr>
<td>SH</td>
<td>Saint Helena, Ascensione e Tristan da Cunha</td>
</tr>
<tr>
<td>KN</td>
<td>Santa Kitts e Nevis</td>
</tr>
<tr>
<td>LC</td>
<td>Santa Lucia</td>
</tr>
<tr>
<td>MF</td>
<td>San Martino</td>
</tr>
<tr>
<td>PM</td>
<td>Saint Pierre e Miquelon</td>
</tr>
<tr>
<td>VC</td>
<td>Santa Lucia e Grenadine</td>
</tr>
<tr>
<td>WS</td>
<td>Samoa</td>
</tr>
<tr>
<td>SM</td>
<td>San Marino</td>
</tr>
<tr>
<td>ST</td>
<td>Sao Tome e Principe</td>
</tr>
<tr>
<td>SA</td>
<td>Arabia Saudita</td>
</tr>
<tr>
<td>SN</td>
<td>Senegal</td>
</tr>
<tr>
<td>RS</td>
<td>Serbia</td>
</tr>
<tr>
<td>SC</td>
<td>Isole Seicelle</td>
</tr>
<tr>
<td>SL</td>
<td>Sierra Leone</td>
</tr>
<tr>
<td>SG</td>
<td>Singapore</td>
</tr>
<tr>
<td>SX</td>
<td>Sint Maarten</td>
</tr>
<tr>
<td>SK</td>
<td>Slovacchia</td>
</tr>
<tr>
<td>SI</td>
<td>Slovenia</td>
</tr>
<tr>
<td>SB</td>
<td>Isole Salomone</td>
</tr>
<tr>
<td>SO</td>
<td>Somalia</td>
</tr>
<tr>
<td>ZA</td>
<td>Sud Africa</td>
</tr>
<tr>
<td>GS</td>
<td>Sud Georgia e Isole Sandwich del Sud</td>
</tr>
<tr>
<td>SS</td>
<td>Sud Sudan</td>
</tr>
<tr>
<td>ES</td>
<td>Spagna</td>
</tr>
<tr>
<td>LK</td>
<td>Sri Lanka</td>
</tr>
<tr>
<td>SR</td>
<td>Surinamè</td>
</tr>
<tr>
<td>SJ</td>
<td>Svalbard e Jan Mayen</td>
</tr>
<tr>
<td>SZ</td>
<td>Svezia</td>
</tr>
<tr>
<td>SE</td>
<td>Svezia</td>
</tr>
<tr>
<td>CH</td>
<td>Svizzera</td>
</tr>
<tr>
<td>TW</td>
<td>Taiwan</td>
</tr>
<tr>
<td>TJ</td>
<td>Tagikistan</td>
</tr>
<tr>
<td>TZ</td>
<td>Tanzania</td>
</tr>
<tr>
<td>TH</td>
<td>Tailandia</td>
</tr>
<tr>
<td>TL</td>
<td>Timor-Leste</td>
</tr>
<tr>
<td>TG</td>
<td>Togo</td>
</tr>
<tr>
<td>TK</td>
<td>Tokelau</td>
</tr>
<tr>
<td>TO</td>
<td>Tonga</td>
</tr>
<tr>
<td>TT</td>
<td>Trinità e Tobago</td>
</tr>
<tr>
<td>TN</td>
<td>Tunisia</td>
</tr>
<tr>
<td>TR</td>
<td>Turchia (Turchia)</td>
</tr>
<tr>
<td>TM</td>
<td>Turchia</td>
</tr>
<tr>
<td>TC</td>
<td>Isole Turks e Caicos</td>
</tr>
<tr>
<td>TV</td>
<td>Tuvale</td>
</tr>
<tr>
<td>UG</td>
<td>Uganda</td>
</tr>
<tr>
<td>UA (acquisizione utenti)</td>
<td>Ucraina</td>
</tr>
<tr>
<td>AE</td>
<td>Emirati Arabi Uniti</td>
</tr>
<tr>
<td>UM</td>
<td>Isole minori statunitensi</td>
</tr>
<tr>
<td>UY</td>
<td>Uruguay</td>
</tr>
<tr>
<td>UZ</td>
<td>Uzbekistan</td>
</tr>
<tr>
<td>VU</td>
<td>Vanuati</td>
</tr>
<tr>
<td>VE</td>
<td>Venezia</td>
</tr>
<tr>
<td>VN</td>
<td>Vietnam</td>
</tr>
<tr>
<td>VG</td>
<td>Isole Vergini (Britanniche)</td>
</tr>
<tr>
<td>VI</td>
<td>Isole Vergini (US)</td>
</tr>
<tr>
<td>WF</td>
<td>Wallis e Futuna</td>
</tr>
<tr>
<td>EH</td>
<td>Sahara Occidentale</td>
</tr>
<tr>
<td>YE</td>
<td>Yemen</td>
</tr>
<tr>
<td>ZM</td>
<td>Zambia</td>
</tr>
<tr>
<td>ZW</td>
<td>Zimbabwe</td>
</tr>
<tr>
<td>CU</td>
<td>Cuba</td>
</tr>
<tr>
<td>IR</td>
<td>Irlanda</td>
</tr>
<tr>
<td>SY</td>
<td>Siria</td>
</tr>
<tr>
<td>KP</td>
<td>Corea del Nord</td>
</tr>
</tbody>
Codice

Vedi anche:

Parametri

player: Instance

Il giocatore per cui stai ottenendo informazioni sul paese/regione.

Valore predefinito: ""

Restituzioni

Una stringa che indica il codice del paese/regione di un Giocatore.

Campioni di codice

This code sample gets the country/region code for a local player and prints "Hello, friend from Canada!" if the player's client IP geolocation is Canada.

Getting Country/Region Code for a Player

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("Hello, friend from Canada!")
else
print("GetCountryRegionForPlayerAsync failed: " .. code)
end

GetTranslatorForLocaleAsync

Resa

Questa funzione prende un codice locale come argomento e restituisce fino a quando il cloud LocalizationTable non è stato caricato, se disponibile.Quindi restituisce un oggetto Translator che può essere utilizzato per eseguire traduzioni per quel locale se ne sono disponibili.Gli elementi utilizzati per la localizzazione sono gli elementi forniti dalla gerarchia LocalizationTable sotto LocalizationService nonché il tavolo del cloud (se disponibile).Questo sarà lo stesso insieme di entrate restituite da LocalizationService:GetTableEntries(nil) .

Questa funzione può errore e quindi dovrebbe essere avvolta in un pcall() .

Vedi anche:

Parametri

locale: string

Un linguaggio o un codice locale supportato da Roblox.

Valore predefinito: ""

Restituzioni

L'istanza Translator per il locale specificato.

Campioni di codice

This code sample attempts to retrieve a Translator object for the locale "fr" (French).

LocalizationService:GetTranslatorForLocaleAsync() is wrapped in a pcall because it may error. If it does not error and returns a Translator, prints "Hello in French:" followed by the French translation of "Hello World!". If the function errors, it prints "GetTranslatorForLocaleAsync failed:" followed by the error message.

Getting and Using a Translator for a Locale

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("Hello in French: " .. result)
else
print("GetTranslatorForLocaleAsync failed: " .. translator)
end

GetTranslatorForPlayerAsync

Resa

Questa funzione prende un giocatore come argomento e rende fino a quando il cloud LocalizationTable per il locale di quel Giocatorenon è stato caricato, se disponibile.Quindi restituisce un oggetto Translator che può essere utilizzato per eseguire traduzioni per quel locale se ne sono disponibili.Gli elementi utilizzati per la localizzazione sono gli elementi forniti dalla gerarchia LocalizationTable sotto LocalizationService nonché il tavolo del cloud (se disponibile).Questo sarà lo stesso insieme di entrate restituite da LocalizationService:GetTableEntries(nil) .

Questa funzione può errore e quindi dovrebbe essere avvolta in un pcall() .

Vedi anche:

Parametri

player: Instance

Il Player che stai ottenendo per il Translator .

Valore predefinito: ""

Restituzioni

L'istanza Translator per il locale specificato.

Campioni di codice

This code sample attempts to retrieve a Translator object for the local player. LocalizationService:GetTranslatorForPlayerAsync() is wrapped in a pcall because it may error. If it does not error and returns a Translator, it translates and prints "Hello World!" in the player's language. If the function errors, it prints "GetTranslatorForLocaleAsync failed:" followed by the error message.

LocalizationService:GetTranslatorForPlayer() can also be used if you'd like to get the player's translator without yielding until the function returns.

Getting and Using a Translator for a Player

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

Eventi