aboutsummaryrefslogtreecommitdiffhomepage
path: root/core/locale.lua
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+667e-11@users.noreply.github.com>2011-12-31 18:00:19 -0500
committerGravatar mitchell <70453897+667e-11@users.noreply.github.com>2011-12-31 18:00:19 -0500
commitbd55d676f133a5b38ca53c33bf599d66dfe1fc87 (patch)
tree369c9cfa6fe5e32eeb3bc89d0a86d3c8def57044 /core/locale.lua
parentae8dddf78ef5b07f4d64471d8f6800746373af6e (diff)
Changed 'locale.localize()' to global '_L' table.
Diffstat (limited to 'core/locale.lua')
-rw-r--r--core/locale.lua26
1 files changed, 2 insertions, 24 deletions
diff --git a/core/locale.lua b/core/locale.lua
index 3975c323..1ba3a8f1 100644
--- a/core/locale.lua
+++ b/core/locale.lua
@@ -2,37 +2,15 @@
local M = {}
---[[ This comment is for LuaDoc.
----
--- Contains all messages used by Textadept for localization.
-module('locale')]]
-
--- Markdown:
--- ## Fields
---
--- Each message ID in `core/locale.conf` is accessible as a field in this
--- module.
-
--- Contains all localizations for the current locale.
--- @class table
--- @name localizations
-local localizations = {}
-
local f = io.open(_USERHOME..'/locale.conf', 'rb')
if not f then f = io.open(_HOME..'/core/locale.conf', 'rb') end
if not f then error('"core/locale.conf" not found.') end
for line in f:lines() do
if not line:find('^%s*%%') then
local id, str = line:match('^(.-)%s*=%s*(.+)$')
- if id and str then localizations[id] = str end
+ if id and str then M[id] = str end
end
end
f:close()
----
--- Localizes the given string.
--- @param id String to localize.
--- @name localize
-function M.localize(id) return localizations[id] or 'No Localization' end
-
-return M
+return setmetatable(M, { __index = function() return 'No Localization' end })