1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-19 10:23:15 +00:00

Replace string.format with l10n in playerskillhandlers

This commit is contained in:
Evil Eye 2025-11-24 20:11:07 +01:00
parent 0a04bfa46d
commit f7ad7a8263
3 changed files with 26 additions and 10 deletions

View file

@ -15,6 +15,9 @@ set(BUILTIN_DATA_MW_FILES
# Generic UI messages that can be reused by mods # Generic UI messages that can be reused by mods
l10n/Interface/gmst.yaml l10n/Interface/gmst.yaml
# L10n for game-specific mechanics
l10n/Mechanics/gmst.yaml
# L10n for OpenMW menus and non-game-specific messages # L10n for OpenMW menus and non-game-specific messages
l10n/OMWEngine/gmst.yaml l10n/OMWEngine/gmst.yaml

View file

@ -0,0 +1,17 @@
ReleasedFromPrison:
pattern: |-
{days, plural,
one{{gmst:sNotifyMessage42}}
other{{gmst:sNotifyMessage43}}
}
variables:
- ["days"]
- ["days"]
SkillIncreasedTo:
pattern: "{gmst:sNotifyMessage39}"
variables:
- ["skill", "level"]
SkillDecreasedTo:
pattern: "{gmst:sNotifyMessage44}"
variables:
- ["skill", "level"]

View file

@ -8,6 +8,7 @@ local NPC = types.NPC
local Actor = types.Actor local Actor = types.Actor
local ui = require('openmw.ui') local ui = require('openmw.ui')
local auxUtil = require('openmw_aux.util') local auxUtil = require('openmw_aux.util')
local mechanicsL10n = core.l10n('Mechanics')
local function tableHasValue(table, value) local function tableHasValue(table, value)
for _, v in pairs(table) do for _, v in pairs(table) do
@ -99,7 +100,7 @@ local function skillLevelUpHandler(skillid, source, params)
ambient.playSound("skillraise") ambient.playSound("skillraise")
local message = string.format(core.getGMST('sNotifyMessage39'),skillRecord.name,skillStat.base) local message = mechanicsL10n('SkillIncreasedTo', { skill = skillRecord.name, level = skillStat.base })
if source == I.SkillProgression.SKILL_INCREASE_SOURCES.Book then if source == I.SkillProgression.SKILL_INCREASE_SOURCES.Book then
message = '#{sBookSkillMessage}\n'..message message = '#{sBookSkillMessage}\n'..message
@ -134,21 +135,16 @@ local function jailTimeServed(days)
I.SkillProgression.skillLevelUp(skillid, I.SkillProgression.SKILL_INCREASE_SOURCES.Jail) I.SkillProgression.skillLevelUp(skillid, I.SkillProgression.SKILL_INCREASE_SOURCES.Jail)
end end
local message = '' local message = mechanicsL10n('ReleasedFromPrison', { days = days });
if days == 1 then
message = string.format(core.getGMST('sNotifyMessage42'), days)
else
message = string.format(core.getGMST('sNotifyMessage43'), days)
end
for skillid, skillStat in pairs(NPC.stats.skills) do for skillid, skillStat in pairs(NPC.stats.skills) do
local diff = skillStat(self).base - oldSkillLevels[skillid] local diff = skillStat(self).base - oldSkillLevels[skillid]
if diff ~= 0 then if diff ~= 0 then
local skillMsg = core.getGMST('sNotifyMessage39') local skillMsg = 'SkillIncreasedTo'
if diff < 0 then if diff < 0 then
skillMsg = core.getGMST('sNotifyMessage44') skillMsg = 'SkillDecreasedTo'
end end
local skillRecord = Skill.record(skillid) local skillRecord = Skill.record(skillid)
message = message..'\n'..string.format(skillMsg, skillRecord.name, skillStat(self).base) message = message..'\n'..mechanicsL10n(skillMsg, { skill = skillRecord.name, level = skillStat(self).base })
end end
end end