GetLocalization: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 36: | Line 36: | ||
["bg_BG"] = "Bulgarian", | ["bg_BG"] = "Bulgarian", | ||
["bs_BA"] = "Bosnian", | ["bs_BA"] = "Bosnian", | ||
["cs_CZ= "Czech", | ["cs_CZ"] = "Czech", | ||
["da_DK"] = "Danish", | ["da_DK"] = "Danish", | ||
["de_DE"] = "German", | ["de_DE"] = "German", | ||
Line 119: | Line 119: | ||
code = getLanguageCode(getLocalization().code) | code = getLanguageCode(getLocalization().code) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Client_utility_functions}} | {{Client_utility_functions}} | ||
[[ru:GetLocalization]] | [[ru:GetLocalization]] |
Revision as of 12:51, 3 July 2023
This function gets the player's localization setting as set in the MTA client.
Syntax
table getLocalization ( )
Returns
Returns a table with the following entries:
- code : The language code (eg. "en_US" for "English (United States)" or "ar" for "Arabic").
- name : The name of the language (eg. "English (United States)" or "Arabic").
Example
This example outputs simple Welcome message at the resource start (also when player joins the game if the resource is already running).
local msg = {cs = "Vítejte", fr = "Accueil", de = "Willkommen", pl = "Powitanie", hu = "Üdv"} addEventHandler("onClientResourceStart", resourceRoot, function () local languageCode = getLocalization()["code"] if msg[languageCode] then --Check if the message is avaible in client's language outputChatBox(msg[languageCode] .. "!") --Output it else outputChatBox("Welcome!") --Output English for any other language end end)
This is a list of all the language codes used in MTA in a table with the full name of the language.
langTable = { ["ar_SA"] = "Arabic", ["az_AZ"] = "Azerbaijani", ["bg_BG"] = "Bulgarian", ["bs_BA"] = "Bosnian", ["cs_CZ"] = "Czech", ["da_DK"] = "Danish", ["de_DE"] = "German", ["en_US"] = "English", ["el_GR"] = "Greek", ["es_ES"] = "Spanish", ["et_EE"] = "Estonian", ["fa_IR"] = "Persian", ["fi_FI"] = "Finnish", ["fil_PH"] = "Filipino", ["fr_FR"] = "French", ["he_IL"] = "Hebrew", ["hi_IN"] = "Hindi", ["hr_HR"] = "Croatian", ["hu_HU"] = "Hungarian", ["id_ID"] = "Indonesian", ["it_IT"] = "Italian", ["ja_JP"] = "Japanese", ["ka_GE"] = "Georgian", ["ko_KR"] = "Korean", ["lt_LT"] = "Lithuanian", ["lv_LV"] = "Latvian", ["mk_MK"] = "Macedonian", ["nb_NO"] = "Norwegian", ["nl_NL"] = "Dutch", ["pt_BR"] = "Portuguese, Brazilian", ["pt_PT"] = "Portuguese", ["pl_PL"] = "Polish", ["ru_RU"] = "Russian", ["ro_RO"] = "Romanian", ["sl_SL"] = "Slovenian", ["sv_SE"] = "Swedish", ["sk_SK"] = "Slovak", ["srp"] = "Serbian", ["tr_TR"] = "Turkish", ["uk_UA"] = "Ukrainian", ["vi_VN"] = "Vietnamese", ["zh_CN"] = "Chinese Simplified", ["zh_TW"] = "Chinese Traditional", }
This function is useful for fixing any scripts that were made before MTA 1.6 as some of the language codes were changed.
function getLanguageCode(c) if (c == "fr_FR") then return "fr" elseif (c == "ru_RU") then return "ru" elseif (c == "pt_PT") then return "pt_BR" elseif (c == "pl_PL") then return "pl" elseif (c == "tr_TR") then return "tr" elseif (c == "es_ES") then return "es" elseif (c == "de_DE") then return "de" elseif (c == "vi_VN") then return "vi" elseif (c == "ar_SA") then return "ar" elseif (c == "bg_BG") then return "bg" elseif (c == "hu_HU") then return "hu" elseif (c == "ro_RO") then return "ro" elseif (c == "sv_SE") then return "sv" elseif (c == "hr_HR") then return "hr" elseif (c == "uk_UA") then return "uk" end return c end code = getLanguageCode(getLocalization().code)
See Also
- createTrayNotification
- downloadFile
- getDevelopmentMode
- getKeyboardLayout
- getLocalization
- isShowCollisionsEnabled
- isShowSoundEnabled
- isTransferBoxAlwaysVisible
- isTransferBoxVisible
- isTrayNotificationEnabled
- setClipboard
- setDevelopmentMode
- setTransferBoxVisible
- setWindowFlashing
- showCol
- showSound
- Shared
- addDebugHook
- base64Decode
- base64Encode
- debugSleep
- decodeString
- encodeString
- fromJSON
- generateKeyPair
- getColorFromString
- getDevelopmentMode
- getDistanceBetweenPoints2D
- getDistanceBetweenPoints3D
- getEasingValue
- getNetworkStats
- getNetworkUsageData
- getPerformanceStats
- getRealTime
- getTickCount
- getTimerDetails
- getTimers
- getFPSLimit
- getUserdataType
- getVersion
- gettok
- isTransferBoxVisible
- setTransferBoxVisible
- hash
- inspect
- interpolateBetween
- iprint
- isOOPEnabled
- isTimer
- killTimer
- md5
- passwordHash
- passwordVerify
- pregFind
- pregMatch
- pregReplace
- removeDebugHook
- resetTimer
- setDevelopmentMode
- setFPSLimit
- setTimer
- ref
- deref
- sha256
- split
- teaDecode
- teaEncode
- toJSON
- tocolor
- getProcessMemoryStats
- utfChar
- utfCode
- utfLen
- utfSeek
- utfSub