mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 19:22:53 +01:00
[UpdateAssemblyInfo] Update General/Version in XML translation files
In addition to updating the version (major.minor.maintenance) in AssemblyInfo.cs.template, also update the XML translation files when preparing a new release.
This commit is contained in:
parent
57a9bfa480
commit
b02f68d6b4
@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
|
||||
namespace UpdateAssemblyInfo
|
||||
{
|
||||
@ -131,6 +133,22 @@ namespace UpdateAssemblyInfo
|
||||
}
|
||||
}
|
||||
|
||||
private static void UpdateTranslations(string languagesFolderName, VersionInfo newVersion, VersionInfo oldVersion)
|
||||
{
|
||||
var fileNamePattern = string.Format(@"[\{0}\{1}][a-z]{{2,3}}-[A-Za-z-]+\.xml\z", Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
|
||||
var fileNameRegex = new Regex(fileNamePattern, RegexOptions.Compiled | RegexOptions.ExplicitCapture);
|
||||
var translation = new XmlDocument { XmlResolver = null };
|
||||
|
||||
foreach (var fileName in Directory.EnumerateFiles(languagesFolderName).Where(fn => fileNameRegex.IsMatch(fn)))
|
||||
{
|
||||
translation.Load(fileName);
|
||||
var node = translation.DocumentElement.SelectSingleNode("General/Version") as XmlElement;
|
||||
if (node != null && node.InnerText.Trim() == oldVersion.ShortVersion)
|
||||
node.InnerText = newVersion.ShortVersion;
|
||||
translation.Save(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
private static void UpdateAssemblyInfo(string templateFileName, VersionInfo newVersion, bool updateTemplateFile = false)
|
||||
{
|
||||
var templateText = File.ReadAllText(templateFileName).TrimEnd();
|
||||
@ -268,6 +286,11 @@ namespace UpdateAssemblyInfo
|
||||
if (newVersion != currentVersion)
|
||||
{
|
||||
Console.WriteLine(" updating version number to " + newVersion.FullVersion);
|
||||
if (updateTemplateFile) {
|
||||
var oldVersion = GetTemplateVersion(seTemplateFileName);
|
||||
var languagesFolderName = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(seTemplateFileName)), "Languages");
|
||||
UpdateTranslations(languagesFolderName, newVersion, oldVersion);
|
||||
}
|
||||
UpdateAssemblyInfo(libSeTemplateFileName, newVersion, updateTemplateFile);
|
||||
UpdateAssemblyInfo(seTemplateFileName, newVersion, updateTemplateFile);
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CommandLineRunner.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user