diff options
author | mitchell <70453897+667e-11@users.noreply.github.com> | 2012-07-17 17:48:59 -0400 |
---|---|---|
committer | mitchell <70453897+667e-11@users.noreply.github.com> | 2012-07-17 17:48:59 -0400 |
commit | 8ad622fc6db9a873753e77530d9c9f9401867fd6 (patch) | |
tree | 4c6a8187219e4127bd22988e976549af4bad207d /core/locale.lua | |
parent | 17c33b24243cccf82298513e5a99888ec5b9976e (diff) |
Added function to check if a localized message exists; core/locale.lua
Diffstat (limited to 'core/locale.lua')
-rw-r--r-- | core/locale.lua | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/core/locale.lua b/core/locale.lua index 1763f396..8c838ecc 100644 --- a/core/locale.lua +++ b/core/locale.lua @@ -5,11 +5,15 @@ local M = {} --[[ This comment is for LuaDoc. --- -- Table of all messages used by Textadept for localization. --- @field _NIL (string) --- String returned when no localization for a given message exists. module('_L')]] -M._NIL = 'No Localization' +local none = 'No Localization: ' + +--- +-- Returns whether or not a localized message exists for the given message. +-- @param message The message to localize. +-- @return `true` if a localization exists, `false` otherwise. +function M._EXISTS(message) return M[message] ~= none..message end local f = io.open(_USERHOME..'/locale.conf', 'rb') if not f then f = io.open(_HOME..'/core/locale.conf', 'rb') end @@ -22,4 +26,4 @@ for line in f:lines() do end f:close() -return setmetatable(M, { __index = function(t, k) return M._NIL..': '..k end }) +return setmetatable(M, { __index = function(t, k) return none..k end }) |