Skip to content

Commit

Permalink
better locale unmatch penalty (fix #102, fix #104)
Browse files Browse the repository at this point in the history
- give locale unmatch penalty also for lang config missing cases
- english documents should not get this penalty. They do not have
  file lang info in most cases
  • Loading branch information
wtsnjp committed Feb 2, 2024
1 parent 004d2b1 commit 1d2ceb6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions script/texdoclib-score.tlu
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,20 @@ local function set_score(df, original_kw)

-- bonus for locale
local config_lang = texdoc.config.get_value('lang')
if not is_alias and config_lang ~= nil then
if not is_alias then
local file_lang = df.lang

if not file_lang then
_, file_lang, _ = parse(name)
file_lang = texdoc.const.lang_codes[file_lang]
end

if config_lang == file_lang then
if config_lang ~= nil and config_lang == file_lang then
score = score + 1
dbg_score('Locale match bonus: +1.0')
elseif file_lang ~= nil then
elseif file_lang ~= nil and file_lang ~= 'en' then
-- normally, english documents do not have file_lang,
-- but sometimes the catalog includes en info (e.g., geometry)
score = score - 0.1
dbg_score('Locale unmatch: -0.1')
end
Expand Down

0 comments on commit 1d2ceb6

Please sign in to comment.