Rename Translations yaml keys to FluentMessages.
This commit is contained in:
@@ -40,16 +40,16 @@ namespace OpenRA.Mods.Common.Lint
|
||||
foreach (var context in usedKeys.EmptyKeyContexts)
|
||||
emitWarning($"Empty key in map ftl files required by {context}");
|
||||
|
||||
var mapTranslations = FieldLoader.GetValue<string[]>("value", map.FluentMessageDefinitions.Value);
|
||||
var allModTranslations = modData.Manifest.Translations;
|
||||
var mapMessages = FieldLoader.GetValue<string[]>("value", map.FluentMessageDefinitions.Value);
|
||||
var modMessages = modData.Manifest.FluentMessages;
|
||||
|
||||
// For maps we don't warn on unused keys. They might be unused on *this* map,
|
||||
// but the mod or another map may use them and we don't have sight of that.
|
||||
CheckKeys(allModTranslations.Concat(mapTranslations), map.Open, usedKeys,
|
||||
CheckKeys(modMessages.Concat(mapMessages), map.Open, usedKeys,
|
||||
_ => false, emitError, emitWarning);
|
||||
|
||||
var modFluentBundle = new FluentBundle(modData.Manifest.FluentCulture, allModTranslations, modData.DefaultFileSystem, _ => { });
|
||||
var mapFluentBundle = new FluentBundle(modData.Manifest.FluentCulture, mapTranslations, map, error => emitError(error.Message));
|
||||
var modFluentBundle = new FluentBundle(modData.Manifest.FluentCulture, modMessages, modData.DefaultFileSystem, _ => { });
|
||||
var mapFluentBundle = new FluentBundle(modData.Manifest.FluentCulture, mapMessages, map, error => emitError(error.Message));
|
||||
|
||||
foreach (var group in usedKeys.KeysWithContext)
|
||||
{
|
||||
@@ -79,14 +79,14 @@ namespace OpenRA.Mods.Common.Lint
|
||||
foreach (var context in usedKeys.EmptyKeyContexts)
|
||||
emitWarning($"Empty key in mod translation files required by {context}");
|
||||
|
||||
var allModTranslations = modData.Manifest.Translations.ToArray();
|
||||
var modMessages = modData.Manifest.FluentMessages.ToArray();
|
||||
CheckModWidgets(modData, usedKeys, testedFields);
|
||||
|
||||
// With the fully populated keys, check keys and variables are not missing and not unused across all language files.
|
||||
var keyWithAttrs = CheckKeys(
|
||||
allModTranslations, modData.DefaultFileSystem.Open, usedKeys,
|
||||
modMessages, modData.DefaultFileSystem.Open, usedKeys,
|
||||
file =>
|
||||
!modData.Manifest.AllowUnusedTranslationsInExternalPackages ||
|
||||
!modData.Manifest.AllowUnusedFluentMessagesInExternalPackages ||
|
||||
!modData.DefaultFileSystem.IsExternalFile(file),
|
||||
emitError, emitWarning);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
|
||||
void ILintPass.Run(Action<string> emitError, Action<string> emitWarning, ModData modData)
|
||||
{
|
||||
Run(emitError, emitWarning, modData.DefaultFileSystem, modData.Manifest.Translations);
|
||||
Run(emitError, emitWarning, modData.DefaultFileSystem, modData.Manifest.FluentMessages);
|
||||
}
|
||||
|
||||
static void Run(Action<string> emitError, Action<string> emitWarning, IReadOnlyFileSystem fileSystem, IEnumerable<string> paths)
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
MergeAndPrint(map, "Voices", map.VoiceDefinitions);
|
||||
MergeAndPrint(map, "Music", map.MusicDefinitions);
|
||||
MergeAndPrint(map, "Notifications", map.NotificationDefinitions);
|
||||
MergeAndPrintFluentMessages(map, "Translations", map.FluentMessageDefinitions);
|
||||
MergeAndPrintFluentMessages(map, "FluentMessages", map.FluentMessageDefinitions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
const string Enftl = "en.ftl";
|
||||
ExtractFromFile(Path.Combine(package.Name, Enftl), mapRules, traitInfos, () =>
|
||||
{
|
||||
var node = yaml.NodeWithKeyOrDefault("Translations");
|
||||
var node = yaml.NodeWithKeyOrDefault("FluentMessages");
|
||||
if (node != null)
|
||||
{
|
||||
var value = node.NodeValue<string[]>();
|
||||
@@ -94,7 +94,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
node.Value.Value = string.Join(", ", value.Concat(new string[] { Enftl }).ToArray());
|
||||
}
|
||||
else
|
||||
yaml.Nodes.Add(new MiniYamlNodeBuilder("Translations", Enftl));
|
||||
yaml.Nodes.Add(new MiniYamlNodeBuilder("FluentMessages", Enftl));
|
||||
});
|
||||
|
||||
mapRules.Save();
|
||||
|
||||
Reference in New Issue
Block a user