Localization Question

I’m a first-time Addon author and and also new to lua. So here goes.

I would like to provide localization for my addon (it’s nothing special, just a learning toy) and have some questions:

First question: how to configure my addon’s files for localization. I’ve chosen to localize the addon’s strings in a file name EnUS_Locale.lua. Here’s what its header looks like.

local Addon, locales = ...
local L = setmetatable({}, { __index = function(t, k) 
    	local v = tostring(k)
    	rawset(t, k, v)
    	return v
    end })

locales.L = L 

local LOCALE = GetLocale()
if LOCALE == "enUS" then
   L["ADDON_NAME"]				= Addon
end

Then, in a subsequent file, Test.lua, I have this:

local Addon, test = ...

local L = locales.L

But when I load these two files, I get the error message below (Test.lua is loaded after EnUS_Locale.lua).

Message: ... attempt to index global 'locales' (a nil value)

What am I missing?

Second question: I’ve noticed quite a few addons use ACE_Locale. On the other hand not a few addons do not use ACE and instead roll their own. What would you recommend?

thanks,

The second return is your namespace. In the first file your namespace is named locales. In your second file your namespace is named test. It’s common to use the same name for the namespace in each file.

So your second file should be either:

local Addon, test = ...

local L = test.L

or

local Addon, locales = ...

local L = locales.L

On hauling in an Ace library to perform this simple task, it seems overkill. Like having a library to add numbers together.