ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Using Localization files (https://www.esoui.com/forums/showthread.php?t=1578)

silmaodv 05/21/14 07:04 AM

Using Localization files
 
Hi there,

First, sorry for my English !

I'm looking for a way to get the English name of a point of interest when the game is not in English.
I searched the API, but did not find anything about it.
Does anybody know how i can access the localization files of others languages ?

It may be a silly question for English-speaking users, but like many players on the European server, my game is not in English. However the zone channel are, so each time someone announce that something happens somewhere, the name of the "point of interest" (shrine, castle, bosses) is in English, and i have to look at my map (in my own language) and try to guess how it has been translated...
I wish to simply make an add on that show both names on the map : one in my language, and the English name.

Any clue would be welcome..

Have a nice day !

thelegendaryof 05/21/14 08:06 AM

Edit:

Ah wait - you're looking to get the English name of all Locations displayed on your current Map?

That might be possible and a good solution! I'll have a look ... if it comes down to it you can get that Data from ESOHEAD:

http://esohead.com/map#439.2.50.50
http://esohead.com/zones#alliance:1

Edit 2:

Seems like they don't have everything stored as well - at least with a first glance

You'll probably have to embed a Library of those Location Names in your addon thought!
There is really really medicore localization support for the whole API afterall (almost non-existant).

Edit 3:

Just in case this translates all Item-Links to English no matter your client language:

http://www.esoui.com/downloads/info4...izedItems.html

silmaodv 05/21/14 08:35 AM

Thanks a lot for you answer.

I could play with the English client, but then i would have the opposite problem, when my guildmates will give the POI names in French. ;)

I don't intend to do any translation, i want to use what is already existing in the game files. I guess the game must have an ID for each Point of Interest. When it generates a map, it checks the language file and bring back the name for this ID. What i want to do is to check both the FR file and the ENG file, but i don't know if i can access them, and how.

I also could do a layer on the map, like the Skyshard addon, but it will be heavier (and much longer to write!)

I think it was an error to localize NPC and locations names on an international server...

Edit :
You edited your post while i was typing ^^
This Items Links addon seems to be a good place to start, i'll have a look at it, thanks a lot for the time you spend on my problem !

thelegendaryof 05/21/14 09:13 AM

Hm. Looking at the API itself:

You could parse them out of the API itself probably:

Lua Code:
  1. GetNumMaps()
  2. Returns: integer numMaps
  3.  
  4. GetMapInfo(luaindex index)
  5. Returns: string name, UIMapType mapType, MapContentType mapContentType
  6.  
  7. GetNumMapLocations()
  8. Returns: integer numMapLocations
  9.  
  10. GetMapLocation(luaindex locationIndex)
  11. _Uses variable returns..._
  12. Returns: string locationName, integer fontSize, number colorR, number colorG, number colorB, number normalizedX, number normalizedZ


Then try to get them like this (not tested, just written here quick n dirty):

Lua Code:
  1. local function GetAllLocationsFromAllMaps()
  2.     local locations = {}
  3.  
  4.     for mapid = 1, GetNumMaps(), 1 do
  5.    
  6.         locations[mapid] = {}
  7.        
  8.         for locid = 1, GetNumMapLocations(), 1 do
  9.             local name = GetMapLocation(locid)
  10.  
  11.             if(name) then locations[mapid][locid] = name end
  12.         end
  13.     end
  14.  
  15.     return locations
  16. end
  17.  
  18. -- switch game client to english
  19. ENGLISH_LOCATIONS = GetAllLocationsFromAllMaps()
  20.  
  21. -- this will probably overflow your Chat
  22. -- so better use /zgoo ENGLISH_LOCATIONS
  23. -- and comment that line out (*)
  24. d(ENGLISH_LOCATIONS)

(*) You can find Zgoo here: Zgoo

I'm not sure however - maybe it 's only working for the current map you're in. You could then dump that data with LibOrangUtils:CopyToClipboard(string text) from my library (well after converting it to a string instead of a table)

http://www.esoui.com/downloads/info4...rangUtils.html

and then supply both tables with your addon and translate them based on map/location ID.

You should get something like this as a result:

Lua Code:
  1. ENGLISH_LOCATIONS = {
  2.     [1] = { -- mapid
  3.         [592] = "The Herpderp Den of Derpert Herp", -- location id = name
  4.         [1029] = "The Lerb"
  5.     },
  6.     [502] = {
  7.         [1] = "Blargh"
  8.     }
  9. }

Garkin 05/21/14 09:21 AM

As far as I know there is no way to get point of interest (POI) names in different language without reloading UI. It means that you will need to create some table with localized names in your addon.

How to get POI names for the current map in the current language:
Lua Code:
  1. local zoneIndex = GetCurrentMapZoneIndex()
  2. for poiIndex = 1, GetNumPOIs(zoneIndex) do
  3.    local name, level, startDesc, finishedDesc = GetPOIInfo(zoneIndex, poiIndex)
  4.    d(name)
  5. end
Or just take a look to the Undiscovered addon files (Language\UndiscoveredData-??.lua).

How to switch between laguages:
In my private addon I have defined three slash commands to switch language:
Lua Code:
  1. SLASH_COMMANDS["/langen"] = function() SetCVar("language.2", "en") end
  2. SLASH_COMMANDS["/langde"] = function() SetCVar("language.2", "de") end
  3. SLASH_COMMANDS["/langfr"] = function() SetCVar("language.2", "fr") end

Where you want to display modified names? You can for example modify tooltip creators for POI pins on the world map:
Lua Code:
  1. local mt = {}
  2. function mt.__call(self, zoneIndex, poiIndex)
  3.    local name
  4.    if self[zoneIndex] then
  5.       name = self[zoneIndex][poiIndex]
  6.    end
  7.    return name
  8. end
  9. local englishPOINames = setmetatable({}, mt)
  10.  
  11. englishPOINames[17] = { --example for Alik'r Desert
  12.    [1] = "Sentinel Docks",
  13.    [2] = "Ancestor's Landing",
  14.    [3] = "Rain Catcher Fields",
  15.    [4] = "Morwha's Bounty",
  16.    [5] = "Tu'whacca's Throne",
  17.    [6] = "Kulati Mines",
  18.    [7] = "Leki's Blade",
  19.    [8] = "Sep's Spine",
  20.    [9] = "Bergama",
  21.    [10] = "Tava's Blessing",
  22.    [11] = "HoonDing's Watch",
  23.    [12] = "Satakalaam",
  24.    [13] = "Kozanset",
  25.    [14] = "Sentinel",
  26.    [15] = "Salas En",
  27.    [16] = "Motalion Necropolis",
  28.    [17] = "Morwha's Bounty Wayshrine",
  29.    [18] = "Sentinel Wayshrine",
  30.    [19] = "Bergama Wayshrine",
  31.    [20] = "Leki's Blade Wayshrine",
  32.    [21] = "Satakalaam Wayshrine",
  33.    [22] = "Santaki",
  34.    [23] = "Divad's Chagrin Mine",
  35.    [24] = "Aldunz",
  36.    [25] = "Coldrock Diggings",
  37.    [26] = "Sandblown Mine",
  38.    [27] = "Yldzuun",
  39.    [28] = "Lost City of the Na-Totambu",
  40.    [29] = "Divad's Chagrin Mine Wayshrine",
  41.    [30] = "Kulati Mines Wayshrine",
  42.    [31] = "Aswala Stables Wayshrine",
  43.    [32] = "Sep's Spine Wayshrine",
  44.    [33] = "Ogre's Bluff",
  45.    [34] = "Shrikes' Aerie Wayshrine",
  46.    [35] = "HoonDing's Watch Wayshrine",
  47.    [36] = "Myrkwasa Dolmen",
  48.    [37] = "Hollow Waste Dolmen",
  49.    [38] = "Tigonus Dolmen",
  50.    [39] = "The Warrior",
  51.    [40] = "The Ritual",
  52.    [41] = "The Thief",
  53.    [42] = "Dungeon: Volenfell",
  54.    [43] = "Goat's Head Oasis Wayshrine",
  55.    [44] = "Lost Caravan",
  56.    [45] = "Lesser Circle",
  57.    [46] = "Giant Camp",
  58.    [47] = "Forsaken Hearts Cave",
  59.    [48] = "Hag Camp",
  60.    [49] = "King's Rest",
  61.    [50] = "Saltwalker Militia Camp",
  62.    [51] = "Aswala's Remembrance",
  63.    [52] = "Tears of the Dishonored",
  64.    [53] = "Ragnthar",
  65.    [54] = "Rkulftzel",
  66.    [55] = "Alezer Kotu",
  67.    [56] = "Easterly Aerie",
  68.    [57] = "Hatiha's Camp",
  69.    [58] = "Na-Totambu's Landing",
  70.    [59] = "Artisan's Oasis",
  71.    [60] = "Duneripper Downs",
  72.    [61] = "Wayfarer's Wharf",
  73. }
  74. local function AddEnglishName(pin)
  75.    local poiIndex = pin:GetPOIIndex()
  76.    local zoneIndex = pin:GetPOIZoneIndex()
  77.    local englishName = englishPOINames(zoneIndex, poiIndex)
  78.    if not englishName then return end
  79.    local localizedName = ZO_WorldMapMouseoverName:GetText()
  80.  
  81.    ZO_WorldMapMouseoverName:SetText(localizedName .. " (" .. englishName .. ")")
  82. end
  83.  
  84. local CreatorPOISeen = ZO_MapPin.TOOLTIP_CREATORS[MAP_PIN_TYPE_POI_SEEN].creator
  85. ZO_MapPin.TOOLTIP_CREATORS[MAP_PIN_TYPE_POI_SEEN].creator = function(pin)
  86.    CreatorPOISeen(pin) --original tooltip creator
  87.    AddEnglishName(pin) --your function that will change text
  88. end
  89. local CreatorPOIComplete = ZO_MapPin.TOOLTIP_CREATORS[MAP_PIN_TYPE_POI_COMPLETE].creator
  90. ZO_MapPin.TOOLTIP_CREATORS[MAP_PIN_TYPE_POI_COMPLETE].creator = function(pin)
  91.    CreatorPOIComplete(pin) --original tooltip creator
  92.    AddEnglishName(pin) --your function that will change text
  93. end

thelegendaryof 05/21/14 09:26 AM

Quote:

Originally Posted by Garkin (Post 8157)
How to switch between laguages:
In my private addon I have defined three slash commands to switch language:
Lua Code:
  1. SLASH_COMMANDS["/langen"] = function() SetCVar("language.2", "en") end
  2. SLASH_COMMANDS["/langde"] = function() SetCVar("language.2", "de") end
  3. SLASH_COMMANDS["/langfr"] = function() SetCVar("language.2", "fr") end

Pretty usefull! thanks. Mind if I include it in BugEater (of course, named differently and after testing it)?

Also - I'm curious - Whats the difference between Map-Locations and POI 's ? (just never touched it yet)

Halja 05/21/14 10:51 AM

I have all three languages installed but does the game go boom :eek: if you don't and switch the cVar dynamically?

I'll not sure how gracefully the game will deal with it if you don't have the languages already downloaded.
--halja

Garkin 05/21/14 11:07 AM

Quote:

Originally Posted by Halja (Post 8166)
I have all three languages installed but does the game go boom :eek: if you don't and switch the cVar dynamically?

I'll not sure how gracefully the game will deal with it if you don't have the languages already downloaded.
--halja

No worries, it just reloads UI (tested with EU client).

Garkin 05/21/14 11:16 AM

Quote:

Originally Posted by thelegendaryof (Post 8158)
Pretty usefull! thanks. Mind if I include it in BugEater (of course, named differently and after testing it)?

Also - I'm curious - Whats the difference between Map-Locations and POI 's ? (just never touched it yet)

Feel free to use any code that I post here on forum.

As to the locations/points of interest - I have no idea how locations work, GetNumMapLocations() is always 0 no matter what I do :(

Garkin 05/21/14 12:23 PM

What it does:



Source code: http://pastebin.com/Q0ZsR9PJ

http://www.esoui.com/downloads/info4...hPOINames.html

thelegendaryof 05/21/14 12:25 PM

Quote:

Originally Posted by Garkin (Post 8177)
What it does:



Source code: http://pastebin.com/Q0ZsR9PJ

Thats Garkin for you. :D

silmaodv 05/23/14 03:42 AM

Hi there , and thanks !!

I could not come here yesterday, and when i come back, i have not only the answers, but the work is done.
You are awesome ^^

Thanks a lot !


All times are GMT -6. The time now is 05:58 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI