aboutsummaryrefslogtreecommitdiffhomepage
path: root/core/locale.lua
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+667e-11@users.noreply.github.com>2010-10-15 16:52:12 -0400
committerGravatar mitchell <70453897+667e-11@users.noreply.github.com>2010-10-15 16:52:12 -0400
commit6d11c044ec0059405c9e2813e39e9b618e7068c8 (patch)
treebd2d28c04d63d633817cc1f29c74608e36c7c3cb /core/locale.lua
parent32602279973cef2783399c08709b3567f8369371 (diff)
Changed locale implementation.
Diffstat (limited to 'core/locale.lua')
-rw-r--r--core/locale.lua15
1 files changed, 9 insertions, 6 deletions
diff --git a/core/locale.lua b/core/locale.lua
index 93bf1024..5b14a254 100644
--- a/core/locale.lua
+++ b/core/locale.lua
@@ -19,20 +19,23 @@ module('locale', package.seeall)
-- Each message ID in `core/locale.conf` is accessible as a field in this
-- module.
-local escapes = { ['\\n'] = '\n', ['\\r'] = '\r', ['\\t'] = '\t' }
+-- 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+)%s+"(.+)"$')
- if id and str then locale[id] = str:gsub('\\[nrt]', escapes) end
+ local id, str = line:match('^(.-)%s*=%s*(.+)$')
+ if id and str then localizations[id] = str end
end
end
f:close()
---
--- This module contains no functions.
-function no_functions() end
-no_functions = nil -- undefine
+-- Localizes the given string.
+-- @param id String to localize.
+function localize(id) return localizations[id] or 'No Localization' end