Quantcast
Download
(8 MB)
Download
Updated: 06/29/20 05:31 PM
Pictures
File Info
Compatibility:
Greymoor (6.0.5)
Updated:06/29/20 05:31 PM
Created:06/09/20 07:45 PM
Monthly downloads:3,446
Total downloads:3,847
Favorites:4
MD5:
Categories:Libraries, ESO Tools & Utilities
6.0.5
LibMultilingualName
Version: 1.0.5
by: Shinntarou [More]
name files in 5 languages.(en, de, fr, jp, ru), and PowerShell script file that build them from your ESO client.

usage

The LIB has two interface pattern.

1. GetRaw****Name(langCode, id)

it simply return "gamedata/**.csv"'s value as-is including special chars.

Code:
[44955]="pauldron^p",[44956]="sabatons^p",
if NotFound, parameter is Invalid, then return bool false.

2. Get****Name(langCode, id)

(I wish) it return formatted value depending on what value it is.

Code:
    local name = LIB.GetRawItemName(langCode, id)
    if name then
        return ZO_CachedStrFormat("<<C:1>>", name)
    else 
        return "NotFound. Lang Code ".. langCode .. " Id " .. id
    end
If NotFound etc, then return some strings by any means possible.


Powershell Scripts

setup.ps1

For addon developers and players having fair knowledge of PowerShell.
This one build up all GetRaw****_**.lua files.
please read console message so it is a dialogue script.


external libaries

# EsoExtractData
# @see https://www.esoui.com/downloads/info1258-EsoExtractData.html
Optional Files (0)


Archived Files (4)
File Name
Version
Size
Uploader
Date
1.0.4
8MB
Shinntarou
06/11/20 02:06 PM
1.0.3
5MB
Shinntarou
06/10/20 04:34 AM
1.0.1
5MB
Shinntarou
06/10/20 01:47 AM
1.0.0
5MB
06/09/20 07:45 PM


Post A Reply Comment Options
Unread 06/30/20, 01:17 AM  
Baertram
 
Baertram's Avatar
AddOn Author - Click to view AddOns

Forum posts: 2978
File comments: 3596
Uploads: 62
There is no real GC except /reloadui or setting variables explicitly to = nil

And I guess using _G or local is the same. Only access speed will differ if it would have to search the whole _G table for the desired sub tables and their subtables each time. So use speed up reference locals where possible.

e.g.
Lua Code:
  1. local speedUpRefTab = MyLibraryTable.subtable
  2. for key, value in pairs(speedUpRefTab) do
  3. end

Using the local pointer speedUpRefTab to the global table + subtable will be quicker here as else the _G, then _G.MyLibraryTable and then _G.MyLibraryTable.subTable would be searched on EACH round in the for ... do/in pairs loop.

Same applies to filling the tables dynamically.

_G.MyLibraryTable.subtable[1] = "test" will be not as quick as maybe speedUpRef[1] ="test". But: Depending on how speedUpRef was build, like 1 local speedUpRefBase and then another local speedUpRef = speedUpRefBase.subTable, it won't work properly in some cases!

Check the Wiki: Everything is a table

Originally Posted by Shinntarou
I don't know about actual mechanics of ESO's lua in this situation. just a little I expect that type of interpreter language will appropriately load and dispose local declared data like GC. most of user uses specific 1 or 2 lang code only.
that is reason why I fear that Lib has too big global array data.
but, I'm newbie at LUA.
Last edited by Baertram : 06/30/20 at 05:44 AM.
Report comment to moderator  
Reply With Quote
Unread 06/29/20, 11:58 PM  
Shinntarou
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 10
Uploads: 3
I don't know about actual mechanics of ESO's lua in this situation. just a little I expect that type of interpreter language will appropriately load and dispose local declared data like GC. most of user uses specific 1 or 2 lang code only.
that is reason why I fear that Lib has too big global array data.
but, I'm newbie at LUA.
Report comment to moderator  
Reply With Quote
Unread 06/29/20, 11:20 PM  
Baertram
 
Baertram's Avatar
AddOn Author - Click to view AddOns

Forum posts: 2978
File comments: 3596
Uploads: 62
Wasn't it the same before with the local variables and global functions? The data of all files was loaded right?
Else your lib wouldn't make sense

Originally Posted by Shinntarou
now, testing this code.

Code:
LibMultilingualName = LibMultilingualName or {}
LibMultilingualName.GetRawItemName_Data = LibMultilingualName.GetRawItemName_Data or {}
LibMultilingualName.GetRawItemName_Data["en"] = {
[70]="Cured Kwama Leggings",
[139]="Webspinner's Brace",
[144]="Apprentice's Leggings",
[148]="Scampstamper Sabatons",
[219]="Sommelier's Gloves",
I supposed It potentially cause to memory problem due to using global lib's property. (all language data always loaded on LIB even if a user does't use specific lang code data.)
IF the problem isn't matter, I will release it. now checking ESO's memory usage.
Report comment to moderator  
Reply With Quote
Unread 06/29/20, 11:07 PM  
Shinntarou
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 10
Uploads: 3
now, testing this code.

Code:
LibMultilingualName = LibMultilingualName or {}
LibMultilingualName.GetRawItemName_Data = LibMultilingualName.GetRawItemName_Data or {}
LibMultilingualName.GetRawItemName_Data["en"] = {
[70]="Cured Kwama Leggings",
[139]="Webspinner's Brace",
[144]="Apprentice's Leggings",
[148]="Scampstamper Sabatons",
[219]="Sommelier's Gloves",
I supposed It potentially cause to memory problem due to using global lib's property. (all language data always loaded on LIB even if a user does't use specific lang code data.)
IF the problem isn't matter, I will release it. now checking ESO's memory usage.
Report comment to moderator  
Reply With Quote
Unread 06/29/20, 09:49 PM  
Shinntarou
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 10
Uploads: 3
Thank you for continuous advising, and I agree it's common and better idea in general. but, it's opposite to the initial concept of the library.
The library is impossible to rely on CVar "language.2" because of its concept. a user must pass specific one lang code and get one language's result each times.
and ... the confusing raw file's structure is caused by the batchfile's convenience. I need re-generate raw files on ESO's update.

Only I can do and I want to do is to solve function name's matter you pointed at.(GetRawSkillName_de ... gee, it's bad)
foriegn friends who play ESO in other language(except EN, JA, DE, FR, RU) are increasing. the code will be cancer in near future.
now I have tackled to remove the code like this. and , I want to adopt your teaching to the modifying.

Code:
    if langCode == LMN.CODE_ENGLISH then return LIB.GetRawQuestName_en(id) end
    if langCode == LMN.CODE_JAPANESE then return LIB.GetRawQuestName_jp(id) end
    if langCode == LMN.CODE_GERMAN then return LIB.GetRawQuestName_de(id) end
    if langCode == LMN.CODE_FRENCH then return LIB.GetRawQuestName_fr(id) end
    if langCode == LMN.CODE_RUSSIAN then return LIB.GetRawQuestName_ru(id) end
Thank you again. (and , sorry for my bad English. I'm too poor at English.)
Report comment to moderator  
Reply With Quote
Unread 06/29/20, 06:42 PM  
Baertram
 
Baertram's Avatar
AddOn Author - Click to view AddOns

Forum posts: 2978
File comments: 3596
Uploads: 62
Wouldn't it make more sense to define 1 function with the language code as parameter for the names in your lib?
e.g. current: LibMultilingualName.GetRawSkillName_de(index)
New: LibMultilingualName.GetRawSkillName(index, lang)

This way one would be able to just use the "same functions" and "syntax" for them to get the correct Strings AND one could even use 1 language variable like local lang = GetCVar("language.2") from ingame, istead of having to code
several

local skillName
if lang == "de" then
skillName = LibMultilingualName.GetRawSkillName_de(index)
elseif lang == "en" then
skillName = LibMultilingualName.GetRawSkillName_en(index)
...
end

Not to mention new languages that would be added :-( They would need an update of depending addons as well.

To achieve this change your data files so that the table "local data = {" will close with } and after that lines you transfer it to the global addon's variable data like this:

Lua Code:
  1. local data = {
  2. ...
  3. }
  4. LibMultilingualName = LibMultilingualName or {}
  5. LibMultilingualName.RawData = LibMultilingualName.RawData or {} --Create a new table or use existing one
  6. LibMultilingualName.RawData.ItemNames = LibMultilingualName.RawData.ItemNames or {} --Create a new sub-table (depending on the current file's data) or use existing one
  7.  
  8. LibMultilingualName.RawData.ItemNames["en"] = data --transfer the data with the given language to the table

And in your main file LibMultilingualData.lua create a function then for it:

Lua Code:
  1. --Once at the top
  2. lib.clientlang = GetCVar("language.2")
  3. if  not lib.clientlang then lib.clientlang = "en" end --fallback for unsupported languages to English
  4.  
  5.  
  6. function LibMultilingualName.GetRawItemName(index, lang)
  7.   if not index then return false end
  8.   lang = lang or lib.clientLang
  9.   local data = LibMultilingualName.RawData and LibMultilingualName.RawData.ItemNames and LibMultilingualName.RawData.ItemNames[lang]
  10.   if not data or not data[index] then return false end
  11.   return data[index]
  12. end

Somethign like this would be way easier to use in addons, and more dynamically (imho)
Last edited by Baertram : 06/29/20 at 06:50 PM.
Report comment to moderator  
Reply With Quote
Unread 06/10/20, 05:58 AM  
Shinntarou
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 10
Uploads: 3
Originally Posted by zelenin
Your method of extracting item names corrupts some items like potions/poisons. Its names depends on CP:

ESSENCE OF CREEPING RAVAGE HEALTH
DISTILLATE OF CREEPING RAVAGE HEALTH
PANACEA OF CREEPING RAVAGE HEALTH
etc.
But your library contains "Creeping Ravage Health" and it will in tooltips etc.

You should extract item names ingame and look into specific itemtypes.

https://www.esoui.com/downloads/info...msFetcher.html it will help you

Thanks a lot.
Yes, it is just I needed. I really need a good lib as a reference.
And I'm sorry for leaving these things unfinished. Weapon, Armor, Pot, Poison...

I'm sure to update my bad lib in near future.
Report comment to moderator  
Reply With Quote
Unread 06/10/20, 05:19 AM  
zelenin
AddOn Author - Click to view AddOns

Forum posts: 2
File comments: 71
Uploads: 3
Your method of extracting item names corrupts some items like potions/poisons. Its names depends on CP:

ESSENCE OF CREEPING RAVAGE HEALTH
DISTILLATE OF CREEPING RAVAGE HEALTH
PANACEA OF CREEPING RAVAGE HEALTH
etc.
But your library contains "Creeping Ravage Health" and it will in tooltips etc.

You should extract item names ingame and look into specific itemtypes.

https://www.esoui.com/downloads/info...msFetcher.html it will help you
Report comment to moderator  
Reply With Quote
Unread 06/10/20, 04:11 AM  
Shinntarou
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 10
Uploads: 3
Originally Posted by Baertram
The benefit of tables is that if you dump the itemnames to the SavedVariables by scanning them with a debug function e.g. you can simply copy them over to your addon afterwards without having to alter or add "if ... end" functions around them.
You could use some function of the lib e.g. like
Lua Code:
  1. local startItemId, endItemId = 1, 300000
  2. local itemLinkPattern = "|H1:item:%s:1:50:0:0:0:0:0:0:0:0:0:0:0:0:ITEMSTYLE_NONE:0:0:0:10000:0|h|h"
  3. --Function to scan the itemNames from the game's current clientLanguage.
  4. --Change the clientlanguage ingam by using /script SetCVar("language.2", <2char language>) where <2char language> could be "en", "de", "fr", "ru", "jp"
  5. -- or if custom language mods are installed: "es", "it", "pt", "pl"
  6. --Parameters:
  7. --nilable number startId ItemId to start the scan at. If left nil, value will be 1
  8. --nilable number sendId ItemId to start the scan at. If left nil, value will be 300000
  9. --Returns:
  10. --table scannedItemNames = {[0] = "client language" as string, [number itemId] = "String item name", ...}
  11. function LIB.ScanItemNames(startId, endId)
  12.     startId = startId or  startItemId
  13.     if startId < 1 then startId = 1 end
  14.     endId = endId or  endItemId
  15.     local scannedItemNames = {
  16.         [0] = tostring(GetCVar("language.2"))
  17.     }
  18.     for itemId=startId, endId, 1 do
  19.         local itemLink = string.format(itemLinkPattern, tostring(itemId))
  20.         local itemName = GetItemLinkName(itemLink)
  21.         scannedItemNames[itemId] = itemName or ""
  22.     end
  23. end

Not sure what the maximum itemId can be, I have assumed it's 300000 so maybe there are less or more.
You could use the generated itemLink to check the item's type as well if you want to strip some of the items(like only include armor, weapons and jewelry) via API functions like GetItemLinkItemType.

Caution:
As scanning so many itemIds needs time I'd recommand using zo_callLater e.g. to make "packages of scanned data at a maximum of e.g. 10000 itemIds "at once" in each package. Like put the actual scan code into a local subfunction which you can call with a delay, increase the delay each scanned package by 250ms so the game client won't kick you for mesasge spam.
Check the library LibSets, LibSets_Debug.lua for some code exaples as the sets get scanned -> function "scanAllSetData".

You'd need to add the ## SavedVariables: tag to your txt file of the lib and add e.g. account wide SavedVariables to the library init functions where you could add this table then.
This way you'd get the itemNames from the game client and provide API functions to obtain them.
Maybe you could loose the included ESOExtractData then.

And I'd also recommand minifying the files with a lua minifier, like this one:
https://mothereff.in/lua-minifier

This will shrink the filesize a lot and make loading "a bit faster" at least.

btw: Thanks for the lib!

Thank you very much!
I'll check LibSets and so on. I need useful specification documents like you wrote. Just now I wanted to generate perfect Item name.

> minifier

Oh... previous version lib likes the big chunk of stone.
after using LUA-minifier, it's perfectly safe!
Report comment to moderator  
Reply With Quote
Unread 06/10/20, 03:21 AM  
Baertram
 
Baertram's Avatar
AddOn Author - Click to view AddOns

Forum posts: 2978
File comments: 3596
Uploads: 62
The benefit of tables is that if you dump the itemnames to the SavedVariables by scanning them with a debug function e.g. you can simply copy them over to your addon afterwards without having to alter or add "if ... end" functions around them.
You could use some function of the lib e.g. like
Lua Code:
  1. local startItemId, endItemId = 1, 300000
  2. local itemLinkPattern = "|H1:item:%s:1:50:0:0:0:0:0:0:0:0:0:0:0:0:ITEMSTYLE_NONE:0:0:0:10000:0|h|h"
  3. --Function to scan the itemNames from the game's current clientLanguage.
  4. --Change the clientlanguage ingam by using /script SetCVar("language.2", <2char language>) where <2char language> could be "en", "de", "fr", "ru", "jp"
  5. -- or if custom language mods are installed: "es", "it", "pt", "pl"
  6. --Parameters:
  7. --nilable number startId ItemId to start the scan at. If left nil, value will be 1
  8. --nilable number sendId ItemId to start the scan at. If left nil, value will be 300000
  9. --Returns:
  10. --table scannedItemNames = {[0] = "client language" as string, [number itemId] = "String item name", ...}
  11. function LIB.ScanItemNames(startId, endId)
  12.     startId = startId or  startItemId
  13.     if startId < 1 then startId = 1 end
  14.     endId = endId or  endItemId
  15.     local scannedItemNames = {
  16.         [0] = tostring(GetCVar("language.2"))
  17.     }
  18.     for itemId=startId, endId, 1 do
  19.         local itemLink = string.format(itemLinkPattern, tostring(itemId))
  20.         local itemName = GetItemLinkName(itemLink)
  21.         scannedItemNames[itemId] = itemName or ""
  22.     end
  23. end

Not sure what the maximum itemId can be, I have assumed it's 300000 so maybe there are less or more.
You could use the generated itemLink to check the item's type as well if you want to strip some of the items(like only include armor, weapons and jewelry) via API functions like GetItemLinkItemType.

Caution:
As scanning so many itemIds needs time I'd recommand using zo_callLater e.g. to make "packages of scanned data at a maximum of e.g. 10000 itemIds "at once" in each package. Like put the actual scan code into a local subfunction which you can call with a delay, increase the delay each scanned package by 250ms so the game client won't kick you for mesasge spam.
Check the library LibSets, LibSets_Debug.lua for some code exaples as the sets get scanned -> function "scanAllSetData".

You'd need to add the ## SavedVariables: tag to your txt file of the lib and add e.g. account wide SavedVariables to the library init functions where you could add this table then.
This way you'd get the itemNames from the game client and provide API functions to obtain them.
Maybe you could loose the included ESOExtractData then.

And I'd also recommand minifying the files with a lua minifier, like this one:
https://mothereff.in/lua-minifier

This will shrink the filesize a lot and make loading "a bit faster" at least.

btw: Thanks for the lib!
Last edited by Baertram : 06/10/20 at 03:42 AM.
Report comment to moderator  
Reply With Quote
Unread 06/09/20, 09:38 PM  
Shinntarou
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 10
Uploads: 3
Originally Posted by Dolgubon
You should change the language files to use tables instead. For example for the first few items:

local itemNames = {
[70]= "jambières tannées en kwama^pf" ,
[139]= "sangle lombaire de la tisseuse^f" ,
[144]= "jambières de l'apprenti^pf" ,
[148]= "solerets de piétineur de galopins^pm" ,
[219]= "gants du sommelier^pm" ,
[238]= "chaussures^pf" ,
[251]= "hache de bataille^f" ,
[317]= "solerets de la garde du Lion de l'arbre du Wyrd^pm" ,
[471]= "bastion du dragon de la Sangrépine^m" ,
[479]= "culotte de porcher^f" ,
[521]= "chêne brut^ms" ,
[533]= "chêne poncé^ms" ,
[685]= "bâton de guérison de Gabrielle^m" ,
[793]= "lanières de peau brute^pf" ,
[794]= "peau brute^fs" ,
[800]= "lanières de peau superbe^f" ,
[802]= "érable brut^ms" ,
[803]= "érable poncé^ms" ,
[808]= "minerai de fer^m" ,
}


Then, the actual function becomes this:
function LibMultilingualName.GetItemName_fr(itemId)

if itemNames[itemId] then
return itemNames[itemId]
end
return "NotFound fr"
end


One benefit of this is that tables in Lua are hash tables, so it'll make the function run much faster - rather than doing thousands of comparisons it's just doing a table lookup
Also, it's shorter and imo looks nicer
Thank you for reviewing. the unerring Talos.

in first edition, I once used LUA table. the reason was exactly what you pointed at.
I thought... "5M memory each lang? ESO always loads those tables even for non-using languages? ... I try to change to IF mechanics and count on GC."
but, It was confirmed that there is no big difference when I play.

next version, Probably I will replace the bad code.
thanks.
Report comment to moderator  
Reply With Quote
Unread 06/09/20, 08:29 PM  
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view AddOns

Forum posts: 364
File comments: 707
Uploads: 18
You should change the language files to use tables instead. For example for the first few items:

local itemNames = {
[70]= "jambières tannées en kwama^pf" ,
[139]= "sangle lombaire de la tisseuse^f" ,
[144]= "jambières de l'apprenti^pf" ,
[148]= "solerets de piétineur de galopins^pm" ,
[219]= "gants du sommelier^pm" ,
[238]= "chaussures^pf" ,
[251]= "hache de bataille^f" ,
[317]= "solerets de la garde du Lion de l'arbre du Wyrd^pm" ,
[471]= "bastion du dragon de la Sangrépine^m" ,
[479]= "culotte de porcher^f" ,
[521]= "chêne brut^ms" ,
[533]= "chêne poncé^ms" ,
[685]= "bâton de guérison de Gabrielle^m" ,
[793]= "lanières de peau brute^pf" ,
[794]= "peau brute^fs" ,
[800]= "lanières de peau superbe^f" ,
[802]= "érable brut^ms" ,
[803]= "érable poncé^ms" ,
[808]= "minerai de fer^m" ,
}


Then, the actual function becomes this:
function LibMultilingualName.GetItemName_fr(itemId)

if itemNames[itemId] then
return itemNames[itemId]
end
return "NotFound fr"
end


One benefit of this is that tables in Lua are hash tables, so it'll make the function run much faster - rather than doing thousands of comparisons it's just doing a table lookup
Also, it's shorter and imo looks nicer
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: