Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/snippets/other.7201.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Add localization support for scenario names and descriptions in map selection (#7201).
1 change: 1 addition & 0 deletions loc/TW/strings_db.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,7 @@ SCMP_005_Description="這群島嶼曾經是走私者的天堂,它是以在這
SCMP_006_Description="以早期一位探險者為名的伊昂路口曾經見識過無數的戰役。相當開闊的地區和大量的質量積點導致多年連續不斷的戰爭。"
SCMP_007_Description="「空手」是被冰雪包圍的一小長條綠地,沒有人能肯定最早是誰想出這個名字來的。傳說中這裡原是中立地帶,各陣營的士兵都可以前來此地,不用擔心受到攻擊。因此,所有前來此地的人都是「空手」的,表示沒有攜帶武器。"
SCMP_008_Description="多年以來,這些冰河一直都由「萬古」進行開採,也是他們取的名字。但是,隨著戰役的進行,「萬古」已經被驅離,冰河將屬於能夠守住這個地方的人所有。"
Setons_Clutch_Name="塞頓之握"
SCMP_009_Description="過去幾年中,「塞頓之握」已經發生過數十次戰鬥。有耐心的搜索者可以在地裡和水裡發現數千個部隊的遺物。"
SCMP_010_Description="曾有一個名叫「宋」的酋長將這個島嶼視為家。他選擇此地,一方面因為這裡極美,也因為這裡的資源豐富。宋早已被趕走,但是留下的資源等候有能耐的人來開採。"
SCMP_011_Description="這裡曾經是一塊小型大陸,UEF在這裡建造一處研究基地,進行先進武器測試。研究人員無法控制一項實驗性武器,造成的爆炸毀了整個大陸,使它成為分散的島嶼。現在三個陣營都試圖尋找這個武器的資料,以便利用。"
Expand Down
36 changes: 33 additions & 3 deletions lua/ui/dialogs/mapselect.lua
Original file line number Diff line number Diff line change
Expand Up @@ -962,11 +962,41 @@ function SetupOptionsPanel(parent, curOptions)
UIUtil.CreateLobbyVertScrollbar(OptionContainer, -1, -5, -27)
end

-- Generate LOC entries for scenario names
function LOCN(str, type)
local name = str
name = name:gsub(' %- ', '_'):gsub('%-', '_'):gsub(':', ''):gsub("'", ''):gsub('%w+ Mission %d+ ', ''):gsub(' ', '_')
if string.find(str, '<LOC') then
return LOC(str)
elseif type == 'campaign_coop' then
return LOC('<LOC FAF_Coop_'..name..'_Name>'..str)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its not a good idea to hardcode FAF_Coop_, it's a convention for custom missions, not a requirement.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. FAF_Coop_ is not required in the mission name, folder, OPERATION_NAME, or OPERATION_DESCRIPTION. The function only checks whether the input already contains <LOC. If it does, it uses that value unchanged. If it does not, the function generates a LOC entry, and FAF_Coop_ is only part of that generated output.
For example, mission “Fort Clarke Assault” has original name OPERATION_NAME = 'Fort Clarke Assault', this function produces <LOC FAF_Coop_Fort_Clarke_Assault_Name>Fort Clarke Assault.
Therefore, FAF_Coop_ is not used to identify or validate a custom mission. It is only added when constructing the output localization key.

elseif type == 'skirmish' then
return LOC('<LOC '..name..'_Name>'..str)
else
return str
end
end

-- Generate LOC entries for scenario descriptions
function LOCD(str1, str2, type)
local name = str1
name = name:gsub(' %- ', '_'):gsub('%-', '_'):gsub(':', ''):gsub("'", ''):gsub('%w+ Mission %d+ ', ''):gsub(' ', '_')
if string.find(str2, '<LOC') or str2 == '' then
return LOC(str2)
elseif type == 'campaign_coop' then
return LOC('<LOC FAF_Coop_'..name..'_Description>'..str2)
elseif type == 'skirmish' then
return LOC('<LOC '..name..'_Desc>'..str2)
else
return str2
end
end

function SetDescription(scen)
local errors = false
description:DeleteAllItems()
if scen.name then
description:AddItem(scen.name)
description:AddItem(LOCN(scen.name, scen.type))
else
description:AddItem(LOC("<LOC map_select_0006>No Scenario Name"))
errors = true
Expand Down Expand Up @@ -998,7 +1028,7 @@ function SetDescription(scen)
description:AddItem("")
if scen.description then
local textBoxWidth = description.Width()
local wrapped = import("/lua/maui/text.lua").WrapText(LOC(scen.description), textBoxWidth,
local wrapped = import("/lua/maui/text.lua").WrapText(LOCD(scen.name, scen.description, scen.type), textBoxWidth,
function(curText) return description:GetStringAdvance(curText) end)
for i, line in wrapped do
description:AddItem(line)
Expand Down Expand Up @@ -1050,7 +1080,7 @@ function PopulateMapList()
reselectRow = count
end
count = count + 1
mapList:AddItem(LOC(sceninfo.name))
mapList:AddItem(LOCN(sceninfo.name, sceninfo.type))
end
end

Expand Down