Jump to content

Help translate


Volltron

Recommended Posts

Hello guys ! Can someone help me with this script ? It is supposed to change the shop gui text to the chosen language but it only displays the english language

local languageCode = getLocalization()["code"] 
  
function checkTheLanguage() 
    if languageCode == "en_US" then 
        languageCode = "en_US" 
    elseif languageCode == "ro" then 
        languageCode = "ro" 
    else 
        languageCode = "en_US" 
    end 
end 
addEventHandler("onClientResourceStart",root,checkTheLanguage) 
  
local languageTable = { 
{"en","en_US"}, 
{"ro","ro"}, 
} 
  
function changeLanguageOnCommand(playerSource,language) 
    if language then 
        for i, lang in ipairs(languageTable) do 
            if language == lang[1] then 
                languageCode = lang[2] 
                outputChatBox("New language: "..tostring(languageCode),0,255,0) 
            end 
        end 
    else 
        outputChatBox("Possible values for language: en, ro.",255,0,0) 
    end 
end 
addCommandHandler("language",changeLanguageOnCommand) 
  
GUIEditor = { 
    tab = {}, 
    window = {}, 
    tabpanel = {}, 
    button = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(0.34, 0.32, 0.36, 0.49, "SHOP", true) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetVisible(GUIEditor.window[1], false) 
  
        GUIEditor.tabpanel[1] = guiCreateTabPanel(0.01, 0.08, 0.97, 0.90, true, GUIEditor.window[1]) 
  
        GUIEditor.tab[1] = guiCreateTab(LangTextTable[languageCode][1], GUIEditor.tabpanel[1]) 
  
        GUIEditor.button[1] = guiCreateButton(0.06, 0.17, 0.10, 0.05, "xxx$", true, GUIEditor.tab[1]) 
  
        GUIEditor.tab[2] = guiCreateTab(LangTextTable[languageCode][2], GUIEditor.tabpanel[1]) 
  
        GUIEditor.button[2] = guiCreateButton(0.89, 0.04, 0.09, 0.05, "Close", true, GUIEditor.window[1])        
    end 
) 
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), 
function ( ) 
   if (source == GUIEditor.button[2]) then 
      guiSetVisible(GUIEditor.window[1],false) 
      showCursor(false) 
   end 
end 
) 
  
function shopwindow() 
   guiSetVisible(GUIEditor.window[1], true) 
   showCursor(true) 
end 
addCommandHandler("shop", shopwindow) 
addEvent("openShop",true) 
addEventHandler("openShop", getRootElement(), shopwindow) 

LangTextTable = { 
    ["en_US"] = { 
        "Medicine", 
        "Weapons", 
    }, 
    ["ro"] = { 
        "Medicina", 
        "Arme", 
    },       
} 
  
  

Link to comment

I think it's better than yours. Check this out :)

UPDATED

local languageCode = getLocalization()["code"] 
function checkTheLanguage() 
    if languageCode then 
        if not LangTextTable[languageCode] then 
            languageCode = "en_US" 
        end 
    end 
end 
addEventHandler("onClientResourceStart",root,checkTheLanguage) 

Edited by Guest
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...