Thread Tools Display Modes
09-02-08, 07:34 AM   #1
Veev
A Deviate Faerie Dragon
 
Veev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 12
Trying to localize mod, proper use of GetSpellInfo

Hello,

I have received many requests that I localize my mod LockNotes, so I decided I'd spend some time today trying to learn how.

I am only concerned (at the moment) about just making the mod and events work for each localization, the actual text that is displayed to the user I can worry about some other day (e.g., translating words like resisted, up/down, etc.).

Here is an example of the code I am trying to convert:

Code:
if (arg2 == "SPELL_DISPEL") then
	if bit.band(arg5, COMBATLOG_OBJECT_AFFILIATION_MINE) > 0 then
		if (arg10 == "Devour Magic") then
			SpellName = arg13
			if bit.band(arg8, COMBATLOG_OBJECT_REACTION_FRIENDLY) > 0 then -- dispelling buff off friendly target
				UIErrorsFrame:AddMessage("["..SpellName.."]", 1, 1, 1); -- white
			else
				UIErrorsFrame:AddMessage("["..SpellName.."]", 1, 1, 0); -- yellow
			end
		end
	end
end
The problem obviously is the check to see if the spell name is "Devour Magic" only works on English clients.

So I tried experimenting with the command GetSpellInfo using the Spell ID instead. The spell ID for this certain example is usually 27277 for the rank 6 version of the spell. However I was disappointed to learn GetSpellInfo(27277) returns 'Devour Magic' however it is spelled in the local version.

I would like for the mod to be compatible with all ranks of spells of course, but I do not want to have to have the mod check to see if the spell matches one of six (or more for other spells) possible IDs, and that would mean the mod have to be updated for any future ranks of spells added etc.

Anyway I'm probably beginning to ramble, but basically what I'm trying to figure out is how can I have the mod check to see if the English version of the spell name is Devour Magic? Or is there a more efficient way to use Spell IDs I'm not aware of?

Any help would be greatly appreciated!
  Reply With Quote
09-02-08, 09:32 AM   #2
kerrang
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2006
Posts: 109
I asked the same question here a little while ago

http://www.wowinterface.com/forums/s...ad.php?t=17606

and got no replies as you can see...

I use that approach in my addons anyway - it SHOULD return localised spellnames IMO - it makes little sense for it NOT to.

If it doesn't then - quite frankly - I'd pass the issue to Blizzard to sort out - there's little else you can do as an author IMO

p.s. I did this originally because it was suggested to me that it DID work - by someone who has since not complained that it didn't - so who knows - installing a 'language pack' is a MASSIVE nightmare I'm not keen to go through just to check

p.p.s. I also go to the trouble of putting all the 'localisation needed' stuff into a separate file ofc. - but I don't seek-out translators - my thinking is "if they want it in French - they can convert it themselves "

Last edited by kerrang : 09-02-08 at 09:34 AM.
  Reply With Quote
09-02-08, 10:16 AM   #3
Mera
Retired of WoW, In ESO :)
 
Mera's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 331
Originally Posted by Veev View Post
what I'm trying to figure out is how can I have the mod check to see if the English version of the spell name is Devour Magic? Or is there a more efficient way to use Spell IDs I'm not aware of?

Any help would be greatly appreciated!
That's exactly why libraries like Babble-Spell are made for exemple with LibBabble-Spell-3.0, load it in your addon:

Code:
<Include file="libs\LibBabble-Spell-3.0\lib.xml"/>
then you have access to new apis like

Code:
/dump GetSpellInfo(27277)
/dump LibStub("LibBabble-Spell-3.0"):GetReverseIterator("Dévorer la magie")
will return

Code:
DevTools: value=LibStub("LibBabble-Spell-3,0"):GetReverseIterator("Dévorer la magie")
[1]=<function>,
[2]={
  ["Devour Magic"]=true
}
I have translated from frFR "Dévorer la magie" to enUS "Devour Magic", the benefit is you don't have to manage spells, chief ckk will do it for you ;p
__________________
If you need to reach me I'm in ESO, @class101 or "Fathis Ules i"
addons: SpamBayes, BrokerCPU
projects: ThunderBayes
Mera[xeh]? - La CroisadeEcarlate (wow)
  Reply With Quote
09-02-08, 10:31 AM   #4
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by Veev View Post
However I was disappointed to learn GetSpellInfo(27277) returns 'Devour Magic' however it is spelled in the local version.
GetSpellInfo(27277) does return the localized name ... in my case "Magie verschlingen".
  Reply With Quote
09-02-08, 10:33 AM   #5
Mera
Retired of WoW, In ESO :)
 
Mera's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 331
Originally Posted by Duugu View Post
GetSpellInfo(27277) does return the localized name ... in my case "Magie verschlingen".
yup but he would like returned the english not the local lang, so Babble is a workaround
__________________
If you need to reach me I'm in ESO, @class101 or "Fathis Ules i"
addons: SpamBayes, BrokerCPU
projects: ThunderBayes
Mera[xeh]? - La CroisadeEcarlate (wow)
  Reply With Quote
09-02-08, 10:37 AM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
First get rid of the arg1, arg2, etc variables, as they are going the way of the dodo in WotLK.

Second, check for spellid, then return (in your message) the spell name as presented in the combat log, which would be localized. As to how to check for the id, create a local table at the top of your lua with all ranks of Devour Magic. Only this table will need updated with future ranks.
Code:
local DMID = {  [id1] = true,
                     [id2] = true,
                     [id3] = true,
                      etc.  }
Then to check the id in your function
Code:
if DMID[spellID] then
     do stuff
end
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-02-08, 10:43 AM   #7
kerrang
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2006
Posts: 109
Interestingly - I knew they were moving away from 'arg...' variables - but the current builds on the WOTLK BETA server still support them...

The new approach of

function myfunc(...)
arg1,arg2,arg3 = ...

works as well ofc. - but it's not, currently, mandatory as the old-style arg... variables still work...
  Reply With Quote
09-02-08, 10:48 AM   #8
Sekrin
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 150
I've never tried doing this, so it's somewhat dry-coded, but would not the following do for your needs?

Code:
if (arg2 == "SPELL_DISPEL") then
	if bit.band(arg5, COMBATLOG_OBJECT_AFFILIATION_MINE) > 0 then
		local DMName = GetSpellInfo(27277)
		if (arg10 == DMName ) then
			SpellName = arg13
			if bit.band(arg8, COMBATLOG_OBJECT_REACTION_FRIENDLY) > 0 then -- dispelling buff off friendly target
				UIErrorsFrame:AddMessage("["..SpellName.."]", 1, 1, 1); -- white
			else
				UIErrorsFrame:AddMessage("["..SpellName.."]", 1, 1, 0); -- yellow
			end
		end
	end
end

Last edited by Sekrin : 09-02-08 at 10:49 AM. Reason: Oops, left a extra line in.
  Reply With Quote
09-02-08, 10:52 AM   #9
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
I do not want to have to have the mod check to see if the spell matches one of six (or more for other spells) possible IDs, and that would mean the mod have to be updated for any future ranks of spells added etc.
.................

Last edited by Duugu : 09-02-08 at 10:55 AM.
  Reply With Quote
09-02-08, 11:00 AM   #10
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Just create a table with all localized names ... once on first load
Code:
local SpellNames = {}
local tname = GetSpellInfo(27277)
SpellNames["Devour Magic"] = tname
...
Then use the table to test:

Code:
if (arg2 == "SPELL_DISPEL") then
	if bit.band(arg5, COMBATLOG_OBJECT_AFFILIATION_MINE) > 0 then
		if (arg10 == SpellNames["Devour Magic"]) then
			SpellName = arg13
			if bit.band(arg8, COMBATLOG_OBJECT_REACTION_FRIENDLY) > 0 then -- dispelling buff off friendly target
				UIErrorsFrame:AddMessage("["..SpellName.."]", 1, 1, 1); -- white
			else
				UIErrorsFrame:AddMessage("["..SpellName.."]", 1, 1, 0); -- yellow
			end
		end
	end
end

Last edited by Duugu : 09-02-08 at 11:03 AM.
  Reply With Quote
09-02-08, 08:14 PM   #11
Veev
A Deviate Faerie Dragon
 
Veev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 12
Thank you for the replies everyone! Will try to digest this information now
  Reply With Quote
09-02-08, 08:38 PM   #12
Mera
Retired of WoW, In ESO :)
 
Mera's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 331
No probs little gnome !
__________________
If you need to reach me I'm in ESO, @class101 or "Fathis Ules i"
addons: SpamBayes, BrokerCPU
projects: ThunderBayes
Mera[xeh]? - La CroisadeEcarlate (wow)
  Reply With Quote
09-04-08, 06:09 AM   #13
BDelacroix
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 33
I have a mod where I wanted to check for the existence of a particular spell. I didn't care what rank it was. One nice feature of GetSpellInfo() is that when using a global spellID, it will always return a name, whether the user has it or not. IF you pass a spell name, the function returns something other than nil only if that spell exists in the spellbook.

So, you can just look for one (in my case I looked for the highest) spellID and then pass the name you get to GetSpellInfo() again to get the highest rank and name of that spell that the user actually has.

In my case, I didn't care but to check that there was any rank of the spell, but it can be modified in other ways.

Code:
local t
local gname
local name
local rank

for t = 1,5 do
   gname=GetSpellInfo(spell_c[t])

-- if GetSpellInfo() breaks here we have either a bad number in the array or Blizzard has changed the functionality of GetSpellInfo()

   name,rank=GetSpellInfo(gname)

-- if you try to put GetSpellInfo(spell_c[t]) inline, you will get a nil value from this.  Believe me, I tried it.

   if name then
      -- do stuff with it, the spell exists in the user's spellbook
   end
end
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Trying to localize mod, proper use of GetSpellInfo


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off