Multilingual lorem() Package for Arab, Greek, Korea, Nüshu and every language on the Earth

I search the Typst Universe, there are lorem() packages for cn, jp ,ru. But lorem() should not be limited into a single language or letters’ system, right? And a multilingual version could done rashly, perhaps within one week. Here is a try:

#set par(justify:true)

#let Latin = range(0x0041, 0x007b)  //    58 Latin Basic Letter
#let Korea = range(0xac00, 0xd7b0)  // 11184 Korea Hangul Syllable
#let Greek = range(0x0370, 0x0400)  //   144 Greek Script
#let Arab  = range(0x0600, 0x0700)  //   256 Arabic Script
#let Nüshu = range(0x1b170, 0x1b300)//   400 China Women Writing

#let Lang = ("la":Latin, "ko":Korea, "el":Greek, "ar":Arab, "nü":Nüshu )
#let Len = Latin.len()

// lorem() Multilingual
#let loreM(words, lang:"la", start:0, step:1) = {
  let i = lorem(words)
  let o = ""

  let gap = Lang.at(lang).at(0) - Latin.at(0)
  let cap = Lang.at(lang).len() - Len + 1
  let n = start - step

  for c in i {
    n = n + step
    if c in " ,.?!:;'–()" { o += c; continue }  // – is not -, \u{2013} \u{2d}
    o = o + str.from-unicode(c.to-unicode() + gap + calc.rem(n, cap)) }

  if lang == "ar" { box(text(dir:rtl, o)) }
  else { o } }

#lorem(16)\
#loreM(16)\
#loreM(16, lang:"ko")\
#loreM(16, lang:"el")\
#loreM(16, lang:"ar")\
#loreM(16, lang:"nü")\

  • However, I don’t know rust, so can not edit the lipsum.rs library.
  • It seems Texlive has a multilingual lorem lipsum if u search apt…
texlive lipsum lorem

apt search lipsum
Sorting... Done
Full Text Search... Done
geany-plugin-lipsum/...
...
texlive-lang-arabic/... TeX Live: Arabic

texlive-lang-chinese/... TeX Live: Chinese

texlive-lang-european/... TeX Live: Other European languages

texlive-lang-italian/... TeX Live: Italian ...