From 8ad622fc6db9a873753e77530d9c9f9401867fd6 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Tue, 17 Jul 2012 17:48:59 -0400 Subject: Added function to check if a localized message exists; core/locale.lua --- core/locale.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'core') 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 }) -- cgit v1.2.3