• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How to localize map?

Status
Not open for further replies.
Trigger strings are stored in the war3map.wts file. You can add support for multiple localizations by importing a separate war3map.wts for each language. This can be done with Ladislav's MPQ Editor by right clicking your file and choosing "Set File Locale". With this method you can translate much of your map, including the map name and descriptions.

You can also use some JASS tricks to get the clients language:

JASS:
function GetLocalLanguage takes nothing returns string
    local string s = GetLocalizedString("CHEATENABLED")
 
    if (s == "Cheat enabled!") then
        return "English"
    else if (s == "Cheat aktiviert!") then
        return "German"
    endif
 
    return s
endfunction

The above function checks a localized string to determine what language the client is using. The downside to this you cannot detect locale, only language.

If you want to detect client locale through JASS, you will have to do something like this:

JASS:
function GetLocale takes nothing returns string
    local player p = GetLocalPlayer()
    local string s = GetPlayerName(p)
    local string locale = ""
 
    call StartCampaignAI(Player(PLAYER_NEUTRAL_AGGRESSIVE), "locale\\detect.ai")
 
    set locale = GetPlayerName(p)
 
    call SetPlayerName(p, s)
 
    if (locale == s) then
        return "Unknown"
    endif
 
    return locale
endfunction

Along with that function, you will need to add "locale\\detect.ai" to the MPQ for each game locale you want to detect. I uploaded a map as an example which can detect enUS or koKR.
 

Attachments

  • langtest.w3x
    18 KB · Views: 57
Last edited:
Status
Not open for further replies.
Top