• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sile-typesetter / sile / 6932773445

20 Nov 2023 04:11PM UTC coverage: 60.703% (-1.6%) from 62.266%
6932773445

Pull #1904

github

alerque
feat(utilities): Add Greek alphabetical (non-arithmetic) numbering

Useful in some context such as biblical annotations etc. where greek
characters are used orderly for numbering.
Pull Request #1904: Merge develop into master (commit to next release being breaking)

66 of 193 new or added lines in 19 files covered. (34.2%)

321 existing lines in 26 files now uncovered.

9452 of 15571 relevant lines covered (60.7%)

2104.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/core/languages.lua
1
local loadkit = require("loadkit")
120✔
2
local cldr = require("cldr")
120✔
3

4
loadkit.register("ftl", function (file)
240✔
5
  local contents = assert(file:read("*a"))
135✔
6
  file:close()
135✔
7
  return assert(fluent:add_messages(contents))
270✔
8
end)
9

10
local loadonce = {}
120✔
11

12
SILE.languageSupport = {
120✔
13
  languages = {},
120✔
14
  loadLanguage = function (language)
15
    language = language or SILE.settings:get("document.language")
3,977✔
16
    language = cldr.locales[language] and language or "und"
3,977✔
17
    if loadonce[language] then return end
3,977✔
18
    loadonce[language] = true
135✔
19
    local langresource = string.format("languages.%s", language)
135✔
20
    local gotlang, lang = pcall(require, langresource)
135✔
21
    if not gotlang then
135✔
22
      SU.warn(("Unable to load language feature support (e.g. hyphenation rules) for %s: %s")
2✔
23
        :format(language, lang:gsub(":.*", "")))
1✔
24
    end
25
    local ftlresource = string.format("i18n.%s", language)
135✔
26
    SU.debug("fluent", "Loading FTL resource", ftlresource, "into locale", language)
135✔
27
    fluent:set_locale(language)
135✔
28
    local gotftl, ftl = pcall(require, ftlresource)
135✔
29
    if not gotftl then
135✔
UNCOV
30
      SU.warn(("Unable to load localized strings (e.g. table of contents header text) for %s: %s")
×
UNCOV
31
        :format(language, ftl:gsub(":.*", "")))
×
32
    end
33
    if type(lang) == "table" and lang.init then
135✔
34
      lang.init()
2✔
35
    end
36
  end
37
}
120✔
38

39
SILE.registerCommand("language", function (options, content)
240✔
40
  local main = SU.required(options, "main", "language setting")
6✔
41
  SILE.languageSupport.loadLanguage(main)
6✔
42
  if content[1] then
6✔
43
    SILE.settings:temporarily(function ()
4✔
44
      SILE.settings:set("document.language", main)
2✔
45
      SILE.process(content)
2✔
46
    end)
47
  else
48
    SILE.settings:set("document.language", main)
4✔
49
  end
50
end, nil, nil, true)
126✔
51

52
SILE.registerCommand("fluent", function (options, content)
240✔
53
  local key = content[1]
3✔
54
  local locale = options.locale or SILE.settings:get("document.language")
3✔
55
  SU.debug("fluent", "Looking for", key, "in", locale)
3✔
56
  local entry
57
  if key then
3✔
58
    fluent:set_locale(locale)
3✔
59
    entry = fluent:get_message(key)
6✔
60
  else
61
    SU.warn("Fluent localization function called without passing a valid message id")
×
62
  end
63
  local message
64
  if entry then
3✔
65
    message = entry:format(options)
6✔
66
  else
67
    SU.warn(string.format("No localized message for %s found in locale %s", key, locale))
×
68
    fluent:set_locale('und')
×
69
    entry = fluent:get_message(key)
×
70
    if entry then
×
71
      message = entry:format(options)
×
72
    end
73
    fluent:set_locale(locale)
×
74
  end
75
  SILE.processString(("<sile>%s</sile>"):format(message), "xml")
3✔
76
end, nil, nil, true)
123✔
77

78
SILE.registerCommand("ftl", function (options, content)
240✔
79
  local locale = options.locale or SILE.settings:get("document.language")
1✔
80
  SU.debug("fluent", "Loading message(s) into locale", locale)
1✔
81
  fluent:set_locale(locale)
1✔
82
  if options.src then
1✔
83
    fluent:load_file(options.src, locale)
×
84
  elseif SU.hasContent(content) then
2✔
85
    local input = content[1]
1✔
86
    fluent:add_messages(input, locale)
1✔
87
  end
88
end, nil, nil, true)
121✔
89

90
require("languages.unicode")
120✔
91

92
-- The following languages neither have hyphenation nor specific
93
-- language support at present. This code is here to suppress warnings.
94
SILE.hyphenator.languages.ar = { patterns = {} }
120✔
95
SILE.hyphenator.languages.bo = { patterns = {} }
120✔
96
SILE.hyphenator.languages.sd = { patterns = {} }
120✔
97
SILE.hyphenator.languages.ur = { patterns = {} }
120✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc