annotate libs/AceLocale-2.0/AceLocale-2.0.lua @ 1:c11ca1d8ed91

Version 0.1
author Flick <flickerstreak@gmail.com>
date Tue, 20 Mar 2007 21:03:57 +0000
parents
children
rev   line source
flickerstreak@1 1 --[[
flickerstreak@1 2 Name: AceLocale-2.0
flickerstreak@1 3 Revision: $Rev: 18753 $
flickerstreak@1 4 Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team)
flickerstreak@1 5 Inspired By: Ace 1.x by Turan (turan@gryphon.com)
flickerstreak@1 6 Website: http://www.wowace.com/
flickerstreak@1 7 Documentation: http://www.wowace.com/index.php/AceLocale-2.0
flickerstreak@1 8 SVN: http://svn.wowace.com/root/trunk/Ace2/AceLocale-2.0
flickerstreak@1 9 Description: Localization library for addons to use to handle proper
flickerstreak@1 10 localization and internationalization.
flickerstreak@1 11 Dependencies: AceLibrary
flickerstreak@1 12 ]]
flickerstreak@1 13
flickerstreak@1 14 local MAJOR_VERSION = "AceLocale-2.0"
flickerstreak@1 15 local MINOR_VERSION = "$Revision: 18753 $"
flickerstreak@1 16
flickerstreak@1 17 if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary.") end
flickerstreak@1 18 if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
flickerstreak@1 19
flickerstreak@1 20 local AceLocale = {}
flickerstreak@1 21
flickerstreak@1 22 local DEFAULT_LOCALE = "enUS"
flickerstreak@1 23 local _G = getfenv(0)
flickerstreak@1 24
flickerstreak@1 25 local __baseTranslations__, __debugging__, __translations__, __baseLocale__, __translationTables__, __reverseTranslations__, __strictness__
flickerstreak@1 26
flickerstreak@1 27 local __call = function(self, key1, key2)
flickerstreak@1 28 if key2 then
flickerstreak@1 29 return self[key1][key2]
flickerstreak@1 30 else
flickerstreak@1 31 return self[key1]
flickerstreak@1 32 end
flickerstreak@1 33 end
flickerstreak@1 34
flickerstreak@1 35 local rawget = rawget
flickerstreak@1 36 local rawset = rawset
flickerstreak@1 37 local type = type
flickerstreak@1 38
flickerstreak@1 39 local lastSelf
flickerstreak@1 40
flickerstreak@1 41 local __index = function(self, key)
flickerstreak@1 42 lastSelf = self
flickerstreak@1 43 local value = (rawget(self, __translations__) or AceLocale.prototype)[key]
flickerstreak@1 44 rawset(self, key, value)
flickerstreak@1 45 return value
flickerstreak@1 46 end
flickerstreak@1 47
flickerstreak@1 48 local __newindex = function(self, k, v)
flickerstreak@1 49 if type(v) ~= "function" and type(k) ~= "table" then
flickerstreak@1 50 AceLocale.error(self, "Cannot change the values of an AceLocale instance.")
flickerstreak@1 51 end
flickerstreak@1 52 rawset(self, k, v)
flickerstreak@1 53 end
flickerstreak@1 54
flickerstreak@1 55 local __tostring = function(self)
flickerstreak@1 56 if type(rawget(self, 'GetLibraryVersion')) == "function" then
flickerstreak@1 57 return self:GetLibraryVersion()
flickerstreak@1 58 else
flickerstreak@1 59 return "AceLocale(" .. self[__name__] .. ")"
flickerstreak@1 60 end
flickerstreak@1 61 end
flickerstreak@1 62
flickerstreak@1 63 local refixInstance = function(instance)
flickerstreak@1 64 if getmetatable(instance) then
flickerstreak@1 65 setmetatable(instance, nil)
flickerstreak@1 66 end
flickerstreak@1 67 local translations = instance[__translations__]
flickerstreak@1 68 if translations then
flickerstreak@1 69 if getmetatable(translations) then
flickerstreak@1 70 setmetatable(translations, nil)
flickerstreak@1 71 end
flickerstreak@1 72 local baseTranslations = instance[__baseTranslations__]
flickerstreak@1 73 if getmetatable(baseTranslations) then
flickerstreak@1 74 setmetatable(baseTranslations, nil)
flickerstreak@1 75 end
flickerstreak@1 76 if translations == baseTranslations or instance[__strictness__] then
flickerstreak@1 77 setmetatable(instance, {
flickerstreak@1 78 __index = __index,
flickerstreak@1 79 __newindex = __newindex,
flickerstreak@1 80 __call = __call,
flickerstreak@1 81 __tostring = __tostring
flickerstreak@1 82 })
flickerstreak@1 83
flickerstreak@1 84 setmetatable(translations, {
flickerstreak@1 85 __index = AceLocale.prototype
flickerstreak@1 86 })
flickerstreak@1 87 else
flickerstreak@1 88 setmetatable(instance, {
flickerstreak@1 89 __index = __index,
flickerstreak@1 90 __newindex = __newindex,
flickerstreak@1 91 __call = __call,
flickerstreak@1 92 __tostring = __tostring
flickerstreak@1 93 })
flickerstreak@1 94
flickerstreak@1 95 setmetatable(translations, {
flickerstreak@1 96 __index = baseTranslations,
flickerstreak@1 97 })
flickerstreak@1 98
flickerstreak@1 99 setmetatable(baseTranslations, {
flickerstreak@1 100 __index = AceLocale.prototype,
flickerstreak@1 101 })
flickerstreak@1 102 end
flickerstreak@1 103 else
flickerstreak@1 104 setmetatable(instance, {
flickerstreak@1 105 __index = __index,
flickerstreak@1 106 __newindex = __newindex,
flickerstreak@1 107 __call = __call,
flickerstreak@1 108 __tostring = __tostring,
flickerstreak@1 109 })
flickerstreak@1 110 end
flickerstreak@1 111 end
flickerstreak@1 112
flickerstreak@1 113 function AceLocale:new(name)
flickerstreak@1 114 error(MAJOR_VERSION .. " is not supported in WoW 2.0", 2)
flickerstreak@1 115 self:argCheck(name, 2, "string")
flickerstreak@1 116
flickerstreak@1 117 if self.registry[name] and type(rawget(self.registry[name], 'GetLibraryVersion')) ~= "function" then
flickerstreak@1 118 return self.registry[name]
flickerstreak@1 119 end
flickerstreak@1 120
flickerstreak@1 121 local self = {
flickerstreak@1 122 [__strictness__] = false,
flickerstreak@1 123 [__name__] = name,
flickerstreak@1 124 }
flickerstreak@1 125 refixInstance(self)
flickerstreak@1 126
flickerstreak@1 127 AceLocale.registry[name] = self
flickerstreak@1 128 return self
flickerstreak@1 129 end
flickerstreak@1 130
flickerstreak@1 131 setmetatable(AceLocale, { __call = AceLocale.new })
flickerstreak@1 132
flickerstreak@1 133 AceLocale.prototype = {}
flickerstreak@1 134 AceLocale.prototype.class = AceLocale
flickerstreak@1 135
flickerstreak@1 136 function AceLocale.prototype:EnableDebugging()
flickerstreak@1 137 if rawget(self, __baseTranslations__) then
flickerstreak@1 138 AceLocale:error("Cannot enable debugging after a translation has been registered.")
flickerstreak@1 139 end
flickerstreak@1 140 rawset(self, __debugging__, true)
flickerstreak@1 141 end
flickerstreak@1 142
flickerstreak@1 143 function AceLocale.prototype:RegisterTranslations(locale, func)
flickerstreak@1 144 AceLocale.argCheck(self, locale, 2, "string")
flickerstreak@1 145 AceLocale.argCheck(self, func, 3, "function")
flickerstreak@1 146
flickerstreak@1 147 if locale == rawget(self, __baseLocale__) then
flickerstreak@1 148 AceLocale.error(self, "Cannot provide the same locale more than once. %q provided twice.", locale)
flickerstreak@1 149 end
flickerstreak@1 150
flickerstreak@1 151 if rawget(self, __baseTranslations__) and GetLocale() ~= locale then
flickerstreak@1 152 if rawget(self, __debugging__) then
flickerstreak@1 153 local t = func()
flickerstreak@1 154 func = nil
flickerstreak@1 155 if type(t) ~= "table" then
flickerstreak@1 156 AceLocale.error(self, "Bad argument #3 to `RegisterTranslations'. function did not return a table. (expected table, got %s)", type(t))
flickerstreak@1 157 end
flickerstreak@1 158 self[__translationTables__][locale] = t
flickerstreak@1 159 t = nil
flickerstreak@1 160 end
flickerstreak@1 161 func = nil
flickerstreak@1 162 return
flickerstreak@1 163 end
flickerstreak@1 164 local t = func()
flickerstreak@1 165 func = nil
flickerstreak@1 166 if type(t) ~= "table" then
flickerstreak@1 167 AceLocale.error(self, "Bad argument #3 to `RegisterTranslations'. function did not return a table. (expected table, got %s)", type(t))
flickerstreak@1 168 end
flickerstreak@1 169
flickerstreak@1 170 rawset(self, __translations__, t)
flickerstreak@1 171 if not rawget(self, __baseTranslations__) then
flickerstreak@1 172 rawset(self, __baseTranslations__, t)
flickerstreak@1 173 rawset(self, __baseLocale__, locale)
flickerstreak@1 174 for key,value in pairs(t) do
flickerstreak@1 175 if value == true then
flickerstreak@1 176 t[key] = key
flickerstreak@1 177 end
flickerstreak@1 178 end
flickerstreak@1 179 else
flickerstreak@1 180 for key, value in pairs(self[__translations__]) do
flickerstreak@1 181 if not rawget(self[__baseTranslations__], key) then
flickerstreak@1 182 AceLocale.error(self, "Improper translation exists. %q is likely misspelled for locale %s.", key, locale)
flickerstreak@1 183 end
flickerstreak@1 184 if value == true then
flickerstreak@1 185 AceLocale.error(self, "Can only accept true as a value on the base locale. %q is the base locale, %q is not.", rawget(self, __baseLocale__), locale)
flickerstreak@1 186 end
flickerstreak@1 187 end
flickerstreak@1 188 end
flickerstreak@1 189 refixInstance(self)
flickerstreak@1 190 if rawget(self, __debugging__) then
flickerstreak@1 191 if not rawget(self, __translationTables__) then
flickerstreak@1 192 rawset(self, __translationTables__, {})
flickerstreak@1 193 end
flickerstreak@1 194 self[__translationTables__][locale] = t
flickerstreak@1 195 end
flickerstreak@1 196 t = nil
flickerstreak@1 197 end
flickerstreak@1 198
flickerstreak@1 199 function AceLocale.prototype:SetStrictness(strict)
flickerstreak@1 200 AceLocale.argCheck(self, strict, 2, "boolean")
flickerstreak@1 201 local mt = getmetatable(self)
flickerstreak@1 202 if not mt then
flickerstreak@1 203 AceLocale.error(self, "Cannot call `SetStrictness' without a metatable.")
flickerstreak@1 204 end
flickerstreak@1 205 if not rawget(self, __translations__) then
flickerstreak@1 206 AceLocale.error(self, "No translations registered.")
flickerstreak@1 207 end
flickerstreak@1 208 rawset(self, __strictness__, strict)
flickerstreak@1 209 refixInstance(self)
flickerstreak@1 210 end
flickerstreak@1 211
flickerstreak@1 212 function AceLocale.prototype:GetTranslationStrict(text, sublevel)
flickerstreak@1 213 AceLocale.argCheck(self, text, 1, "string")
flickerstreak@1 214 local translations = rawget(self, __translations__)
flickerstreak@1 215 if not translations then
flickerstreak@1 216 AceLocale.error(self, "No translations registered")
flickerstreak@1 217 end
flickerstreak@1 218 if sublevel then
flickerstreak@1 219 local t = rawget(translations, text)
flickerstreak@1 220 if type(t) ~= "table" then
flickerstreak@1 221 AceLocale.error(self, "Strict translation %q::%q does not exist", text, sublevel)
flickerstreak@1 222 end
flickerstreak@1 223 local value = t[sublevel]
flickerstreak@1 224 if not value then
flickerstreak@1 225 AceLocale.error(self, "Strict translation %q::%q does not exist", text, sublevel)
flickerstreak@1 226 end
flickerstreak@1 227 return value
flickerstreak@1 228 else
flickerstreak@1 229 local value = rawget(translations, text)
flickerstreak@1 230 if not value then
flickerstreak@1 231 AceLocale.error(self, "Strict translation %q does not exist", text)
flickerstreak@1 232 end
flickerstreak@1 233 return value
flickerstreak@1 234 end
flickerstreak@1 235 end
flickerstreak@1 236
flickerstreak@1 237 function AceLocale.prototype:GetTranslation(text, sublevel)
flickerstreak@1 238 AceLocale.argCheck(self, text, 1, "string")
flickerstreak@1 239 local translations = rawget(self, __translations__)
flickerstreak@1 240 if not translations then
flickerstreak@1 241 AceLocale.error(self, "No translations registered")
flickerstreak@1 242 end
flickerstreak@1 243 if sublevel then
flickerstreak@1 244 local base = self[__baseTranslations__]
flickerstreak@1 245 local standard = rawget(translations, text)
flickerstreak@1 246 local current
flickerstreak@1 247 local baseStandard
flickerstreak@1 248 if not standard then
flickerstreak@1 249 baseStandard = rawget(base, text)
flickerstreak@1 250 current = baseStandard
flickerstreak@1 251 end
flickerstreak@1 252 if not type(current) ~= "table" then
flickerstreak@1 253 AceLocale.error(self, "Loose translation %q::%q does not exist", text, sublevel)
flickerstreak@1 254 end
flickerstreak@1 255 local value = current[sublevel]
flickerstreak@1 256 if not value then
flickerstreak@1 257 if current == baseStandard or type(baseStandard) ~= "table" then
flickerstreak@1 258 AceLocale.error(self, "Loose translation %q::%q does not exist", text, sublevel)
flickerstreak@1 259 end
flickerstreak@1 260 value = baseStandard[sublevel]
flickerstreak@1 261 if not value then
flickerstreak@1 262 AceLocale.error(self, "Loose translation %q::%q does not exist", text, sublevel)
flickerstreak@1 263 end
flickerstreak@1 264 end
flickerstreak@1 265 return value
flickerstreak@1 266 else
flickerstreak@1 267 local value = rawget(translations, text)
flickerstreak@1 268 if not value then
flickerstreak@1 269 AceLocale.error(self, "Loose translation %q does not exist", text)
flickerstreak@1 270 end
flickerstreak@1 271 return value
flickerstreak@1 272 end
flickerstreak@1 273 end
flickerstreak@1 274
flickerstreak@1 275 local function initReverse(self)
flickerstreak@1 276 rawset(self, __reverseTranslations__, {})
flickerstreak@1 277 local alpha = self[__translations__]
flickerstreak@1 278 local bravo = self[__reverseTranslations__]
flickerstreak@1 279 for base, localized in pairs(alpha) do
flickerstreak@1 280 bravo[localized] = base
flickerstreak@1 281 end
flickerstreak@1 282 end
flickerstreak@1 283
flickerstreak@1 284 function AceLocale.prototype:GetReverseTranslation(text)
flickerstreak@1 285 local x = rawget(self, __reverseTranslations__)
flickerstreak@1 286 if not x then
flickerstreak@1 287 if not rawget(self, __translations__) then
flickerstreak@1 288 AceLocale.error(self, "No translations registered")
flickerstreak@1 289 end
flickerstreak@1 290 initReverse(self)
flickerstreak@1 291 x = self[__reverseTranslations__]
flickerstreak@1 292 end
flickerstreak@1 293 local translation = x[text]
flickerstreak@1 294 if not translation then
flickerstreak@1 295 AceLocale.error(self, "Reverse translation for %q does not exist", text)
flickerstreak@1 296 end
flickerstreak@1 297 return translation
flickerstreak@1 298 end
flickerstreak@1 299
flickerstreak@1 300 function AceLocale.prototype:GetIterator()
flickerstreak@1 301 local x = rawget(self, __translations__)
flickerstreak@1 302 if not x then
flickerstreak@1 303 AceLocale.error(self, "No translations registered")
flickerstreak@1 304 end
flickerstreak@1 305 return next, x, nil
flickerstreak@1 306 end
flickerstreak@1 307
flickerstreak@1 308 function AceLocale.prototype:GetReverseIterator()
flickerstreak@1 309 local x = rawget(self, __reverseTranslations__)
flickerstreak@1 310 if not x then
flickerstreak@1 311 if not rawget(self, __translations__) then
flickerstreak@1 312 AceLocale.error(self, "No translations registered")
flickerstreak@1 313 end
flickerstreak@1 314 initReverse(self)
flickerstreak@1 315 x = self[__reverseTranslations__]
flickerstreak@1 316 end
flickerstreak@1 317 return next, x, nil
flickerstreak@1 318 end
flickerstreak@1 319
flickerstreak@1 320 function AceLocale.prototype:HasTranslation(text, sublevel)
flickerstreak@1 321 AceLocale.argCheck(self, text, 1, "string")
flickerstreak@1 322 local x = rawget(self, __translations__)
flickerstreak@1 323 if not x then
flickerstreak@1 324 AceLocale.error(self, "No translations registered")
flickerstreak@1 325 end
flickerstreak@1 326 if sublevel then
flickerstreak@1 327 AceLocale.argCheck(self, sublevel, 2, "string", "nil")
flickerstreak@1 328 return type(rawget(x, text)) == "table" and x[text][sublevel] and true
flickerstreak@1 329 end
flickerstreak@1 330 return rawget(x, text) and true
flickerstreak@1 331 end
flickerstreak@1 332
flickerstreak@1 333 function AceLocale.prototype:HasReverseTranslation(text)
flickerstreak@1 334 local x = rawget(self, __reverseTranslations__)
flickerstreak@1 335 if not x then
flickerstreak@1 336 if not rawget(self, __translations__) then
flickerstreak@1 337 AceLocale.error(self, "No translations registered")
flickerstreak@1 338 end
flickerstreak@1 339 initReverse(self)
flickerstreak@1 340 x = self[__reverseTranslations__]
flickerstreak@1 341 end
flickerstreak@1 342 return x[text] and true
flickerstreak@1 343 end
flickerstreak@1 344
flickerstreak@1 345 AceLocale.prototype.GetTableStrict = AceLocale.prototype.GetTranslationStrict
flickerstreak@1 346 AceLocale.prototype.GetTable = AceLocale.prototype.GetTranslation
flickerstreak@1 347
flickerstreak@1 348 function AceLocale.prototype:Debug()
flickerstreak@1 349 if not rawget(self, __debugging__) then
flickerstreak@1 350 return
flickerstreak@1 351 end
flickerstreak@1 352 local words = {}
flickerstreak@1 353 local locales = {"enUS", "deDE", "frFR", "koKR", "zhCN", "zhTW"}
flickerstreak@1 354 local localizations = {}
flickerstreak@1 355 DEFAULT_CHAT_FRAME:AddMessage("--- AceLocale Debug ---")
flickerstreak@1 356 for _,locale in ipairs(locales) do
flickerstreak@1 357 if not self[__translationTables__][locale] then
flickerstreak@1 358 DEFAULT_CHAT_FRAME:AddMessage(string.format("Locale %q not found", locale))
flickerstreak@1 359 else
flickerstreak@1 360 localizations[locale] = self[__translationTables__][locale]
flickerstreak@1 361 end
flickerstreak@1 362 end
flickerstreak@1 363 local localeDebug = {}
flickerstreak@1 364 for locale, localization in pairs(localizations) do
flickerstreak@1 365 localeDebug[locale] = {}
flickerstreak@1 366 for word in pairs(localization) do
flickerstreak@1 367 if type(localization[word]) == "table" then
flickerstreak@1 368 if type(words[word]) ~= "table" then
flickerstreak@1 369 words[word] = {}
flickerstreak@1 370 end
flickerstreak@1 371 for bit in pairs(localization[word]) do
flickerstreak@1 372 if type(localization[word][bit]) == "string" then
flickerstreak@1 373 words[word][bit] = true
flickerstreak@1 374 end
flickerstreak@1 375 end
flickerstreak@1 376 elseif type(localization[word]) == "string" then
flickerstreak@1 377 words[word] = true
flickerstreak@1 378 end
flickerstreak@1 379 end
flickerstreak@1 380 end
flickerstreak@1 381 for word in pairs(words) do
flickerstreak@1 382 if type(words[word]) == "table" then
flickerstreak@1 383 for bit in pairs(words[word]) do
flickerstreak@1 384 for locale, localization in pairs(localizations) do
flickerstreak@1 385 if not rawget(localization, word) or not localization[word][bit] then
flickerstreak@1 386 localeDebug[locale][word .. "::" .. bit] = true
flickerstreak@1 387 end
flickerstreak@1 388 end
flickerstreak@1 389 end
flickerstreak@1 390 else
flickerstreak@1 391 for locale, localization in pairs(localizations) do
flickerstreak@1 392 if not rawget(localization, word) then
flickerstreak@1 393 localeDebug[locale][word] = true
flickerstreak@1 394 end
flickerstreak@1 395 end
flickerstreak@1 396 end
flickerstreak@1 397 end
flickerstreak@1 398 for locale, t in pairs(localeDebug) do
flickerstreak@1 399 if not next(t) then
flickerstreak@1 400 DEFAULT_CHAT_FRAME:AddMessage(string.format("Locale %q complete", locale))
flickerstreak@1 401 else
flickerstreak@1 402 DEFAULT_CHAT_FRAME:AddMessage(string.format("Locale %q missing:", locale))
flickerstreak@1 403 for word in pairs(t) do
flickerstreak@1 404 DEFAULT_CHAT_FRAME:AddMessage(string.format(" %q", word))
flickerstreak@1 405 end
flickerstreak@1 406 end
flickerstreak@1 407 end
flickerstreak@1 408 DEFAULT_CHAT_FRAME:AddMessage("--- End AceLocale Debug ---")
flickerstreak@1 409 end
flickerstreak@1 410
flickerstreak@1 411 setmetatable(AceLocale.prototype, {
flickerstreak@1 412 __index = function(self, k)
flickerstreak@1 413 if type(k) ~= "table" and k ~= 0 and k ~= "GetLibraryVersion" and k ~= "error" and k ~= "assert" and k ~= "argCheck" and k ~= "pcall" then -- HACK: remove "GetLibraryVersion" and such later.
flickerstreak@1 414 AceLocale.error(lastSelf or self, "Translation %q does not exist.", k)
flickerstreak@1 415 end
flickerstreak@1 416 return nil
flickerstreak@1 417 end
flickerstreak@1 418 })
flickerstreak@1 419
flickerstreak@1 420 local function activate(self, oldLib, oldDeactivate)
flickerstreak@1 421 AceLocale = self
flickerstreak@1 422
flickerstreak@1 423 if oldLib then
flickerstreak@1 424 self.registry = oldLib.registry
flickerstreak@1 425 self.__baseTranslations__ = oldLib.__baseTranslations__
flickerstreak@1 426 self.__debugging__ = oldLib.__debugging__
flickerstreak@1 427 self.__translations__ = oldLib.__translations__
flickerstreak@1 428 self.__baseLocale__ = oldLib.__baseLocale__
flickerstreak@1 429 self.__translationTables__ = oldLib.__translationTables__
flickerstreak@1 430 self.__reverseTranslations__ = oldLib.__reverseTranslations__
flickerstreak@1 431 self.__strictness__ = oldLib.__strictness__
flickerstreak@1 432 self.__name__ = oldLib.__name__
flickerstreak@1 433 end
flickerstreak@1 434 if not self.__baseTranslations__ then
flickerstreak@1 435 self.__baseTranslations__ = {}
flickerstreak@1 436 end
flickerstreak@1 437 if not self.__debugging__ then
flickerstreak@1 438 self.__debugging__ = {}
flickerstreak@1 439 end
flickerstreak@1 440 if not self.__translations__ then
flickerstreak@1 441 self.__translations__ = {}
flickerstreak@1 442 end
flickerstreak@1 443 if not self.__baseLocale__ then
flickerstreak@1 444 self.__baseLocale__ = {}
flickerstreak@1 445 end
flickerstreak@1 446 if not self.__translationTables__ then
flickerstreak@1 447 self.__translationTables__ = {}
flickerstreak@1 448 end
flickerstreak@1 449 if not self.__reverseTranslations__ then
flickerstreak@1 450 self.__reverseTranslations__ = {}
flickerstreak@1 451 end
flickerstreak@1 452 if not self.__strictness__ then
flickerstreak@1 453 self.__strictness__ = {}
flickerstreak@1 454 end
flickerstreak@1 455 if not self.__name__ then
flickerstreak@1 456 self.__name__ = {}
flickerstreak@1 457 end
flickerstreak@1 458
flickerstreak@1 459 __baseTranslations__ = self.__baseTranslations__
flickerstreak@1 460 __debugging__ = self.__debugging__
flickerstreak@1 461 __translations__ = self.__translations__
flickerstreak@1 462 __baseLocale__ = self.__baseLocale__
flickerstreak@1 463 __translationTables__ = self.__translationTables__
flickerstreak@1 464 __reverseTranslations__ = self.__reverseTranslations__
flickerstreak@1 465 __strictness__ = self.__strictness__
flickerstreak@1 466 __name__ = self.__name__
flickerstreak@1 467
flickerstreak@1 468 if not self.registry then
flickerstreak@1 469 self.registry = {}
flickerstreak@1 470 else
flickerstreak@1 471 for name, instance in pairs(self.registry) do
flickerstreak@1 472 local name = name
flickerstreak@1 473 local mt = getmetatable(instance)
flickerstreak@1 474 setmetatable(instance, nil)
flickerstreak@1 475 instance[__name__] = name
flickerstreak@1 476 local strict
flickerstreak@1 477 if instance.translations then
flickerstreak@1 478 instance[__translations__], instance.translations = instance.translations
flickerstreak@1 479 instance[__baseLocale__], instance.baseLocale = instance.baseLocale
flickerstreak@1 480 instance[__baseTranslations__], instance.baseTranslations = instance.baseTranslations
flickerstreak@1 481 instance[__debugging__], instance.debugging = instance.debugging
flickerstreak@1 482 instance.reverseTranslations = nil
flickerstreak@1 483 instance[__translationTables__], instance.translationTables = instance.translationTables
flickerstreak@1 484 if mt and mt.__call == oldLib.prototype.GetTranslationStrict then
flickerstreak@1 485 strict = true
flickerstreak@1 486 end
flickerstreak@1 487 else
flickerstreak@1 488 if instance[__strictness__] ~= nil then
flickerstreak@1 489 strict = instance[__strictness__]
flickerstreak@1 490 elseif instance[__translations__] ~= instance[__baseTranslations__] then
flickerstreak@1 491 if getmetatable(instance[__translations__]).__index == oldLib.prototype then
flickerstreak@1 492 strict = true
flickerstreak@1 493 end
flickerstreak@1 494 end
flickerstreak@1 495 end
flickerstreak@1 496 instance[__strictness__] = strict and true or false
flickerstreak@1 497 refixInstance(instance)
flickerstreak@1 498 end
flickerstreak@1 499 end
flickerstreak@1 500
flickerstreak@1 501 if oldDeactivate then
flickerstreak@1 502 oldDeactivate(oldLib)
flickerstreak@1 503 end
flickerstreak@1 504 end
flickerstreak@1 505
flickerstreak@1 506 AceLibrary:Register(AceLocale, MAJOR_VERSION, MINOR_VERSION, activate)