summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/lang-def.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/lang-def.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/lang-def.lua84
1 files changed, 58 insertions, 26 deletions
diff --git a/Master/texmf-dist/tex/context/base/lang-def.lua b/Master/texmf-dist/tex/context/base/lang-def.lua
index 80ff13beb6b..6656d8ed978 100644
--- a/Master/texmf-dist/tex/context/base/lang-def.lua
+++ b/Master/texmf-dist/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
@@ -359,7 +362,7 @@ local specifications = allocate {
{
["description"] = "Chinese, simplified",
["script"] = "hans",
- ["opentype-script"] = "hani",
+ ["opentypescript"] = "hani",
["bibliographical"] = "chi",
["terminological"] = "zho",
["context"] = "cn",
@@ -370,56 +373,85 @@ local specifications = allocate {
data.specifications = specifications
-local variants = { } data.variants = variants
-local opentypes = { } data.opentypes = opentypes
-local contexts = { } data.contexts = contexts
-local records = { } data.records = records
+local variants = { } data.variants = variants
+local contexts = { } data.contexts = contexts
+local records = { } data.records = records
+local scripts = { } data.scripts = scripts
+local opentypes = { } data.opentypes = opentypes
+local opentypescripts = { } data.opentypescripts = opentypescripts
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 script = specification.script
+ if script then
+ scripts[lower(script)] = specification
+ end
+ local opentypescript = specification.opentypescript
+ if opentypescript then
+ opentypescripts[lower(opentypescript)] = specification
+ end
+ 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"]
+
+local function get(k,key)
+ local v = rawget(variants,k) or rawget(opentypes,k) or rawget(contexts,k)
+ return v and v[key]
+end
+
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 = get(k,"language") 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 = get(k,"opentype") or "dflt"
+ t[k] = v
+ return v
+end)
+
+setmetatableindex(opentypescripts, function(t,k)
+ k = lower(k)
+ local v = get(k,"opentypescript") or get(k,"script") or defaultvariant.opentypescript or defaultvariant.script
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
- v = (type(v) == "table" and v[1]) or v
+ k = lower(str)
+ local v = get(k,"context") 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 = get(k) or defaultvariant
t[k] = v
return v
end)
+
+-- print(opentypes.nl,opentypescripts.nl)
+-- print(opentypes.de,opentypescripts.de)