Quantcast
Download
(1 Kb)
Download
Updated: 03/04/19 04:47 PM
Compatibility:
Wrathstone (4.3)
Updated:03/04/19 04:47 PM
Created:02/26/19 10:38 AM
Monthly downloads:3,883
Total downloads:9,227
Favorites:40
MD5:
LibGetText  Popular! (More than 5000 hits)
Version: 1.0.1
by: sirinsidiator [More]
A small library that is used to provide gettext localization in ESO.

Documentation will follow one day.
v1.0.1
- fixed incorrect argument being used for addon identifier
Archived Files (1)
File Name
Version
Size
Uploader
Date
1.0.0
1kB
sirinsidiator
02/26/19 10:38 AM


Post A Reply Comment Options
Unread 03/04/19, 01:22 PM  
swtrse

Forum posts: 0
File comments: 2
Uploads: 0
Re: Re: Alternative Code

Originally Posted by sirinsidiator
There is no real difference in the code you posted. It's mostly a matter of preference how you write it. I reuse parts of it between multiple libraries, so it is easier for me to use generic names and only specify the full library name in one place. That way I do not have to change everything when I copy it over.
thanks for the feedback. I'm realy appreciate it.
Report comment to moderator  
Reply With Quote
Unread 03/03/19, 11:29 AM  
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view AddOns

Forum posts: 1221
File comments: 755
Uploads: 32
Originally Posted by merlight
Lua Code:
  1. local function GetInstance(addon)
has obscure bug in both, though. The first argument that the __call metafunction receives is the object that's being called, i.e. LibGetText

Lua Code:
  1. local function GetInstance(self, addon)
  2.     local dict = self.instance[addon]
  3.     if dict == nil then
  4.         dict = Dictionary:New()
  5.         self.instance[addon] = dict
  6.     end
  7.     return dict
  8. end
Thanks. It will be fixed in the next version.
__________________
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
I finally got a Patreon page!
Report comment to moderator  
Reply With Quote
Unread 03/03/19, 11:08 AM  
merlight
AddOn Author - Click to view AddOns

Forum posts: 665
File comments: 212
Uploads: 12
Lua Code:
  1. local function GetInstance(addon)
has obscure bug in both, though. The first argument that the __call metafunction receives is the object that's being called, i.e. LibGetText

Lua Code:
  1. local function GetInstance(self, addon)
  2.     local dict = self.instance[addon]
  3.     if dict == nil then
  4.         dict = Dictionary:New()
  5.         self.instance[addon] = dict
  6.     end
  7.     return dict
  8. end
Report comment to moderator  
Reply With Quote
Unread 03/03/19, 10:40 AM  
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view AddOns

Forum posts: 1221
File comments: 755
Uploads: 32
Re: Alternative Code

There is no real difference in the code you posted. It's mostly a matter of preference how you write it. I reuse parts of it between multiple libraries, so it is easier for me to use generic names and only specify the full library name in one place. That way I do not have to change everything when I copy it over.
__________________
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
I finally got a Patreon page!
Report comment to moderator  
Reply With Quote
Unread 03/03/19, 08:19 AM  
swtrse

Forum posts: 0
File comments: 2
Uploads: 0
Alternative Code

I took a quick look at the code of this small library.
I'm am just a beginer and try to figure out lua and the eso api
I came up with my own version and would ask if that version is cleaner and if not why.
Lua Code:
  1. LibGetText = {instance = {}}
  2. LibGetText.name = "LibGetText"
  3.  
  4. local Dictionary = ZO_Object:Subclass()
  5.  
  6. function Dictionary:New()
  7.     local object = ZO_Object.New(self)
  8.     object.dict = {}
  9.     object.settext = function(...)
  10.         object:SetText(...)
  11.     end
  12.     object.gettext = function(...)
  13.         return object:GetText(...)
  14.     end
  15.     return object
  16. end
  17.  
  18. function Dictionary:GetText(text, ...)
  19.     text = self.dict[text] or text
  20.  
  21.     if(select("#", ...) > 0) then
  22.         return zo_strformat(text, ...)
  23.     end
  24.  
  25.     return text
  26. end
  27.  
  28. function Dictionary:SetText(text, translation)
  29.     self.dict[text] = translation
  30. end
  31.  
  32. local function GetInstance(addon)
  33.     if(not LibGetText.instance[addon]) then
  34.         LibGetText.instance[addon] = Dictionary:New()
  35.     end
  36.     return LibGetText.instance[addon]
  37. end
  38.  
  39. setmetatable(LibGetText, { __call = GetInstance })
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump:

Support AddOn Development!

You have just downloaded by the author . If you like this AddOn why not consider supporting the author? This author has set up a donation account. Donations ensure that authors can continue to develop useful tools for everyone.