/trunk/libs
--- **AceLocale-3.0** manages localization in addons, allowing for multiple locale to be registered with fallback to the base locale for untranslated strings. |
-- @class file |
-- @name AceLocale-3.0 |
-- @release $Id: AceLocale-3.0.lua 895 2009-12-06 16:28:55Z nevcairiel $ |
local MAJOR,MINOR = "AceLocale-3.0", 2 |
-- @release $Id: AceLocale-3.0.lua 1005 2011-01-29 14:19:43Z mikk $ |
local MAJOR,MINOR = "AceLocale-3.0", 5 |
local AceLocale, oldminor = LibStub:NewLibrary(MAJOR, MINOR) |
-- @param application Unique name of addon / module |
-- @param locale Name of the locale to register, e.g. "enUS", "deDE", etc. |
-- @param isDefault If this is the default locale being registered (your addon is written in this language, generally enUS) |
-- @param silent If true, the locale will not issue warnings for missing keys. Can only be set on the default locale. |
-- @param silent If true, the locale will not issue warnings for missing keys. Must be set on the first locale registered. If set to "raw", nils will be returned for unknown keys (no metatable used). |
-- @usage |
-- -- enUS.lua |
-- local L = LibStub("AceLocale-3.0"):NewLocale("TestLocale", "enUS", true) |
-- @return Locale Table to add localizations to, or nil if the current locale is not required. |
function AceLocale:NewLocale(application, locale, isDefault, silent) |
if silent and not isDefault then |
error("Usage: NewLocale(application, locale[, isDefault[, silent]]): 'silent' can only be specified for the default locale", 2) |
end |
-- GAME_LOCALE allows translators to test translations of addons without having that wow client installed |
-- Ammo: I still think this is a bad idea, for instance an addon that checks for some ingame string will fail, just because some other addon |
-- gives the user the illusion that they can run in a different locale? Ditch this whole thing or allow a setting per 'application'. I'm of the |
-- opinion to remove this. |
local gameLocale = GAME_LOCALE or gameLocale |
if locale ~= gameLocale and not isDefault then |
return -- nop, we don't need these translations |
local app = AceLocale.apps[application] |
if silent and app then |
geterrorhandler()("Usage: NewLocale(application, locale[, isDefault[, silent]]): 'silent' must be specified for the first locale registered") |
end |
local app = AceLocale.apps[application] |
if not app then |
app = setmetatable({}, silent and readmetasilent or readmeta) |
if silent=="raw" then |
app = {} |
else |
app = setmetatable({}, silent and readmetasilent or readmeta) |
end |
AceLocale.apps[application] = app |
AceLocale.appnames[app] = application |
end |
if locale ~= gameLocale and not isDefault then |
return -- nop, we don't need these translations |
end |
registering = app -- remember globally for writeproxy and writedefaultproxy |
if isDefault then |
--[[ |
LibDualSpec-1.0 - Adds dual spec support to individual AceDB-3.0 databases |
Copyright (C) 2009 Adirelle |
Copyright (C) 2009-2011 Adirelle |
All rights reserved. |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
--]] |
local MAJOR, MINOR = "LibDualSpec-1.0", 4 |
local MAJOR, MINOR = "LibDualSpec-1.0", 9 |
assert(LibStub, MAJOR.." requires LibStub") |
local lib = LibStub:NewLibrary(MAJOR, MINOR) |
if not lib then return end |
-- Library data |
-- ---------------------------------------------------------------------------- |
lib.talentGroup = lib.talentGroup or GetActiveTalentGroup() |
lib.eventFrame = lib.eventFrame or CreateFrame("Frame") |
lib.registry = lib.registry or {} |
local locale = GetLocale() |
if locale == "frFR" then |
L_DUALSPEC_DESC = "Lorsqu'elle est activée, cette fonctionnalité vous permet ".. |
"de choisir un profil différent pour chaque spécialisation de talents. ".. |
"Le second profil sera échangé avec le profil courant chaque fois que vous ".. |
"passerez d'une spécialisation à l'autre." |
L_ENABLED = 'Activez le second profil' |
L_ENABLED_DESC = "Cochez cette case pour échanger automatiquement les profils ".. |
"lors d'un changement de spécialisation." |
L_DUAL_PROFILE = 'Second profil' |
L_DUAL_PROFILE_DESC = "Sélectionnez le profil à échanger avec le profil courant ".. |
"lors du changement de spécialisation." |
L_DUALSPEC_DESC = "Lorsqu'elle est activée, cette fonctionnalité vous permet de choisir un profil différent pour chaque spécialisation de talents. Le second profil sera échangé avec le profil courant chaque fois que vous passerez d'une spécialisation à l'autre." |
L_DUAL_PROFILE = "Second profil" |
L_DUAL_PROFILE_DESC = "Sélectionnez le profil à échanger avec le profil courant lors du changement de spécialisation." |
L_ENABLED = "Activez le second profil" |
L_ENABLED_DESC = "Cochez cette case pour échanger automatiquement les profils lors d'un changement de spécialisation." |
elseif locale == "deDE" then |
L_DUALSPEC_DESC = "Wenn aktiv, wechselt dieses Feature bei jedem Wechsel der dualen Talentspezialisierung das Profil. Das duale Profil wird beim Wechsel automatisch mit dem derzeit aktiven Profil getauscht." |
L_DUAL_PROFILE = "Duales Profil" |
L_DUAL_PROFILE_DESC = "W\195\164hle das Profil, das beim Wechsel der Talente aktiviert wird." |
L_DUALSPEC_DESC = "Wenn aktiv, wechselt dieses Feature bei jedem Wechsel ".. |
"der dualen Talentspezialisierung das Profil. Das duale Profil wird beim ".. |
"Wechsel automatisch mit dem derzeit aktiven Profil getauscht." |
L_DUAL_PROFILE_DESC = "Wähle das Profil, das beim Wechsel der Talente aktiviert wird." |
L_ENABLED = "Aktiviere Duale Profile" |
L_ENABLED_DESC = "Aktiviere diese Option, um beim Talentwechsel automatisch ".. |
"zwischen den Profilen zu wechseln." |
L_ENABLED_DESC = "Aktiviere diese Option, um beim Talentwechsel automatisch zwischen den Profilen zu wechseln." |
elseif locale == "koKR" then |
L_DUALSPEC_DESC = "ê°ë¥íë©´ ì¬ì©í©ëë¤. ì´ì¤ í¹ì±ì ìíì¬ ë¤ë¥¸ íë¡íì ì íí ì ìê² íëë¤. ì´ì¤ íë¡íì íì¬ íë¡íê³¼ ë²ê°ìì í¹ì±ì´ ë³ê²½ë ë ê°ì´ ì ì©ë©ëë¤." |
L_DUAL_PROFILE = "ì´ì¤ íë¡í" |
L_DUAL_PROFILE_DESC = "í¹ì±ì´ ë°ë ë íë¡íì ì íí©ëë¤." |
L_ENABLED = "ì´ì¤ íë¡í ì¬ì©" |
L_ENABLED_DESC = "í¹ì±ì´ ë³ê²½ ë ë ìëì¼ë¡ íë¡íì ë³ê²½íëë¡ ì íí©ëë¤." |
elseif locale == "ruRU" then |
L_DUALSPEC_DESC = "Ðвойной пÑоÑÐ¸Ð»Ñ Ð¿Ð¾Ð·Ð²Ð¾Ð»ÑÐµÑ Ð²Ð°Ð¼ вÑбÑаÑÑ ÑазлиÑнÑе пÑоÑили Ð´Ð»Ñ ÐºÐ°Ð¶Ð´Ð¾Ð¹ ÑаÑкладки ÑаланÑов. ÐÑоÑили бÑдÑÑ Ð¿ÐµÑеклÑÑаÑÑÑÑ ÐºÐ°Ð¶Ð´Ñй Ñаз, когда Ð²Ñ Ð¿ÐµÑеклÑÑаеÑе ÑаÑÐºÐ»Ð°Ð´ÐºÑ ÑаланÑов." |
L_DUAL_PROFILE = "ÐÑоÑой пÑоÑилÑ" |
L_DUAL_PROFILE_DESC = "ÐÑбеÑиÑе пÑоÑилÑ, коÑоÑÑй Ð½ÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼Ð¾ акÑивиÑоваÑÑ Ð¿Ñи пеÑеклÑÑениии ÑаланÑов." |
L_ENABLED = "ÐклÑÑиÑÑ Ð´Ð²Ð¾Ð¹Ð½Ð¾Ð¹ пÑоÑилÑ" |
L_ENABLED_DESC = "ÐклÑÑиÑе ÑÑÑ Ð¾Ð¿ÑÐ¸Ñ Ð´Ð»Ñ Ð°Ð²ÑомаÑиÑеÑкого пеÑеклÑÑÐµÐ½Ð¸Ñ Ð¼ÐµÐ¶Ð´Ñ Ð¿ÑоÑилÑми пÑи пеÑеклÑÑении ÑаÑкладки ÑаланÑов." |
elseif locale == "zhCN" then |
L_DUALSPEC_DESC = "å¯æ¶ï¼ä½ å¯ä»¥ä¸ºä½ çå天èµè®¾å®å¦ä¸ç»é ç½®æ件ï¼ä½ çåéé ç½®æ件å°å¨ä½ 转æ¢å¤©èµæ¶èªå¨ä¸ç®å使ç¨é ç½®æ件交æ¢ã" |
L_DUAL_PROFILE = "åéé ç½®æ件" |
L_DUAL_PROFILE_DESC = "éæ©è½¬æ¢å¤©èµæ¶æè¦ä½¿ç¨çé ç½®æ件" |
L_DUALSPEC_DESC = "å¯æ¶ï¼ä½ å¯ä»¥ä¸ºä½ çå天èµè®¾å®å¦ä¸ç»é ç½®æ件ï¼ä½ çåéé ç½®æ件å°å¨ä½ 转æ¢å¤©èµæ¶èªå¨ä¸ç®å使ç¨é ç½®æ件交æ¢ã" |
L_ENABLED = "å¼å¯åéé ç½®æ件" |
L_ENABLED_DESC = "å¾é以便转æ¢å¤©èµæ¶èªå¨äº¤æ¢é ç½®æ件ã" |
elseif locale == "zhTW" then |
L_DUALSPEC_DESC = "åç¨æï¼ä½ å¯ä»¥çºä½ çé天賦è¨å®å¦ä¸çµè¨å®æªãä½ çéè¨å®æªå°å¨ä½ è½æ天賦æèªåèç®å使ç¨è¨å®æªäº¤æã" |
L_DUAL_PROFILE = "éè¨å®æª" |
L_DUAL_PROFILE_DESC = "é¸æè½æ天賦å¾æè¦ä½¿ç¨çè¨å®æª" |
L_ENABLED = "åç¨éè¨å®æª" |
L_ENABLED_DESC = "å¾é¸ä»¥å¨è½æ天賦æèªå交æè¨å®æª" |
L_DUAL_PROFILE = "éè¨å®æª" |
L_DUAL_PROFILE_DESC = "é¸æè½æ天賦å¾æè¦ä½¿ç¨çè¨å®æª" |
elseif locale == "esES" then |
L_DUALSPEC_DESC = "Si está activa, esta caracterÃstica te permite seleccionar un perfil distinto para cada configuración de talentos. El perfil secundario será intercambiado por el activo cada vez que cambies de una configuración de talentos a otra." |
L_DUAL_PROFILE = "Perfil secundario" |
L_DUAL_PROFILE_DESC = "Elige el perfil secundario que se usará cuando cambies de talentos." |
L_ENABLED = "Activar perfil secundario" |
L_ENABLED_DESC = "Activa esta casilla para alternar automáticamente entre prefiles cuando cambies de talentos." |
end |
end |
-- Mixin |
-- ---------------------------------------------------------------------------- |
--- Get dual spec feature status. |
--- Get dual spec feature status. |
-- @return (boolean) true is dual spec feature enabled. |
-- @name enhancedDB:IsDualSpecEnabled |
function mixin:IsDualSpecEnabled() |
if enabled and not db.char.talentGroup then |
db.char.talentGroup = lib.talentGroup |
db.char.profile = self:GetCurrentProfile() |
db.char.enabled = true |
db.char.enabled = true |
else |
db.char.enabled = enabled |
self:CheckDualSpecState() |
--- Set the alternate profile name. |
-- No validation are done to ensure the profile is valid. |
-- @param profileName (string) the profile name to use. |
-- @param profileName (string) the profile name to use. |
-- @name enhancedDB:SetDualSpecProfile |
function mixin:SetDualSpecProfile(profileName) |
registry[self].db.char.profile = profileName |
-- @name enhancedDB:CheckDualSpecState |
function mixin:CheckDualSpecState() |
local db = registry[self].db |
if db.char.enabled and db.char.talentGroup ~= lib.talentGroup then |
if lib.talentsLoaded and db.char.enabled and db.char.talentGroup ~= lib.talentGroup then |
local currentProfile = self:GetCurrentProfile() |
local newProfile = db.char.profile |
db.char.talentGroup = lib.talentGroup |
if newProfile ~= currentProfile then |
db.char.profile = currentProfile |
self:SetProfile(newProfile) |
db.char.profile = currentProfile |
end |
end |
end |
EmbedMixin(target) |
end |
-- Actually enhance the database |
-- This is used on first initialization and everytime the database is reset using :ResetDB |
function lib:_EnhanceDatabase(event, target) |
registry[target].db = target:GetNamespace(MAJOR, true) or target:RegisterNamespace(MAJOR) |
EmbedMixin(target) |
target:CheckDualSpecState() |
end |
--- Embed dual spec feature into an existing AceDB-3.0 database. |
-- LibDualSpec specific methods are added to the instance. |
-- @name LibDualSpec:EnhanceDatabase |
elseif registry[target] then |
return |
end |
local db = target:GetNamespace(MAJOR, true) or target:RegisterNamespace(MAJOR) |
registry[target] = { name = name, db = db } |
EmbedMixin(target) |
target:CheckDualSpecState() |
registry[target] = { name = name } |
lib:_EnhanceDatabase("EnhanceDatabase", target) |
target.RegisterCallback(lib, "OnDatabaseReset", "_EnhanceDatabase") |
end |
-- ---------------------------------------------------------------------------- |
lib.eventFrame:RegisterEvent('PLAYER_TALENT_UPDATE') |
lib.eventFrame:SetScript('OnEvent', function() |
lib.talentsLoaded = true |
local newTalentGroup = GetActiveTalentGroup() |
if lib.talentGroup ~= newTalentGroup then |
lib.talentGroup = newTalentGroup |
end |
end) |