Remove vestigial translation plumbing.
This was never completed to the level required to be properly used ingame.
This commit is contained in:
committed by
Matthias Mailänder
parent
fb20479379
commit
6e7ad9df25
@@ -66,17 +66,11 @@ namespace OpenRA
|
||||
|
||||
static readonly ConcurrentCache<Type, FieldLoadInfo[]> TypeLoadInfo =
|
||||
new ConcurrentCache<Type, FieldLoadInfo[]>(BuildTypeLoadInfo);
|
||||
static readonly ConcurrentCache<MemberInfo, bool> MemberHasTranslateAttribute =
|
||||
new ConcurrentCache<MemberInfo, bool>(member => member.HasAttribute<TranslateAttribute>());
|
||||
|
||||
static readonly ConcurrentCache<string, BooleanExpression> BooleanExpressionCache =
|
||||
new ConcurrentCache<string, BooleanExpression>(expression => new BooleanExpression(expression));
|
||||
static readonly ConcurrentCache<string, IntegerExpression> IntegerExpressionCache =
|
||||
new ConcurrentCache<string, IntegerExpression>(expression => new IntegerExpression(expression));
|
||||
|
||||
static readonly object TranslationsLock = new object();
|
||||
static Dictionary<string, string> translations;
|
||||
|
||||
public static void Load(object self, MiniYaml my)
|
||||
{
|
||||
var loadInfo = TypeLoadInfo[self.GetType()];
|
||||
@@ -213,11 +207,7 @@ namespace OpenRA
|
||||
return InvalidValueAction(value, fieldType, fieldName);
|
||||
}
|
||||
else if (fieldType == typeof(string))
|
||||
{
|
||||
if (field != null && MemberHasTranslateAttribute[field] && value != null)
|
||||
return Regex.Replace(value, "@[^@]+@", m => Translate(m.Value.Substring(1, m.Value.Length - 2)), RegexOptions.Compiled);
|
||||
return value;
|
||||
}
|
||||
else if (fieldType == typeof(Color))
|
||||
{
|
||||
if (value != null && Color.TryParse(value, out var color))
|
||||
@@ -694,34 +684,8 @@ namespace OpenRA
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static string Translate(string key)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
return key;
|
||||
|
||||
lock (TranslationsLock)
|
||||
{
|
||||
if (translations == null)
|
||||
return key;
|
||||
|
||||
if (!translations.TryGetValue(key, out var value))
|
||||
return key;
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetTranslations(IDictionary<string, string> translations)
|
||||
{
|
||||
lock (TranslationsLock)
|
||||
FieldLoader.translations = new Dictionary<string, string>(translations);
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public sealed class TranslateAttribute : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public sealed class FieldFromYamlKeyAttribute : FieldLoader.SerializeAttribute
|
||||
{
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace OpenRA
|
||||
{
|
||||
public class GameSpeed
|
||||
{
|
||||
[Translate]
|
||||
public readonly string Name = "Default";
|
||||
public readonly int Timestep = 40;
|
||||
public readonly int OrderLatency = 3;
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace OpenRA
|
||||
public readonly string[]
|
||||
Rules, ServerTraits,
|
||||
Sequences, ModelSequences, Cursors, Chrome, Assemblies, ChromeLayout,
|
||||
Weapons, Voices, Notifications, Music, Translations, TileSets,
|
||||
Weapons, Voices, Notifications, Music, TileSets,
|
||||
ChromeMetrics, MapCompatibility, Missions, Hotkeys;
|
||||
|
||||
public readonly IReadOnlyDictionary<string, string> Packages;
|
||||
@@ -128,7 +128,6 @@ namespace OpenRA
|
||||
Voices = YamlList(yaml, "Voices");
|
||||
Notifications = YamlList(yaml, "Notifications");
|
||||
Music = YamlList(yaml, "Music");
|
||||
Translations = YamlList(yaml, "Translations");
|
||||
TileSets = YamlList(yaml, "TileSets");
|
||||
ChromeMetrics = YamlList(yaml, "ChromeMetrics");
|
||||
Missions = YamlList(yaml, "Missions");
|
||||
|
||||
@@ -173,7 +173,6 @@ namespace OpenRA
|
||||
new MapField("Voices", "VoiceDefinitions", required: false),
|
||||
new MapField("Music", "MusicDefinitions", required: false),
|
||||
new MapField("Notifications", "NotificationDefinitions", required: false),
|
||||
new MapField("Translations", "TranslationDefinitions", required: false)
|
||||
};
|
||||
|
||||
// Format versions
|
||||
@@ -204,7 +203,6 @@ namespace OpenRA
|
||||
public readonly MiniYaml VoiceDefinitions;
|
||||
public readonly MiniYaml MusicDefinitions;
|
||||
public readonly MiniYaml NotificationDefinitions;
|
||||
public readonly MiniYaml TranslationDefinitions;
|
||||
|
||||
public readonly Dictionary<CPos, TerrainTile> ReplacedInvalidTerrainTiles = new Dictionary<CPos, TerrainTile>();
|
||||
|
||||
|
||||
@@ -138,42 +138,6 @@ namespace OpenRA
|
||||
|
||||
public IEnumerable<string> Languages { get; private set; }
|
||||
|
||||
void LoadTranslations(Map map)
|
||||
{
|
||||
var selectedTranslations = new Dictionary<string, string>();
|
||||
var defaultTranslations = new Dictionary<string, string>();
|
||||
|
||||
if (!Manifest.Translations.Any())
|
||||
{
|
||||
Languages = new string[0];
|
||||
return;
|
||||
}
|
||||
|
||||
var yaml = MiniYaml.Load(map, Manifest.Translations, map.TranslationDefinitions);
|
||||
Languages = yaml.Select(t => t.Key).ToArray();
|
||||
|
||||
foreach (var y in yaml)
|
||||
{
|
||||
if (y.Key == Game.Settings.Graphics.Language)
|
||||
selectedTranslations = y.Value.ToDictionary(my => my.Value ?? "");
|
||||
else if (y.Key == Game.Settings.Graphics.DefaultLanguage)
|
||||
defaultTranslations = y.Value.ToDictionary(my => my.Value ?? "");
|
||||
}
|
||||
|
||||
var translations = new Dictionary<string, string>();
|
||||
foreach (var tkv in defaultTranslations.Concat(selectedTranslations))
|
||||
{
|
||||
if (translations.ContainsKey(tkv.Key))
|
||||
continue;
|
||||
if (selectedTranslations.ContainsKey(tkv.Key))
|
||||
translations.Add(tkv.Key, selectedTranslations[tkv.Key]);
|
||||
else
|
||||
translations.Add(tkv.Key, tkv.Value);
|
||||
}
|
||||
|
||||
FieldLoader.SetTranslations(translations);
|
||||
}
|
||||
|
||||
public Map PrepareMap(string uid)
|
||||
{
|
||||
LoadScreen?.Display();
|
||||
@@ -185,8 +149,6 @@ namespace OpenRA
|
||||
using (new Support.PerfTimer("Map"))
|
||||
map = new Map(this, MapCache[uid].Package);
|
||||
|
||||
LoadTranslations(map);
|
||||
|
||||
// Reinitialize all our assets
|
||||
InitializeLoaders(map);
|
||||
|
||||
|
||||
@@ -190,9 +190,6 @@ namespace OpenRA
|
||||
|
||||
public int BatchSize = 8192;
|
||||
public int SheetSize = 2048;
|
||||
|
||||
public string Language = "english";
|
||||
public string DefaultLanguage = "english";
|
||||
}
|
||||
|
||||
public class SoundSettings
|
||||
|
||||
@@ -17,11 +17,9 @@ namespace OpenRA.Traits
|
||||
[Desc("Required for shroud and fog visibility checks. Add this to the player actor.")]
|
||||
public class ShroudInfo : TraitInfo, ILobbyOptions
|
||||
{
|
||||
[Translate]
|
||||
[Desc("Descriptive label for the fog checkbox in the lobby.")]
|
||||
public readonly string FogCheckboxLabel = "Fog of War";
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for the fog checkbox in the lobby.")]
|
||||
public readonly string FogCheckboxDescription = "Line of sight is required to view enemy forces";
|
||||
|
||||
@@ -37,11 +35,9 @@ namespace OpenRA.Traits
|
||||
[Desc("Display order for the fog checkbox in the lobby.")]
|
||||
public readonly int FogCheckboxDisplayOrder = 0;
|
||||
|
||||
[Translate]
|
||||
[Desc("Descriptive label for the explored map checkbox in the lobby.")]
|
||||
public readonly string ExploredMapCheckboxLabel = "Explored Map";
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for the explored map checkbox in the lobby.")]
|
||||
public readonly string ExploredMapCheckboxDescription = "Initial map shroud is revealed";
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace OpenRA.Traits
|
||||
[Desc("The side that the faction belongs to. For example, England belongs to the 'Allies' side.")]
|
||||
public readonly string Side = null;
|
||||
|
||||
[Translate]
|
||||
public readonly string Description = null;
|
||||
|
||||
public readonly bool Selectable = true;
|
||||
|
||||
@@ -26,11 +26,9 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
[Desc("The prerequisite type that this provides.")]
|
||||
public readonly string Prerequisite = null;
|
||||
|
||||
[Translate]
|
||||
[Desc("Label to display over the support power icon and in its tooltip while the power is active.")]
|
||||
public readonly string ActiveText = "ACTIVE";
|
||||
|
||||
[Translate]
|
||||
[Desc("Label to display over the support power icon and in its tooltip while the power is available but not active.")]
|
||||
public readonly string AvailableText = "READY";
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Sort order for the production palette. Smaller numbers are presented earlier.")]
|
||||
public readonly int BuildPaletteOrder = 9999;
|
||||
|
||||
[Translate]
|
||||
[Desc("Text shown in the production tooltip.")]
|
||||
public readonly string Description = "";
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Delay for the end game notification in milliseconds.")]
|
||||
public readonly int NotificationDelay = 1500;
|
||||
|
||||
[Translate]
|
||||
[Desc("Description of the objective.")]
|
||||
public readonly string Objective = "Destroy all opposition!";
|
||||
|
||||
|
||||
@@ -19,11 +19,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Attach this to the player actor.")]
|
||||
public class DeveloperModeInfo : TraitInfo, ILobbyOptions
|
||||
{
|
||||
[Translate]
|
||||
[Desc("Descriptive label for the developer mode checkbox in the lobby.")]
|
||||
public readonly string CheckboxLabel = "Debug Menu";
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for the developer mode checkbox in the lobby.")]
|
||||
public readonly string CheckboxDescription = "Enables cheats and developer commands";
|
||||
|
||||
|
||||
@@ -18,11 +18,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class PlayerResourcesInfo : TraitInfo, ILobbyOptions
|
||||
{
|
||||
[Translate]
|
||||
[Desc("Descriptive label for the starting cash option in the lobby.")]
|
||||
public readonly string DefaultCashDropdownLabel = "Starting Cash";
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for the starting cash option in the lobby.")]
|
||||
public readonly string DefaultCashDropdownDescription = "Change the amount of cash that players start with";
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Internal id for this tech level.")]
|
||||
public readonly string Id;
|
||||
|
||||
[Translate]
|
||||
[Desc("Name shown in the lobby options.")]
|
||||
public readonly string Name;
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Delay for the end game notification in milliseconds.")]
|
||||
public readonly int NotificationDelay = 1500;
|
||||
|
||||
[Translate]
|
||||
[Desc("Description of the objective")]
|
||||
public readonly string Objective = "Hold all the strategic positions!";
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
[Desc("Displays a text overlay relative to the selection box.")]
|
||||
public class WithTextDecorationInfo : WithDecorationBaseInfo
|
||||
{
|
||||
[Translate]
|
||||
[FieldLoader.Require]
|
||||
public readonly string Text = null;
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public abstract class TooltipInfoBase : ConditionalTraitInfo, Requires<IMouseBoundsInfo>
|
||||
{
|
||||
[Translate]
|
||||
public readonly string Name = "";
|
||||
}
|
||||
|
||||
@@ -28,7 +27,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Shown in the build palette widget.")]
|
||||
public class TooltipInfo : TooltipInfoBase, ITooltipInfo
|
||||
{
|
||||
[Translate]
|
||||
[Desc("An optional generic name (i.e. \"Soldier\" or \"Structure\")" +
|
||||
"to be shown to chosen players.")]
|
||||
public readonly string GenericName = null;
|
||||
@@ -36,15 +34,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Prefix generic tooltip name with 'Ally/Neutral/EnemyPrefix'.")]
|
||||
public readonly bool GenericStancePrefix = true;
|
||||
|
||||
[Translate]
|
||||
[Desc("Prefix to display in the tooltip for allied units.")]
|
||||
public readonly string AllyPrefix = "Allied";
|
||||
|
||||
[Translate]
|
||||
[Desc("Prefix to display in the tooltip for neutral units.")]
|
||||
public readonly string NeutralPrefix = null;
|
||||
|
||||
[Translate]
|
||||
[Desc("Prefix to display in the tooltip for enemy units.")]
|
||||
public readonly string EnemyPrefix = "Enemy";
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class TooltipDescriptionInfo : ConditionalTraitInfo
|
||||
{
|
||||
[Desc("Text shown in tooltip.")]
|
||||
[Translate]
|
||||
public readonly string Description = "";
|
||||
|
||||
[Desc("Player relationships who can view the description.")]
|
||||
|
||||
@@ -20,11 +20,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class CrateSpawnerInfo : TraitInfo, ILobbyOptions
|
||||
{
|
||||
[Translate]
|
||||
[Desc("Descriptive label for the crates checkbox in the lobby.")]
|
||||
public readonly string CheckboxLabel = "Crates";
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for the crates checkbox in the lobby.")]
|
||||
public readonly string CheckboxDescription = "Collect crates with units to receive random bonuses or penalties";
|
||||
|
||||
|
||||
@@ -24,11 +24,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public readonly WDist InitialExploreRange = WDist.FromCells(5);
|
||||
|
||||
[Translate]
|
||||
[Desc("Descriptive label for the spawn positions checkbox in the lobby.")]
|
||||
public readonly string SeparateTeamSpawnsCheckboxLabel = "Separate Team Spawns";
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for the spawn positions checkbox in the lobby.")]
|
||||
public readonly string SeparateTeamSpawnsCheckboxDescription = "Players without assigned spawn points will start as far as possible from enemy players";
|
||||
|
||||
|
||||
@@ -17,11 +17,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Controls the build radius checkboxes in the lobby options.")]
|
||||
public class MapBuildRadiusInfo : TraitInfo, ILobbyOptions
|
||||
{
|
||||
[Translate]
|
||||
[Desc("Descriptive label for the ally build radius checkbox in the lobby.")]
|
||||
public readonly string AllyBuildRadiusCheckboxLabel = "Build off Allies";
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for the ally build radius checkbox in the lobby.")]
|
||||
public readonly string AllyBuildRadiusCheckboxDescription = "Allow allies to place structures inside your build area";
|
||||
|
||||
@@ -37,11 +35,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Display order for the ally build radius checkbox in the lobby.")]
|
||||
public readonly int AllyBuildRadiusCheckboxDisplayOrder = 0;
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for the build radius checkbox in the lobby.")]
|
||||
public readonly string BuildRadiusCheckboxLabel = "Limit Build Area";
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for the build radius checkbox in the lobby.")]
|
||||
public readonly string BuildRadiusCheckboxDescription = "Limits structure placement to areas around Construction Yards";
|
||||
|
||||
|
||||
@@ -17,11 +17,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Controls the 'Creeps' checkbox in the lobby options.")]
|
||||
public class MapCreepsInfo : TraitInfo, ILobbyOptions
|
||||
{
|
||||
[Translate]
|
||||
[Desc("Descriptive label for the creeps checkbox in the lobby.")]
|
||||
public readonly string CheckboxLabel = "Creep Actors";
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for the creeps checkbox in the lobby.")]
|
||||
public readonly string CheckboxDescription = "Hostile forces spawn on the battlefield";
|
||||
|
||||
|
||||
@@ -18,11 +18,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Controls the game speed, tech level, and short game lobby options.")]
|
||||
public class MapOptionsInfo : TraitInfo, ILobbyOptions, IRulesetLoaded
|
||||
{
|
||||
[Translate]
|
||||
[Desc("Descriptive label for the short game checkbox in the lobby.")]
|
||||
public readonly string ShortGameCheckboxLabel = "Short Game";
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for the short game checkbox in the lobby.")]
|
||||
public readonly string ShortGameCheckboxDescription = "Players are defeated when their bases are destroyed";
|
||||
|
||||
@@ -38,11 +36,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Display order for the short game checkbox in the lobby.")]
|
||||
public readonly int ShortGameCheckboxDisplayOrder = 0;
|
||||
|
||||
[Translate]
|
||||
[Desc("Descriptive label for the tech level option in the lobby.")]
|
||||
public readonly string TechLevelDropdownLabel = "Tech Level";
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for the tech level option in the lobby.")]
|
||||
public readonly string TechLevelDropdownDescription = "Change the units and abilities at your disposal";
|
||||
|
||||
@@ -58,11 +54,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Display order for the tech level option in the lobby.")]
|
||||
public readonly int TechLevelDropdownDisplayOrder = 0;
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for the game speed option in the lobby.")]
|
||||
public readonly string GameSpeedDropdownLabel = "Game Speed";
|
||||
|
||||
[Translate]
|
||||
[Desc("Description of the game speed option in the lobby.")]
|
||||
public readonly string GameSpeedDropdownDescription = "Change the rate at which time passes";
|
||||
|
||||
|
||||
@@ -21,12 +21,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Internal id for this option.")]
|
||||
public readonly string ID = null;
|
||||
|
||||
[Translate]
|
||||
[FieldLoader.Require]
|
||||
[Desc("Descriptive label for this option.")]
|
||||
public readonly string Label = null;
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for this option.")]
|
||||
public readonly string Description = null;
|
||||
|
||||
|
||||
@@ -23,11 +23,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public readonly string StartingUnitsClass = "none";
|
||||
|
||||
[Translate]
|
||||
[Desc("Descriptive label for the starting units option in the lobby.")]
|
||||
public readonly string DropdownLabel = "Starting Units";
|
||||
|
||||
[Translate]
|
||||
[Desc("Tooltip description for the starting units option in the lobby.")]
|
||||
public readonly string DropdownDescription = "Change the units that you start the game with";
|
||||
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenRA.Mods.Common.UtilityCommands
|
||||
{
|
||||
class ExtractLanguageStringsCommand : IUtilityCommand
|
||||
{
|
||||
string IUtilityCommand.Name { get { return "--extract-language-strings"; } }
|
||||
|
||||
bool IUtilityCommand.ValidateArguments(string[] args)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
[Desc("Extract translatable strings that are not yet localized and update chrome layout.")]
|
||||
void IUtilityCommand.Run(Utility utility, string[] args)
|
||||
{
|
||||
// HACK: The engine code assumes that Game.modData is set.
|
||||
var modData = Game.ModData = utility.ModData;
|
||||
|
||||
var types = modData.ObjectCreator.GetTypes();
|
||||
var translatableFields = types.SelectMany(t => t.GetFields())
|
||||
.Where(f => f.HasAttribute<TranslateAttribute>()).Distinct();
|
||||
|
||||
foreach (var filename in modData.Manifest.ChromeLayout)
|
||||
{
|
||||
modData.ModFiles.TryGetPackageContaining(filename, out var package, out var name);
|
||||
name = package.Name + "/" + name;
|
||||
Console.WriteLine("# {0}:", filename);
|
||||
|
||||
var yaml = MiniYaml.FromFile(name, false);
|
||||
FromChromeLayout(ref yaml, null,
|
||||
translatableFields.Select(t => t.Name).Distinct(), null);
|
||||
using (var file = new StreamWriter(name))
|
||||
file.WriteLine(yaml.WriteToString());
|
||||
}
|
||||
|
||||
// TODO: Properties can also be translated.
|
||||
}
|
||||
|
||||
internal static void FromChromeLayout(ref List<MiniYamlNode> nodes, MiniYamlNode parent, IEnumerable<string> translatables, string container)
|
||||
{
|
||||
var parentNode = parent != null && parent.Key != null ? parent.Key.Split('@') : null;
|
||||
var parentType = parent != null && parent.Key != null ? parentNode.First() : null;
|
||||
var parentLabel = parent != null && parent.Key != null ? parentNode.Last() : null;
|
||||
|
||||
if ((parentType == "Background" || parentType == "Container") && parentLabel.IsUppercase())
|
||||
container = parentLabel;
|
||||
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
var alreadyTranslated = node.Value.Value != null && node.Value.Value.Contains('@');
|
||||
if (translatables.Contains(node.Key) && !alreadyTranslated && parentLabel != null)
|
||||
{
|
||||
var translationKey = "{0}-{1}".F(parentLabel.Replace('_', '-'), node.Key.ToUpper());
|
||||
if (container != null)
|
||||
translationKey = "{0}-".F(container.Replace('_', '-')) + translationKey;
|
||||
Console.WriteLine("\t{0}: {1}", translationKey, node.Value.Value);
|
||||
node.Value.Value = "@{0}@".F(translationKey);
|
||||
}
|
||||
|
||||
FromChromeLayout(ref node.Value.Nodes, node, translatables, container);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,6 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
public bool DisableKeyRepeat = false;
|
||||
public bool DisableKeySound = false;
|
||||
|
||||
[Translate]
|
||||
public string Text = "";
|
||||
public TextAlign Align = TextAlign.Center;
|
||||
public int LeftMargin = 5;
|
||||
@@ -58,11 +57,9 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
protected Lazy<TooltipContainerWidget> tooltipContainer;
|
||||
|
||||
[Translate]
|
||||
public string TooltipText;
|
||||
public Func<string> GetTooltipText;
|
||||
|
||||
[Translate]
|
||||
public string TooltipDesc;
|
||||
public Func<string> GetTooltipDesc;
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
public Func<string> GetImageName;
|
||||
public Func<string> GetImageCollection;
|
||||
|
||||
[Translate]
|
||||
public string TooltipText;
|
||||
|
||||
Lazy<TooltipContainerWidget> tooltipContainer;
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
public class LabelWidget : Widget
|
||||
{
|
||||
[Translate]
|
||||
public string Text = null;
|
||||
public TextAlign Align = TextAlign.Left;
|
||||
public TextVAlign VAlign = TextVAlign.Middle;
|
||||
|
||||
@@ -247,13 +247,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
BindIntSliderPref(panel, "FRAME_LIMIT_SLIDER", ds, "MaxFramerate");
|
||||
BindCheckboxPref(panel, "PLAYER_STANCE_COLORS_CHECKBOX", gs, "UsePlayerStanceColors");
|
||||
|
||||
var languageDropDownButton = panel.GetOrNull<DropDownButtonWidget>("LANGUAGE_DROPDOWNBUTTON");
|
||||
if (languageDropDownButton != null)
|
||||
{
|
||||
languageDropDownButton.OnMouseDown = _ => ShowLanguageDropdown(languageDropDownButton, modData.Languages);
|
||||
languageDropDownButton.GetText = () => FieldLoader.Translate(ds.Language);
|
||||
}
|
||||
|
||||
var windowModeDropdown = panel.Get<DropDownButtonWidget>("MODE_DROPDOWN");
|
||||
windowModeDropdown.OnMouseDown = _ => ShowWindowModeDropdown(windowModeDropdown, ds);
|
||||
windowModeDropdown.GetText = () => ds.Mode == WindowMode.Windowed ?
|
||||
@@ -388,7 +381,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
ds.CapFramerate = dds.CapFramerate;
|
||||
ds.MaxFramerate = dds.MaxFramerate;
|
||||
ds.Language = dds.Language;
|
||||
ds.GLProfile = dds.GLProfile;
|
||||
ds.Mode = dds.Mode;
|
||||
ds.VideoDisplay = dds.VideoDisplay;
|
||||
@@ -828,21 +820,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, options.Keys, setupItem);
|
||||
}
|
||||
|
||||
static void ShowLanguageDropdown(DropDownButtonWidget dropdown, IEnumerable<string> languages)
|
||||
{
|
||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => Game.Settings.Graphics.Language == o,
|
||||
() => Game.Settings.Graphics.Language = o);
|
||||
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => FieldLoader.Translate(o);
|
||||
return item;
|
||||
};
|
||||
|
||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, languages, setupItem);
|
||||
}
|
||||
|
||||
static void ShowStatusBarsDropdown(DropDownButtonWidget dropdown, GameSettings s)
|
||||
{
|
||||
var options = new Dictionary<string, StatusBarsType>()
|
||||
|
||||
@@ -70,13 +70,10 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
public readonly bool DrawTime = true;
|
||||
|
||||
[Translate]
|
||||
public readonly string ReadyText = "";
|
||||
|
||||
[Translate]
|
||||
public readonly string HoldText = "";
|
||||
|
||||
[Translate]
|
||||
public readonly string InfiniteSymbol = "\u221E";
|
||||
|
||||
public int DisplayedIconCount { get; private set; }
|
||||
|
||||
@@ -22,10 +22,8 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
public class SupportPowersWidget : Widget
|
||||
{
|
||||
[Translate]
|
||||
public readonly string ReadyText = "";
|
||||
|
||||
[Translate]
|
||||
public readonly string HoldText = "";
|
||||
|
||||
public readonly string OverlayFont = "TinyBold";
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
english:
|
||||
english: English
|
||||
|
||||
@@ -140,9 +140,6 @@ Notifications:
|
||||
Music:
|
||||
cnc|audio/music.yaml
|
||||
|
||||
Translations:
|
||||
cnc|languages/english.yaml
|
||||
|
||||
Hotkeys:
|
||||
common|hotkeys/game.yaml
|
||||
common|hotkeys/observer.yaml
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
english:
|
||||
english: English
|
||||
@@ -127,9 +127,6 @@ Notifications:
|
||||
Music:
|
||||
d2k|audio/music.yaml
|
||||
|
||||
Translations:
|
||||
d2k|languages/english.yaml
|
||||
|
||||
Hotkeys:
|
||||
common|hotkeys/game.yaml
|
||||
common|hotkeys/observer.yaml
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
english:
|
||||
english: English
|
||||
@@ -1,2 +0,0 @@
|
||||
english:
|
||||
english: English
|
||||
@@ -185,9 +185,6 @@ Notifications:
|
||||
Music:
|
||||
ts|audio/music.yaml
|
||||
|
||||
Translations:
|
||||
ts|languages/english.yaml
|
||||
|
||||
Hotkeys:
|
||||
common|hotkeys/game.yaml
|
||||
common|hotkeys/observer.yaml
|
||||
|
||||
Reference in New Issue
Block a user