diff --git a/OpenRA.Game/Traits/World/Faction.cs b/OpenRA.Game/Traits/World/Faction.cs index 950985d1d4..cd93bf8a6a 100644 --- a/OpenRA.Game/Traits/World/Faction.cs +++ b/OpenRA.Game/Traits/World/Faction.cs @@ -17,6 +17,7 @@ namespace OpenRA.Traits [TraitLocation(SystemActors.World | SystemActors.EditorWorld)] public class FactionInfo : TraitInfo { + [TranslationReference] [Desc("This is the name exposed to the players.")] public readonly string Name = null; @@ -29,6 +30,8 @@ namespace OpenRA.Traits [Desc("The side that the faction belongs to. For example, England belongs to the 'Allies' side.")] public readonly string Side = null; + [TranslationReference(optional: true)] + [Desc("This is shown in the lobby as a tooltip.")] public readonly string Description = null; public readonly bool Selectable = true; diff --git a/OpenRA.Mods.Common/Lint/CheckTranslationReference.cs b/OpenRA.Mods.Common/Lint/CheckTranslationReference.cs index 439a5e8ca7..d1738d9fd0 100644 --- a/OpenRA.Mods.Common/Lint/CheckTranslationReference.cs +++ b/OpenRA.Mods.Common/Lint/CheckTranslationReference.cs @@ -110,8 +110,7 @@ namespace OpenRA.Mods.Common.Lint if (translationReference == null) continue; - var keys = LintExts.GetFieldValues(traitInfo, field, translationReference.DictionaryReference); - foreach (var key in keys) + foreach (var key in LintExts.GetFieldValues(traitInfo, field, translationReference.DictionaryReference)) usedKeys.Add(key, translationReference, $"Actor `{actorInfo.Key}` trait `{traitType.Name[..^4]}.{field.Name}`"); } } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs index 8131d86b87..fa503b561b 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoStatsLogic.cs @@ -255,7 +255,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (player == null || player.RelationshipWith(pp) == PlayerRelationship.Ally || player.WinState != WinState.Undefined) { flag.GetImageName = () => pp.Faction.InternalName; - factionName = pp.Faction.Name != factionName ? $"{factionName} ({pp.Faction.Name})" : pp.Faction.Name; + factionName = pp.Faction.Name != factionName + ? $"{TranslationProvider.GetString(factionName)} ({TranslationProvider.GetString(pp.Faction.Name)})" + : TranslationProvider.GetString(pp.Faction.Name); } else flag.GetImageName = () => pp.DisplayFaction.InternalName; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs index a70fe592d7..07dab3745a 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs @@ -219,7 +219,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic colorManager = modRules.Actors[SystemActors.World].TraitInfo(); foreach (var f in modRules.Actors[SystemActors.World].TraitInfos()) - factions.Add(f.InternalName, new LobbyFaction { Selectable = f.Selectable, Name = f.Name, Side = f.Side, Description = f.Description?.Replace(@"\n", "\n") }); + factions.Add(f.InternalName, new LobbyFaction { Selectable = f.Selectable, Name = f.Name, Side = f.Side, Description = f.Description }); var gameStarting = false; Func configurationDisabled = () => !Game.IsHost || gameStarting || diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs index a9e0da0f9b..30569efb1d 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs @@ -222,14 +222,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic var faction = factions[factionId]; var label = item.Get("LABEL"); - var labelText = WidgetUtils.TruncateText(faction.Name, label.Bounds.Width, Game.Renderer.Fonts[label.Font]); + var labelText = WidgetUtils.TruncateText(TranslationProvider.GetString(faction.Name), label.Bounds.Width, Game.Renderer.Fonts[label.Font]); label.GetText = () => labelText; var flag = item.Get("FLAG"); flag.GetImageCollection = () => "flags"; flag.GetImageName = () => factionId; - var (text, desc) = SplitOnFirstToken(faction.Description); + var description = faction.Description != null ? TranslationProvider.GetString(faction.Description) : null; + var (text, desc) = SplitOnFirstToken(description); item.GetTooltipText = () => text; item.GetTooltipDesc = () => desc; @@ -237,7 +238,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } var options = factions.Where(f => f.Value.Selectable).GroupBy(f => f.Value.Side) - .ToDictionary(g => g.Key ?? "", g => g.Select(f => f.Key)); + .ToDictionary(g => g.Key != null ? TranslationProvider.GetString(g.Key) : "", g => g.Select(f => TranslationProvider.GetString(f.Key))); dropdown.ShowDropDown("FACTION_DROPDOWN_TEMPLATE", 154, options, SetupItem); } @@ -551,7 +552,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic dropdown.IsDisabled = () => s.LockFaction || orderManager.LocalClient.IsReady; dropdown.OnMouseDown = _ => ShowFactionDropDown(dropdown, c, orderManager, factions); - var (text, desc) = SplitOnFirstToken(factions[c.Faction].Description); + var description = factions[c.Faction].Description != null ? TranslationProvider.GetString(factions[c.Faction].Description) : null; + var (text, desc) = SplitOnFirstToken(description); dropdown.GetTooltipText = () => text; dropdown.GetTooltipDesc = () => desc; @@ -563,7 +565,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var factionName = parent.Get("FACTIONNAME"); var font = Game.Renderer.Fonts[factionName.Font]; var truncated = new CachedTransform(clientFaction => - WidgetUtils.TruncateText(factions[clientFaction].Name, factionName.Bounds.Width, font)); + WidgetUtils.TruncateText(TranslationProvider.GetString(factions[clientFaction].Name), factionName.Bounds.Width, font)); factionName.GetText = () => truncated.Update(c.Faction); var factionFlag = parent.Get("FACTIONFLAG"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs index e27f0e9fd2..c671663d9e 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs @@ -443,7 +443,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic options.Insert(0, null); // no filter var anyText = ddb.GetText(); - ddb.GetText = () => string.IsNullOrEmpty(filter.Faction) ? anyText : filter.Faction; + ddb.GetText = () => string.IsNullOrEmpty(filter.Faction) ? anyText : TranslationProvider.GetString(filter.Faction); ddb.OnMouseDown = _ => { ScrollItemWidget SetupItem(string option, ScrollItemWidget tpl) @@ -452,7 +452,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic tpl, () => string.Equals(filter.Faction, option, StringComparison.CurrentCultureIgnoreCase), () => { filter.Faction = option; ApplyFilter(); }); - item.Get("LABEL").GetText = () => option ?? anyText; + item.Get("LABEL").GetText = () => option != null ? TranslationProvider.GetString(option) : anyText; return item; } diff --git a/mods/cnc/languages/rules/en.ftl b/mods/cnc/languages/rules/en.ftl index f2db316833..00f22bd720 100644 --- a/mods/cnc/languages/rules/en.ftl +++ b/mods/cnc/languages/rules/en.ftl @@ -32,6 +32,25 @@ dropdown-map-creeps = resource-tiberium = Tiberium +faction-random = + .name = Any + .description = Random Faction + A random faction will be chosen when the game starts + +faction-gdi = + .name = GDI + .description = Global Defense Initiative + The GDI is an international military branch of the United Nations tasked + with keeping world peace. Commanding the combined forces of the world's + most powerful nations, they possess an unmatched arsenal of high-tech weaponry. + +faction-nod = + .name = Nod + .description = Brotherhood of Nod + The Brotherhood is a religious cult centered around their leader Kane + and the alien substance Tiberium. They utilize stealth technology + and guerilla tactics to defeat those who oppose them. + ## defaults.yaml notification-unit-lost = Unit lost. notification-unit-promoted = Unit promoted. @@ -540,4 +559,3 @@ actor-truck = Builds fast Unarmed .name = Supply Truck - diff --git a/mods/cnc/rules/world.yaml b/mods/cnc/rules/world.yaml index 4b2f8db7d2..76e18622db 100644 --- a/mods/cnc/rules/world.yaml +++ b/mods/cnc/rules/world.yaml @@ -125,18 +125,18 @@ BlueTiberium: 100 Beach: 89 Faction@Random: - Name: Any + Name: faction-random.name InternalName: Random RandomFactionMembers: gdi, nod - Description: Random Faction\nA random faction will be chosen when the game starts. + Description: faction-random.description Faction@gdi: - Name: GDI + Name: faction-gdi.name InternalName: gdi - Description: Global Defense Initiative\nThe GDI is an international military branch of the United Nations tasked\nwith keeping world peace. Commanding the combined forces of the world's\nmost powerful nations, they possess an unmatched arsenal of high-tech weaponry. + Description: faction-gdi.description Faction@nod: - Name: Nod + Name: faction-nod.name InternalName: nod - Description: Brotherhood of Nod\nThe Brotherhood is a religious cult centered around their leader Kane\nand the alien substance Tiberium. They utilize stealth technology\nand guerilla tactics to defeat those who oppose them. + Description: faction-nod.description ResourceRenderer: ResourceTypes: Tiberium: diff --git a/mods/d2k/languages/rules/en.ftl b/mods/d2k/languages/rules/en.ftl index 043fa1860e..9cbbda72ee 100644 --- a/mods/d2k/languages/rules/en.ftl +++ b/mods/d2k/languages/rules/en.ftl @@ -33,6 +33,77 @@ options-starting-units = resource-spice = Spice +faction-random = + .name = Any + .description = Random House + A random house will be chosen when the game starts. + +faction-atreides = + .name = Atreides + .description = House Atreides + The noble Atreides, from the water world of Caladan, + rely on their ornithopters to ensure air superiority. + They have allied themselves with the Fremen, the fearsome + native warriors of Dune that can move undetected in battle. + + Faction Variations: + - Combat tanks are balanced in terms of speed and durability + + Special Units: + - Grenadier + - Fremen + - Sonic Tank + + Superweapon: + - Airstrike + +faction-harkonnen = + .name = Harkonnen + .description = House Harkonnen + The evil Harkonnen will stop at nothing to gain control of the spice. + They rely on brute force and atomic weapons to achieve their goals: + wealth, and the destruction of House Atreides. + + Faction Variations: + - Combat Tanks are more durable but slower + + Special Units: + - Sardaukar + - Devastator + + Superweapon: + - Death Hand Missile + +faction-ordos = + .name = Ordos + .description = House Ordos + The insidious Ordos of the icy planet Sigma Draconis IV + are known for their wealth, greed and treachery. + Relying heavily on mercenaries they often resort + to sabotage and forbidden Ixian technologies. + + Faction Variations: + - Trikes are replaced by Raider Trikes + - Combat Tanks are faster but less durable + + Special Units: + - Raider Trike + - Stealth Raider Trike + - Saboteur + - Deviator + +faction-corrino = + .name = Corrino + +faction-mercenaries = + .name = Mercenaries + +faction-smugglers = + .name = Smugglers + +faction-fremen = + .name = Fremen + ## defaults.yaml notification-unit-lost = Unit lost. notification-unit-promoted = Unit promoted. diff --git a/mods/d2k/rules/world.yaml b/mods/d2k/rules/world.yaml index fe540f98f3..e1dc6439bf 100644 --- a/mods/d2k/rules/world.yaml +++ b/mods/d2k/rules/world.yaml @@ -77,36 +77,36 @@ SpiceSand: 100 Spice: 100 Faction@Random: - Name: Any + Name: faction-random.name InternalName: Random RandomFactionMembers: atreides, harkonnen, ordos - Description: Random House\nA random house will be chosen when the game starts. + Description: faction-random.description Faction@Atreides: - Name: Atreides + Name: faction-atreides.name InternalName: atreides - Description: House Atreides\nThe noble Atreides, from the water world of Caladan,\nrely on their ornithopters to ensure air superiority.\nThey have allied themselves with the Fremen, the fearsome\nnative warriors of Dune that can move undetected in battle.\n\nFaction Variations:\n - Combat tanks are balanced in terms of speed and durability\n\nSpecial Units:\n - Grenadier\n - Fremen\n - Sonic Tank\n\nSuperweapon:\n - Airstrike + Description: faction-atreides.description Faction@Harkonnen: - Name: Harkonnen + Name: faction-harkonnen.name InternalName: harkonnen - Description: House Harkonnen\nThe evil Harkonnen will stop at nothing to gain control of the spice.\nThey rely on brute force and atomic weapons to achieve their goals:\nwealth, and the destruction of House Atreides.\n\nFaction Variations:\n - Combat Tanks are more durable but slower \n\nSpecial Units:\n - Sardaukar\n - Devastator\n\nSuperweapon: \n - Death Hand Missile + Description: faction-harkonnen.description Faction@Ordos: - Name: Ordos + Name: faction-ordos.name InternalName: ordos - Description: House Ordos\nThe insidious Ordos of the icy planet Sigma Draconis IV\nare known for their wealth, greed and treachery.\nRelying heavily on mercenaries they often resort\nto sabotage and forbidden Ixian technologies.\n\nFaction Variations: \n - Trikes are replaced by Raider Trikes\n - Combat Tanks are faster but less durable\n\nSpecial Units:\n - Raider Trike\n - Stealth Raider Trike\n - Saboteur\n - Deviator + Description: faction-ordos.description Faction@Corrino: - Name: Corrino + Name: faction-corrino.name InternalName: corrino Selectable: false Faction@Mercenaries: - Name: Mercenaries + Name: faction-mercenaries.name InternalName: mercenary Selectable: false Faction@Smugglers: - Name: Smugglers + Name: faction-smugglers.name InternalName: smuggler Selectable: false Faction@Fremen: - Name: Fremen + Name: faction-fremen.name InternalName: fremen Selectable: false D2kResourceRenderer: diff --git a/mods/ra/languages/rules/en.ftl b/mods/ra/languages/rules/en.ftl index 6be01f4441..e696aad80f 100644 --- a/mods/ra/languages/rules/en.ftl +++ b/mods/ra/languages/rules/en.ftl @@ -34,6 +34,58 @@ options-starting-units = resource-minerals = Valuable Minerals +## Faction +faction-allies = + .name = Allies + +faction-england = + .name = England + .description = England: Counterintelligence + Special Unit: British Spy + Special Unit: Mobile Gap Generator + +faction-france = + .name = France + .description = France: Deception + Special Ability: Can build fake structures + Special Unit: Phase Transport + +faction-germany = + .name = Germany + .description = Germany: Technology + Special Ability: Advanced Chronoshift + Special Unit: Chrono Tank + +faction-soviet = + .name = Soviet + +faction-russia = + .name = Russia + .description = Russia: Tesla Weapons + Special Unit: Tesla Tank + Special Unit: Shock Trooper + +faction-ukraine = + .name = Ukraine + .description = Ukraine: Demolitions + Special Ability: Parabombs + Special Unit: Demolition Truck + +faction-random = + .name = Any + .description = Random Country + A random country will be chosen when the game starts. + +faction-randomallies = + .name = Allies + .description = Random Allied Country + A random Allied country will be chosen when the game starts. + +faction-randomsoviet = + .name = Soviet + .description = Random Soviet Country + A random Soviet country will be chosen when the game starts. + ## aircraft.yaml actor-badr-name = Badger diff --git a/mods/ra/rules/world.yaml b/mods/ra/rules/world.yaml index 54d1cc882f..c8bcce582c 100644 --- a/mods/ra/rules/world.yaml +++ b/mods/ra/rules/world.yaml @@ -97,59 +97,59 @@ FogVariants: shroud Index: 255, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 20, 40, 56, 65, 97, 130, 148, 194, 24, 33, 66, 132, 28, 41, 67, 134, 1, 2, 4, 8, 3, 6, 12, 9, 7, 14, 13, 11, 5, 10, 15, 255 UseExtendedIndex: true - Faction@0: - Name: Allies + Faction@allies: + Name: faction-allies.name InternalName: allies Side: Allies Selectable: False - Faction@1: - Name: England + Faction@england: + Name: faction-england.name InternalName: england Side: Allies - Description: England: Counterintelligence\nSpecial Unit: British Spy\nSpecial Unit: Mobile Gap Generator - Faction@2: - Name: France + Description: faction-england.description + Faction@france: + Name: faction-france.name InternalName: france Side: Allies - Description: France: Deception\nSpecial Ability: Can build fake structures\nSpecial Unit: Phase Transport - Faction@3: - Name: Germany + Description: faction-france.description + Faction@germany: + Name: faction-germany.name InternalName: germany Side: Allies - Description: Germany: Technology\nSpecial Ability: Advanced Chronoshift\nSpecial Unit: Chrono Tank - Faction@4: - Name: Soviet + Description: faction-germany.description + Faction@soviet: + Name: faction-soviet.name InternalName: soviet Side: Soviet Selectable: False - Faction@5: - Name: Russia + Faction@russia: + Name: faction-russia.name InternalName: russia Side: Soviet - Description: Russia: Tesla Weapons\nSpecial Unit: Tesla Tank\nSpecial Unit: Shock Trooper - Faction@6: - Name: Ukraine + Description: faction-russia.description + Faction@ukraine: + Name: faction-ukraine.name InternalName: ukraine Side: Soviet - Description: Ukraine: Demolitions\nSpecial Ability: Parabombs\nSpecial Unit: Demolition Truck + Description: faction-ukraine.description Faction@random: - Name: Any + Name: faction-random.name InternalName: Random RandomFactionMembers: RandomAllies, RandomSoviet Side: Random - Description: Random Country\nA random country will be chosen when the game starts. + Description: faction-random.description Faction@randomallies: - Name: Allies + Name: faction-randomallies.name InternalName: RandomAllies RandomFactionMembers: england, france, germany Side: Random - Description: Random Allied Country\nA random Allied country will be chosen when the game starts. + Description: faction-randomallies.description Faction@randomsoviet: - Name: Soviet + Name: faction-randomsoviet.name InternalName: RandomSoviet RandomFactionMembers: russia, ukraine Side: Random - Description: Random Soviet Country\nA random Soviet country will be chosen when the game starts. + Description: faction-randomsoviet.description ResourceRenderer: ResourceTypes: Ore: diff --git a/mods/ts/languages/rules/en.ftl b/mods/ts/languages/rules/en.ftl index 70891ae04b..fee22feb2c 100644 --- a/mods/ts/languages/rules/en.ftl +++ b/mods/ts/languages/rules/en.ftl @@ -32,6 +32,25 @@ dropdown-map-creeps = resource-veins = Veins resource-tiberium = Tiberium +faction-random = + .name = Any + .description = Random Faction + A random faction will be chosen when the game starts + +faction-gdi = + .name = GDI + .description = Global Defense Initiative + The GDI is an international military branch of the United Nations tasked + with keeping world peace. Commanding the combined forces of the world's + most powerful nations, they possess an unmatched arsenal of high-tech weaponry. + +faction-nod = + .name = Nod + .description = Brotherhood of Nod + The Brotherhood is a religious cult centered around their leader Kane + and the alien substance Tiberium. They utilize stealth technology + and guerilla tactics to defeat those who oppose them. + ## Structures notification-construction-complete = Construction complete. notification-unit-ready = Unit ready. diff --git a/mods/ts/rules/world.yaml b/mods/ts/rules/world.yaml index 86838ad70d..1d025555cf 100644 --- a/mods/ts/rules/world.yaml +++ b/mods/ts/rules/world.yaml @@ -189,18 +189,18 @@ Rail: 100 Crushes: wall, crate, infantry Faction@Random: - Name: Any + Name: faction-random.name InternalName: Random RandomFactionMembers: gdi, nod - Description: Random Faction\nA random faction will be chosen when the game starts. - Faction@0: - Name: GDI + Description: faction-random.description + Faction@gdi: + Name: faction-gdi.name InternalName: gdi - Description: Global Defense Initiative\nThe GDI is an international military branch of the United Nations tasked\nwith keeping world peace. Commanding the combined forces of the world's\nmost powerful nations, they possess an unmatched arsenal of high-tech weaponry. - Faction@1: - Name: Nod + Description: faction-gdi.description + Faction@nod: + Name: faction-nod.name InternalName: nod - Description: Brotherhood of Nod\nThe Brotherhood is a religious cult centered around their leader Kane\nand the alien substance Tiberium. They utilize stealth technology\nand guerilla tactics to defeat those who oppose them. + Description: faction-nod.description TerrainGeometryOverlay: DebugVisualizations: CliffBackImpassabilityLayer: