Module:Soldier: Difference between revisions
Infobox: drop State (NARA residence); keep in Technical record |
Infobox: drop certificate/arrive/depart/years; expand other_class codes |
||
| Line 709: | Line 709: | ||
end | end | ||
return prettyProse(s) | return prettyProse(s) | ||
end | |||
-- Roster "other_class" codes → readable course names (By The Numbers / MITC charts). | |||
local function expandOtherClassToken(tok) | |||
tok = tidyDisplay(tok) | |||
if tok == '' then | |||
return '' | |||
end | |||
local u = mw.ustring.upper(tok) | |||
u = mw.ustring.gsub(u, '%s+', ' ') | |||
u = trim(u) | |||
local n = mw.ustring.match(u, '^SC%s*B%s*(%d+)$') | |||
if n then | |||
return 'Special Course B ' .. n | |||
end | |||
n = mw.ustring.match(u, '^SC%s*(%d+)$') | |||
if n then | |||
-- SC# aligns with AGF Photo Interpretation / “Special Course” numbering | |||
-- (e.g. SC8 = Special Course 8 in PI). | |||
return 'Special Course ' .. n | |||
end | |||
n = mw.ustring.match(u, '^DC%s*(%d+)$') | |||
if n then | |||
return 'Division Class ' .. n | |||
end | |||
n = mw.ustring.match(u, '^MITU%s*(%d+)$') | |||
if n then | |||
return 'Mobile Intelligence Training Unit ' .. n | |||
end | |||
n = mw.ustring.match(u, '^RDC%s*(%d+)$') | |||
if n then | |||
return 'Redeployment Class ' .. n | |||
end | |||
n = mw.ustring.match(u, '^RCM%s*(%d+)$') | |||
if n then | |||
return 'Radio Countermeasures Class ' .. n | |||
end | |||
n = mw.ustring.match(u, '^OB%s*(%d+)$') | |||
if n then | |||
return 'Order of Battle Class ' .. n | |||
end | |||
if u == 'SIG' or u == 'SIG-SIG' or mw.ustring.match(u, '^SIG[%s%-]') then | |||
return 'Special Intelligence Group–Signal' | |||
end | |||
local unitNum, unitKind = mw.ustring.match(u, '^(%d+)(?:ST|ND|RD|TH)%s+(.+)$') | |||
if unitNum and unitKind then | |||
local kind = trim(unitKind) | |||
if kind == 'INF' then | |||
kind = 'Infantry' | |||
elseif kind == 'ARMD' then | |||
kind = 'Armored' | |||
else | |||
kind = prettyProse(kind) | |||
end | |||
local ord = unitNum | |||
local last = mw.ustring.sub(unitNum, -1) | |||
local last2 = mw.ustring.len(unitNum) >= 2 and mw.ustring.sub(unitNum, -2) or '' | |||
if last2 ~= '11' and last2 ~= '12' and last2 ~= '13' then | |||
if last == '1' then | |||
ord = unitNum .. 'st' | |||
elseif last == '2' then | |||
ord = unitNum .. 'nd' | |||
elseif last == '3' then | |||
ord = unitNum .. 'rd' | |||
else | |||
ord = unitNum .. 'th' | |||
end | |||
else | |||
ord = unitNum .. 'th' | |||
end | |||
return ord .. ' ' .. kind | |||
end | |||
return prettyProse(tok) | |||
end | |||
local function expandOtherClass(raw) | |||
raw = tidyDisplay(raw) | |||
if raw == '' then | |||
return '' | |||
end | |||
local parts = {} | |||
for piece in mw.ustring.gmatch(raw, '[^;,]+') do | |||
local expanded = expandOtherClassToken(piece) | |||
if expanded ~= '' then | |||
table.insert(parts, expanded) | |||
end | |||
end | |||
return table.concat(parts, '; ') | |||
end | end | ||
| Line 1,916: | Line 2,007: | ||
addRow(tbl, 'Arm / service', prettyProse(armName)) | addRow(tbl, 'Arm / service', prettyProse(armName)) | ||
end | end | ||
-- years_of_service / date_arrive / date_depart / certificate stay in Technical | |||
-- record only (rarely curated; certificate is a cryptic chart number). | |||
addRow(tbl, 'ASN', parentArg(frame, 'asn'), 'serial') | addRow(tbl, 'ASN', parentArg(frame, 'asn'), 'serial') | ||
| Line 1,938: | Line 2,030: | ||
end | end | ||
addRow(tbl, 'Section', mw.ustring.upper(parentArg(frame, 'class_section'))) | addRow(tbl, 'Section', mw.ustring.upper(parentArg(frame, 'class_section'))) | ||
addRow(tbl, 'Other class', parentArg(frame, 'other_class')) | addRow(tbl, 'Other class', expandOtherClass(parentArg(frame, 'other_class'))) | ||
local enlist = prettyPlace(parentArg(frame, 'enlistment_place')) | local enlist = prettyPlace(parentArg(frame, 'enlistment_place')) | ||
| Line 1,948: | Line 2,040: | ||
addRow(tbl, 'Battles / wars', formatBattles(parentArg(frame, 'battles'))) | addRow(tbl, 'Battles / wars', formatBattles(parentArg(frame, 'battles'))) | ||
addTeamsInfoboxRow(tbl, frame) | addTeamsInfoboxRow(tbl, frame) | ||
-- Awards ribbons render in the article body (p.awardsSection), not this | -- Awards ribbons render in the article body (p.awardsSection), not this | ||