<commit_before>-- Copyright 2007-2012 Mitchell mitchell.att.foicica.com. See LICENSE.

local M = {}

--[[ This comment is for LuaDoc.
---
-- Table of all messages used by Textadept for localization.
module('_L')]]

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
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 M[id] = not NCURSES and str or str:gsub('_', '') end
  end
end
f:close()

return setmetatable(M, { __index = function(t, k) return none..k end })<commit_msg>Attempt to auto-detect locale using 'LANG' environment variable; core/locale.lua<commit_after>-- Copyright 2007-2012 Mitchell mitchell.att.foicica.com. See LICENSE.

local M = {}

--[[ This comment is for LuaDoc.
---
-- Table of all messages used by Textadept for localization.
module('_L')]]

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
  local lang = (os.getenv('LANG') or ''):match('^[^_.@]+')
  if lang then f = io.open(_HOME..'/core/locales/locale.'..lang..'.conf') end
end
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 M[id] = not NCURSES and str or str:gsub('_', '') end
  end
end
f:close()

return setmetatable(M, { __index = function(t, k) return none..k end })
{'fraction_non_alphanumeric': 0.16945218198700093, 'fraction_numerical': 0.007428040854224698, 'mean_word_length': 3.7052401746724892, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '455806', 'n_tokens_mistral': 748, 'n_tokens_neox': 716, 'n_words': 258}