Jump to content
Alloder.pro  about Allods with love 😱
Search In
  • More options...
Find results that contain...
Find results in...

Results of the competition "Allods and Life"

Stories, that warm souls.

Read More

Digest April

We talk about what was done and updated in the past month. We help keep abreast of events.

Read more

Game tooltips

Tooltips provide a way for 3rd party fansites and extensions to display detailed information on mouseover.

Read more

Localization of addons


Recommended Posts

More and more players from the European server are now downloading addons. But there are a lot of addons that are not translated for English, French, German or Turkish clients. 

 

Localizing an addon is not hard. This is the code I use (

 

Global("localization", "eng_eu")
-- +----------------------------------+
-- |AO game Localization detection    |
-- |New conceptual detection by Ciuine|
-- |Aesthetically improved by Ramirez |
-- +----------------------------------+


local function GetGameLocalization()
     local id = options.GetOptionsByCustomType( "interface_option_localization" )[ 0 ]
     if id then
         local values = options.GetOptionInfo( id ).values
         local value = values and values[ 0 ]
         local name = value and value.name
         if name then
             return userMods.FromWString( name )
         else
              return localization
          end
     end
end
localization = GetGameLocalization()
function GTL( strTextName )
    return Locales[ localization ][ strTextName ] or Locales[ "eng_eu" ][ strTextName ] or strTextName
end
 
 

The global variable localization will store the language of the client. It is also the default language. In case the language detection fails, this is the language that the addon will use. I suggest setting it to eng_eu because chances are high that the user knows english. As far as I know, supported languages are rus (Russian), eng_eu (English), fra (French), ger (German) and tr (Turkish).

 

The function GetGameLocalization() is the function that detects and returns the language of the client. 

 

The function GTL( strTextName ) takes a string as a parameter and returns the localized version, found in the Locales table. This is the Locales table of the KillAnnounce addon:

 

--------------------------------------------------------------------------------
-- KillAnnounce LOCALES (2.1)
-- RUS, ENG_EU, FRA, GER, TR
-- If you find any mistakes or can provide additional localization, send me a PM on Alloder.pro (https://alloder.pro/user/1245-cristi-mirt/)
-- or email me at [email protected]
--------------------------------------------------------------------------------
 
Global( "Locales", {
    ["eng_eu"] = { -- English, Latin-1
        ["You killed"] = "You killed %s!",
        ["You were killed by"] = "You were killed by %s!",
        ["killed"] = "%s killed %s!",
    },
    ["rus"] = { -- Russian, Win-1251
        ["You killed"] = "Вы убили %s!",
        ["You were killed by"] = "Вы были убиты %s!",
        ["killed"] = "%s убил %s",
    },
    ["ger"] = { -- German, Win-1252
        ["You killed"] = "Du hast %s getötet!",
        ["You were killed by"] = "Du wurdest von %s getötet!",
        ["killed"] = "%s hat %s getötet!",
    },
    ["fra"] = { -- French, Win-1252
        ["You killed"] = "Vous avez tué %s!",
        ["You were killed by"] = "Vous avez été tué par %s!",
        ["killed"] = "%s a tué %s!",
    },
    ["tr"] = { -- Turkish, Win-1254
        ["You killed"] = "Sen %s öldürdü!",
        ["You were killed by"] = "Sen %s tarafından öldürüldü!",
        ["killed"] = "%s %s öldürdü!",
    }
} )

Localization_example.zip

Link to comment
Share on other sites

I forgot to add an important part. The code of the function and the Locales table must be initialized before the main init() function of the addon is called. The way I do it is to have the code (GetGameLocalization() and GTL()) in one file, and the Locales table in a different file, and add them in AddonDesc.(UIAddon).xdb before the main script.

After all this is done, all you have to do is call GTL(stringName), and it will return the localization for the detected language, if there is a "stringName" item in the Locales table for the detected language. If not, it will try to return the localization for the default language. If that also fails, it will return the original string.

I suggest using a different file for the Locales table in case you plan to compile your code. That way, users will be able to correct translation errors and send us the file to update the addon.

If you have any addons that are not localized, I ask of you to at least localize them in English. I can help if you want, and I might also be able to help with the other languages.

  • Thanks 1
Link to comment
Share on other sites

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

By using our site you agree to the Terms of Use