Add LangResCollector
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.32002.261
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.2.32602.215
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SM64 ROM Manager.ProgressUpdater", "SM64 ROM Manager.ProgressUpdater\SM64 ROM Manager.ProgressUpdater.csproj", "{E2B5326E-FF5F-4521-BD8A-0A8DA5A6671E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SM64 ROM Manager.UpdateInstallerAddOn", "SM64 ROM Manager.UpdateInstallerAddOn\SM64 ROM Manager.UpdateInstallerAddOn.csproj", "{C702C309-65C1-4FE4-B468-035ADC31FDEF}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SM64 ROM Manager.LangResCollector", "SM64 ROM Manager.LangResCollector\SM64 ROM Manager.LangResCollector.csproj", "{BE9DA0F8-654E-4035-A71B-7A04E009BE46}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -21,6 +23,10 @@ Global
|
||||
{C702C309-65C1-4FE4-B468-035ADC31FDEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C702C309-65C1-4FE4-B468-035ADC31FDEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C702C309-65C1-4FE4-B468-035ADC31FDEF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BE9DA0F8-654E-4035-A71B-7A04E009BE46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BE9DA0F8-654E-4035-A71B-7A04E009BE46}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BE9DA0F8-654E-4035-A71B-7A04E009BE46}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BE9DA0F8-654E-4035-A71B-7A04E009BE46}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
124
SM64 ROM Manager.LangResCollector/Program.cs
Normal file
124
SM64 ROM Manager.LangResCollector/Program.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
using Microsoft.VisualBasic;
|
||||
using static Microsoft.VisualBasic.CompilerServices.LikeOperator;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Resources;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||
|
||||
namespace SM64_ROM_Manager_LangRes_Collector
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var resFiles = new List<string>();
|
||||
var ofd = new CommonOpenFileDialog { IsFolderPicker = true };
|
||||
string rootPath, outputPath;
|
||||
var fileNameBlackList = new string[]
|
||||
{
|
||||
"Resources.resx",
|
||||
"My*Icons.resx",
|
||||
"*.de.resx",
|
||||
"ReflectionSymbols.resx",
|
||||
"UpdatingAdministrationLangRes"
|
||||
};
|
||||
var fileNameWhiteList = new string[]
|
||||
{
|
||||
"*.resx"
|
||||
};
|
||||
var blackListPropNames = new string[]
|
||||
{
|
||||
">>*",
|
||||
"*.AccessibleName",
|
||||
"*.AccessibleDescription"
|
||||
};
|
||||
|
||||
// Get root path
|
||||
ofd.Title = "Root (repository) directory";
|
||||
if (ofd.ShowDialog() == CommonFileDialogResult.Ok)
|
||||
rootPath = ofd.FileName;
|
||||
else
|
||||
return;
|
||||
|
||||
// Get output path
|
||||
ofd.Title = "Output directory";
|
||||
if (ofd.ShowDialog() == CommonFileDialogResult.Ok)
|
||||
outputPath = ofd.FileName;
|
||||
else
|
||||
return;
|
||||
|
||||
// Collect files
|
||||
if (Directory.Exists(rootPath))
|
||||
{
|
||||
foreach (var filePath in Directory.GetFiles(rootPath, "*.resx", SearchOption.AllDirectories))
|
||||
{
|
||||
var fileName = Path.GetFileName(filePath);
|
||||
var copyFile = true;
|
||||
|
||||
foreach (var blackFileName in fileNameBlackList)
|
||||
{
|
||||
if (copyFile && LikeString(fileName, blackFileName, CompareMethod.Binary))
|
||||
copyFile = false;
|
||||
}
|
||||
|
||||
foreach (var whiteFileName in fileNameWhiteList)
|
||||
{
|
||||
if (copyFile && !LikeString(fileName, whiteFileName, CompareMethod.Binary))
|
||||
copyFile = false;
|
||||
}
|
||||
|
||||
if (copyFile)
|
||||
resFiles.Add(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
// Create output path if not exists
|
||||
Directory.CreateDirectory(outputPath);
|
||||
|
||||
// Copy and prepair files
|
||||
foreach (var resFileInput in resFiles)
|
||||
{
|
||||
var resReader = new ResXResourceReader(resFileInput);
|
||||
var propsToCopy = new Dictionary<string, string>();
|
||||
|
||||
// Collect input properties
|
||||
foreach (DictionaryEntry kvp in resReader)
|
||||
{
|
||||
var propName = (string)kvp.Key;
|
||||
var useProp = true;
|
||||
|
||||
foreach (var blackPropName in blackListPropNames)
|
||||
{
|
||||
if (useProp && LikeString(propName, blackPropName, CompareMethod.Binary))
|
||||
useProp = false;
|
||||
}
|
||||
|
||||
if (useProp && kvp.Value is string)
|
||||
{
|
||||
var val = (string)kvp.Value;
|
||||
|
||||
if (!string.IsNullOrEmpty(val))
|
||||
propsToCopy.Add(propName, (string)kvp.Value);
|
||||
}
|
||||
}
|
||||
|
||||
resReader.Close();
|
||||
|
||||
// Write output ResX file
|
||||
if (propsToCopy.Any())
|
||||
{
|
||||
var resFileOutput = Path.Combine(outputPath, Path.GetFileName(resFileInput));
|
||||
var resWriter = new ResXResourceWriter(resFileOutput);
|
||||
|
||||
foreach (var kvp in propsToCopy)
|
||||
resWriter.AddResource(kvp.Key, kvp.Value);
|
||||
|
||||
resWriter.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0-windows7</TargetFramework>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<RootNamespace>SM64_ROM_Manager_LangRes_Collector</RootNamespace>
|
||||
<StartupObject>SM64_ROM_Manager_LangRes_Collector.Program</StartupObject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FastColoredTextBox-net5" Version="2.17.30.100" />
|
||||
<PackageReference Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="DevComponents.Charts.Design">
|
||||
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.Charts.Design.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DevComponents.DotNetBar.Charts">
|
||||
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.DotNetBar.Charts.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DevComponents.DotNetBar.Keyboard">
|
||||
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.DotNetBar.Keyboard.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DevComponents.DotNetBar.Layout">
|
||||
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.DotNetBar.Layout.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DevComponents.DotNetBar.Schedule">
|
||||
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.DotNetBar.Schedule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DevComponents.DotNetBar.SuperGrid">
|
||||
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.DotNetBar.SuperGrid.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DevComponents.DotNetBar2">
|
||||
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.DotNetBar2.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DevComponents.Instrumentation">
|
||||
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.Instrumentation.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DevComponents.TreeGX">
|
||||
<HintPath>..\Shared Libs\DotNetBarNew\DevComponents.TreeGX.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user