Перейти к содержанию

Дайджесты за январь-февраль

Обновления гайдов и аддонов

Январь Февраль

Мониторинг серверов и редактор аддонов

Представляем вам две легенды. То, о чем можно было только мечтать, стало реальностью.

Мониторинг серверов Редактор аддонов

Подсказки из игры на вашем сайте

Теперь вы можете отображать сведения о внутриигровых элементах простым наведением курсора мыши.

Подробнее

Апдейтер аддонов

Представляем вам программу для автообновления аддонов и делимся подробностями.

Подробнее Скачать

Localization of addons


Рекомендуемые сообщения

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

Ссылка на комментарий
Поделиться на другие сайты

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.

Ссылка на комментарий
Поделиться на другие сайты

Гость
Ответить в этой теме...

×   Вставлено с форматированием.   Восстановить форматирование

  Разрешено использовать не более 75 эмодзи.

×   Ваша ссылка была автоматически встроена.   Отображать как обычную ссылку

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Вы не можете вставлять изображения напрямую. Загружайте или вставляйте изображения по ссылке.

×
×
  • Создать...

Важная информация

Пользуясь сайтом, вы принимаете Условия использования