Download
(1 Kb)
Download
Updated: 05/21/19 02:53 PM
Compatibility:
Elsweyr (5.0.5)
Updated:05/21/19 02:53 PM
Created:02/26/19 10:38 AM
Monthly downloads:7,028
Total downloads:533,232
Favorites:440
MD5:
LibGetText  Popular! (More than 5000 hits)
Version: 1.0.2
by: sirinsidiator [More]
A small library that is used to provide gettext localization in ESO.

Documentation will follow one day.
v1.0.2
- added IsLibrary flag to manifest
- updated API version for Elsweyr

v1.0.1
- fixed incorrect argument being used for addon identifier
Archived Files (2)
File Name
Version
Size
Uploader
Date
1.0.1
1kB
sirinsidiator
03/04/19 04:47 PM
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: 3
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: 1566
File comments: 1117
Uploads: 41
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.
Report comment to moderator  
Reply With Quote
Unread 03/03/19, 11:08 AM  
merlight
AddOn Author - Click to view AddOns

Forum posts: 671
File comments: 213
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: 1566
File comments: 1117
Uploads: 41
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.
Report comment to moderator  
Reply With Quote
Unread 03/03/19, 08:19 AM  
swtrse

Forum posts: 0
File comments: 3
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.