Item: add missing localization check
This commit is contained in:
@@ -31,6 +31,12 @@ local RARITY_INDEX = {
|
|||||||
['unique'] = 0
|
['unique'] = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Keys indicating the languages for which localization presence is checked.
|
||||||
|
local LANG_CODES = {'en', 'ru'}
|
||||||
|
|
||||||
|
-- Number of missed localizations.
|
||||||
|
local missedLocaleCount = 0
|
||||||
|
|
||||||
---@class Item
|
---@class Item
|
||||||
---@field itemDef Item.ItemDefinition
|
---@field itemDef Item.ItemDefinition
|
||||||
---@field luantiDef ItemDefinition
|
---@field luantiDef ItemDefinition
|
||||||
@@ -79,6 +85,16 @@ local defMerge = function(...)
|
|||||||
return tableMerge(...)
|
return tableMerge(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function checkLocale(str, strTranslate)
|
||||||
|
local modName = Mod.getInfo().name
|
||||||
|
for _, langCode in ipairs(LANG_CODES) do
|
||||||
|
if core.get_translated_string(langCode, strTranslate) == str then
|
||||||
|
missedLocaleCount = missedLocaleCount + 1
|
||||||
|
Logger.warningLog('Localization missing[%s][%s]. String: `%s`. Mod: `%s`', missedLocaleCount, langCode, str, modName)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
---@param itemDef Item.ItemDefinition
|
---@param itemDef Item.ItemDefinition
|
||||||
---@return NodeDefinition|ItemDefinition
|
---@return NodeDefinition|ItemDefinition
|
||||||
local function itemDefToLuantiDef(itemDef)
|
local function itemDefToLuantiDef(itemDef)
|
||||||
@@ -89,8 +105,7 @@ local function itemDefToLuantiDef(itemDef)
|
|||||||
local s = itemDef.settings
|
local s = itemDef.settings
|
||||||
local c = itemDef.callbacks
|
local c = itemDef.callbacks
|
||||||
|
|
||||||
local title = s._title
|
local title, description = s._title, s._description
|
||||||
local description = s._description
|
|
||||||
|
|
||||||
if title == nil or title == '' then
|
if title == nil or title == '' then
|
||||||
title = string.match(s.name, '%S:(%S+)')..'-title'
|
title = string.match(s.name, '%S:(%S+)')..'-title'
|
||||||
@@ -100,9 +115,14 @@ local function itemDefToLuantiDef(itemDef)
|
|||||||
description = string.match(s.name, '%S:(%S+)')..'-desc'
|
description = string.match(s.name, '%S:(%S+)')..'-desc'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local titleTranslate, descriptionTranslate = S(title), S(description)
|
||||||
|
|
||||||
|
checkLocale(title, titleTranslate)
|
||||||
|
checkLocale(description, descriptionTranslate)
|
||||||
|
|
||||||
if s._title_color ~= nil and s._description_color ~= nil then
|
if s._title_color ~= nil and s._description_color ~= nil then
|
||||||
title = colorize(s._title_color ,S(title))
|
titleTranslate = colorize(s._title_color , titleTranslate)
|
||||||
description = colorize(s._description_color, S(description))
|
descriptionTranslate = colorize(s._description_color, descriptionTranslate)
|
||||||
else
|
else
|
||||||
error('Item description color parameters cannot be empty.')
|
error('Item description color parameters cannot be empty.')
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user