5

Problem

In historical German some words can be written with both 'ß' and 's', e.g. "Erkenntniß" and "Erkenntnis".

Since I want to depict these different variants in my index, I use both \index{Erkenntnis} and \index{Erkenntniß}:

\mainlanguage[de]
\language[de]

\defineregister[custom]
\setupregister[custom]
  [compress=yes,
   indicator=no,
   pagestyle=\tf,
   n=1]

\starttext

In historischer Schreibung sind \custom{Erkenntniß}Erkenntniß 
und \custom{Erkenntnis}Erkenntnis identisch.

\page

In historischer Schreibung sind \custom{Erkenntnis}Erkenntnis 
und \custom{Erkenntniß}Erkenntniß identisch.

\page

\placecustom

\stoptext

But since 'ß' is mapped to 's' instead of 'ss' (which is more common), "Erkenntniß" and "Erkenntnis" are mixed up in the index:

mixture of two terms


Question

What can I do to have two separate entries for these terms, i.e. map 'ß' to 'ss'? I already tried to configure sort-lan.lua, but that didn't yield any results and the sorting remained the same.

I also noticed that the mapping of 'ß' to 'ss' is somehow suppressed in lang-ini.lua, but since I'm pretty new to Lua I don't know whether or how I should change this function.

5

This is definitely not nice. The code below is relying on the specific layout of the replacements table in sort-lan.lua.

definitions['de']    = {
    parent = 'default',
    replacements = {
        { "ä", 'ae' }, { "Ä", 'Ae' },
        { "ö", 'oe' }, { "Ö", 'Oe' },
        { "ü", 'ue' }, { "Ü", 'Ue' },
        { "ß", 's'  },
    },
}

As you can count, the character we want to replace is the second in the seventh subtable, i.e. sorters.definitions["de"].replacements[7][2] = "ss".

\mainlanguage[de]
\language[de]

\defineregister[custom]
\setupregister[custom]
  [compress=yes,
   indicator=no,
   pagestyle=\tf,
   n=1]

\startluacode
sorters.definitions["de"].replacements[7][2] = "ss"
\stopluacode

\starttext

In historischer Schreibung sind \custom{Erkenntniß}Erkenntniß 
und \custom{Erkenntnis}Erkenntnis identisch.

\page

In historischer Schreibung sind \custom{Erkenntnis}Erkenntnis 
und \custom{Erkenntniß}Erkenntniß identisch.

\page

\placecustom

\stoptext

enter image description here

If you don't want to rely on the fact that the ß/s replacement is in place number seven, you could also explicitly search for it using

for _,v in pairs(sorters.definitions["de"].replacements) do
   local char = unpack(v)
   if char == "ß" then
       v[2] = "ss"
   end
end
  • Thanks a lot for your answer! I accessed the table directly (without searching for the entry), and everything works as it should. – meliade Mar 19 '18 at 8:38
  • 1
    @meliade I think it might be a good idea to guard the direct access in some way, e.g. if sorters.definitions["de"].replacements[7][1] == "ß" then sorters.definitions["de"].replacements[7][2] = "ss" else error("BOOM!") end so that you are “notified” if the table layout changes. – Henri Menke Mar 19 '18 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.