Thread Tools Display Modes
06-29-11, 04:58 AM   #1
Zax
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 147
[HELP] Localization and variable's scope

Hello,

I just localized one of my addon using this:
localization.lua
Code:
local addonName, L = ...;
local function defaultFunc(L, key)
    return key;
end
setmetatable(L, {__index=defaultFunc});
myAddon.lua
Code:
local _, L = ...;

...

print(L["Hello World!"]);
It works fine for all strings located in myAddon.lua file but I don't understand what I have to modify if I want to use
Code:
print(L["Hello World!"]);
in the .xml file (for example, to localize button's name)?

If I well understood variable's scope, there are only 2 possibilities :
- variable used in a single .lua file
- variable used in all of the loaded addons
But there is no simple way to declare variable usable for one addon, right?

Thanks for your help.
  Reply With Quote
06-29-11, 05:13 AM   #2
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
I am not sure if the data passed down trough the lua (in the form of "...") is accessible from the XML.
Each script has it's own "..." passed down hence I am not sure how you can reference the addon one, I think it's a .lua file thing only.
  Reply With Quote
06-29-11, 07:58 AM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Anything created in the XML file is going to be global.
__________________
"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
06-30-11, 01:03 AM   #4
Zax
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 147
Originally Posted by Seerah View Post
Anything created in the XML file is going to be global.
Very interesting, I didn't know that.

Thank you.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » [HELP] Localization and variable's scope


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