summaryrefslogtreecommitdiff
path: root/tex/context/base/lang-def.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/lang-def.lua')
-rw-r--r--tex/context/base/lang-def.lua47
1 files changed, 27 insertions, 20 deletions
diff --git a/tex/context/base/lang-def.lua b/tex/context/base/lang-def.lua
index 80ff13beb..c6bbcf3ae 100644
--- a/tex/context/base/lang-def.lua
+++ b/tex/context/base/lang-def.lua
@@ -1,15 +1,18 @@
-if not modules then modules = { } end modules ['lang-ini'] = {
+if not modules then modules = { } end modules ['lang-def'] = {
version = 1.001,
comment = "companion to lang-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
+ -- dataonly = true, -- saves 10K
}
+local rawget = rawget
local lower = string.lower
languages = languages or { }
local languages = languages
+languages.data = languages.data or { }
local data = languages.data
local allocate = utilities.storage.allocate
@@ -376,50 +379,54 @@ local contexts = { } data.contexts = contexts
local records = { } data.records = records
for k=1,#specifications do
- local v = specifications[k]
- if v.variant then
- variants[v.variant] = v
+ local specification = specifications[k]
+ local variant = specification.variant
+ if variant then
+ variants[lower(variant)] = specification
end
- if v.opentype then
- opentypes[v.opentype] = v
+ local opentype = specification.opentype
+ if opentype then
+ opentypes[lower(opentype)] = specification
end
- local vc = v.context
- if vc then
- if type(vc) == "table" then
- for k=1,#vc do
- contexts[v] = vc[k]
+ local context = context
+ if context then
+ if type(context) == "table" then
+ for k=1,#context do
+ contexts[context[k]] = specification
end
else
- contexts[vc] = v
+ contexts[context] = specification
end
end
end
+local defaultvariant = variants["en-us"]
+
setmetatableindex(variants, function(t,k)
- str = lower(str)
- local v = (l_variant[str] or l_opentype[str] or l_context[str] or l_variant.en).language
+ k = lower(k)
+ local v = (rawget(variants,k) or rawget(opentypes,k) or rawget(contexts,k) or defaultvariant).language
t[k] = v
return v
end)
setmetatableindex(opentypes, function(t,k)
- str = lower(str)
- local v = (l_variant[str] or l_opentype[str] or l_context[str] or l_variant.en).opentype
+ k = lower(k)
+ local v = (rawget(variants,k) or rawget(opentypes,k) or rawget(contexts,k) or defaultvariant).opentype
t[k] = v
return v
end)
setmetatableindex(contexts, function(t,k)
- str = lower(str)
- local v = (l_variant[str] or l_opentype[str] or l_context[str] or l_variant[languages.default]).context
+ k = lower(str)
+ local v = (rawget(variants,k) or rawget(opentypes,k) or rawget(contexts,k) or defaultvariant).context
v = (type(v) == "table" and v[1]) or v
t[k] = v
return v
end)
setmetatableindex(records, function(t,k) -- how useful is this one?
- str = lower(str)
- local v = variants[str] or opentypes[str] or contexts[str] or variants.en
+ k = lower(k)
+ local v = rawget(variants,k) or rawget(opentypes,k) or rawget(contexts,k) or defaultvariant
t[k] = v
return v
end)