adjust LangResCollector for v1.14
This commit is contained in:
15
SM64 ROM Manager.LangResCollector/LangResFilterConfig.cs
Normal file
15
SM64 ROM Manager.LangResCollector/LangResFilterConfig.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SM64_ROM_Manager.LangRes_Collector
|
||||||
|
{
|
||||||
|
internal class LangResFilterConfig
|
||||||
|
{
|
||||||
|
public string[] FileNameBlackList { get; set; }
|
||||||
|
public string[] FileNameWhiteList { get; set; }
|
||||||
|
public string[] PropNameBlackList { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,8 +7,10 @@ using System.Resources;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.WindowsAPICodePack.Dialogs;
|
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace SM64_ROM_Manager_LangRes_Collector
|
namespace SM64_ROM_Manager.LangRes_Collector
|
||||||
{
|
{
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
@@ -17,24 +19,9 @@ namespace SM64_ROM_Manager_LangRes_Collector
|
|||||||
var resFiles = new List<string>();
|
var resFiles = new List<string>();
|
||||||
var ofd = new CommonOpenFileDialog { IsFolderPicker = true };
|
var ofd = new CommonOpenFileDialog { IsFolderPicker = true };
|
||||||
string rootPath, outputPath;
|
string rootPath, outputPath;
|
||||||
var fileNameBlackList = new string[]
|
var myAppDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||||
{
|
var myConfigFilePath = Path.Combine(myAppDir, "FilterConfig.json");
|
||||||
"Resources.resx",
|
var filterConfig = JObject.Parse(File.ReadAllText(myConfigFilePath)).ToObject<LangResFilterConfig>();
|
||||||
"My*Icons.resx",
|
|
||||||
"*.de.resx",
|
|
||||||
"ReflectionSymbols.resx",
|
|
||||||
"UpdatingAdministrationLangRes"
|
|
||||||
};
|
|
||||||
var fileNameWhiteList = new string[]
|
|
||||||
{
|
|
||||||
"*.resx"
|
|
||||||
};
|
|
||||||
var blackListPropNames = new string[]
|
|
||||||
{
|
|
||||||
">>*",
|
|
||||||
"*.AccessibleName",
|
|
||||||
"*.AccessibleDescription"
|
|
||||||
};
|
|
||||||
|
|
||||||
// Get root path
|
// Get root path
|
||||||
ofd.Title = "Root (repository) directory";
|
ofd.Title = "Root (repository) directory";
|
||||||
@@ -53,18 +40,18 @@ namespace SM64_ROM_Manager_LangRes_Collector
|
|||||||
// Collect files
|
// Collect files
|
||||||
if (Directory.Exists(rootPath))
|
if (Directory.Exists(rootPath))
|
||||||
{
|
{
|
||||||
foreach (var filePath in Directory.GetFiles(rootPath, "*.resx", SearchOption.AllDirectories))
|
foreach (var filePath in Directory.GetFiles(rootPath, string.Empty, SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
var fileName = Path.GetFileName(filePath);
|
var fileName = Path.GetFileName(filePath);
|
||||||
var copyFile = true;
|
var copyFile = true;
|
||||||
|
|
||||||
foreach (var blackFileName in fileNameBlackList)
|
foreach (var blackFileName in filterConfig.FileNameBlackList)
|
||||||
{
|
{
|
||||||
if (copyFile && LikeString(fileName, blackFileName, CompareMethod.Binary))
|
if (copyFile && LikeString(fileName, blackFileName, CompareMethod.Binary))
|
||||||
copyFile = false;
|
copyFile = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var whiteFileName in fileNameWhiteList)
|
foreach (var whiteFileName in filterConfig.FileNameWhiteList)
|
||||||
{
|
{
|
||||||
if (copyFile && !LikeString(fileName, whiteFileName, CompareMethod.Binary))
|
if (copyFile && !LikeString(fileName, whiteFileName, CompareMethod.Binary))
|
||||||
copyFile = false;
|
copyFile = false;
|
||||||
@@ -90,16 +77,16 @@ namespace SM64_ROM_Manager_LangRes_Collector
|
|||||||
var propName = (string)kvp.Key;
|
var propName = (string)kvp.Key;
|
||||||
var useProp = true;
|
var useProp = true;
|
||||||
|
|
||||||
foreach (var blackPropName in blackListPropNames)
|
// Check for blacklisted property names
|
||||||
|
foreach (var blackPropName in filterConfig.PropNameBlackList)
|
||||||
{
|
{
|
||||||
if (useProp && LikeString(propName, blackPropName, CompareMethod.Binary))
|
if (useProp && LikeString(propName, blackPropName, CompareMethod.Binary))
|
||||||
useProp = false;
|
useProp = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useProp && kvp.Value is string)
|
// Hold property to write later, if it's a string
|
||||||
|
if (useProp && kvp.Value is string val)
|
||||||
{
|
{
|
||||||
var val = (string)kvp.Value;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(val))
|
if (!string.IsNullOrEmpty(val))
|
||||||
propsToCopy.Add(propName, (string)kvp.Value);
|
propsToCopy.Add(propName, (string)kvp.Value);
|
||||||
}
|
}
|
||||||
@@ -110,9 +97,16 @@ namespace SM64_ROM_Manager_LangRes_Collector
|
|||||||
// Write output ResX file
|
// Write output ResX file
|
||||||
if (propsToCopy.Any())
|
if (propsToCopy.Any())
|
||||||
{
|
{
|
||||||
var resFileOutput = Path.Combine(outputPath, Path.GetFileName(resFileInput));
|
var resFileOutput = Path.Combine(outputPath, resFileInput.Replace(rootPath, outputPath));
|
||||||
|
var resFileOutputDir = Path.GetDirectoryName(resFileOutput);
|
||||||
|
|
||||||
|
// Ensure the directory exists
|
||||||
|
Directory.CreateDirectory(resFileOutputDir);
|
||||||
|
|
||||||
|
// Open a ResXResourceWriter
|
||||||
var resWriter = new ResXResourceWriter(resFileOutput);
|
var resWriter = new ResXResourceWriter(resFileOutput);
|
||||||
|
|
||||||
|
// Write all hold properties
|
||||||
foreach (var kvp in propsToCopy)
|
foreach (var kvp in propsToCopy)
|
||||||
resWriter.AddResource(kvp.Key, kvp.Value);
|
resWriter.AddResource(kvp.Key, kvp.Value);
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,14 @@
|
|||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0-windows7</TargetFramework>
|
<TargetFramework>net6.0-windows7</TargetFramework>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<RootNamespace>SM64_ROM_Manager_LangRes_Collector</RootNamespace>
|
<RootNamespace>SM64_ROM_Manager.LangRes_Collector</RootNamespace>
|
||||||
<StartupObject>SM64_ROM_Manager_LangRes_Collector.Program</StartupObject>
|
<StartupObject>SM64_ROM_Manager.LangRes_Collector.Program</StartupObject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="FastColoredTextBox-net5" Version="2.17.30.100" />
|
<PackageReference Include="FastColoredTextBox.Net5" Version="2.16.26" />
|
||||||
<PackageReference Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.4" />
|
<PackageReference Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.4" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -20,12 +21,18 @@
|
|||||||
<Reference Include="DevComponents.DotNetBar.Charts">
|
<Reference Include="DevComponents.DotNetBar.Charts">
|
||||||
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.DotNetBar.Charts.dll</HintPath>
|
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.DotNetBar.Charts.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="DevComponents.DotNetBar.Design">
|
||||||
|
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.DotNetBar.Design.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="DevComponents.DotNetBar.Keyboard">
|
<Reference Include="DevComponents.DotNetBar.Keyboard">
|
||||||
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.DotNetBar.Keyboard.dll</HintPath>
|
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.DotNetBar.Keyboard.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="DevComponents.DotNetBar.Layout">
|
<Reference Include="DevComponents.DotNetBar.Layout">
|
||||||
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.DotNetBar.Layout.dll</HintPath>
|
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.DotNetBar.Layout.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="DevComponents.DotNetBar.Layout.Design">
|
||||||
|
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.DotNetBar.Layout.Design.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="DevComponents.DotNetBar.Schedule">
|
<Reference Include="DevComponents.DotNetBar.Schedule">
|
||||||
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.DotNetBar.Schedule.dll</HintPath>
|
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.DotNetBar.Schedule.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@@ -38,6 +45,12 @@
|
|||||||
<Reference Include="DevComponents.Instrumentation">
|
<Reference Include="DevComponents.Instrumentation">
|
||||||
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.Instrumentation.dll</HintPath>
|
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.Instrumentation.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="DevComponents.Instrumentation.Design">
|
||||||
|
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.Instrumentation.Design.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="DevComponents.SuperGrid.Design">
|
||||||
|
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.SuperGrid.Design.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="DevComponents.TreeGX">
|
<Reference Include="DevComponents.TreeGX">
|
||||||
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.TreeGX.dll</HintPath>
|
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.TreeGX.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|||||||
Reference in New Issue
Block a user