Skip to content

Commit d9d4df8

Browse files
committed
Update to .Net 6.0 & C# 10 and implementing issue #2 (filtering supported languages)
1 parent e47f295 commit d9d4df8

24 files changed

Lines changed: 770 additions & 682 deletions

Action/Action.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net5.0</TargetFramework>
5+
<TargetFramework>net6.0</TargetFramework>
66
<RootNamespace>MrMeeseeks.ResXTranslationCombinator.Action</RootNamespace>
77
<AssemblyName>MrMeeseeks.ResXTranslationCombinator.Action</AssemblyName>
8-
<LangVersion>9.0</LangVersion>
8+
<LangVersion>10</LangVersion>
99
<Nullable>enable</Nullable>
1010
<WarningsAsErrors>nullable</WarningsAsErrors>
1111
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>

Action/ActionInputs.cs

Lines changed: 56 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,64 @@
11
using CommandLine;
22

3-
namespace MrMeeseeks.ResXTranslationCombinator.Action
3+
namespace MrMeeseeks.ResXTranslationCombinator.Action;
4+
5+
public class ActionInputs : IActionInputs
46
{
5-
public class ActionInputs : IActionInputs
6-
{
7-
[Option(
8-
'd',
9-
"dir",
10-
Required = false,
11-
Default = ".",
12-
HelpText = "The root directory to start recursive searching from.")]
13-
public string Directory { get; set; } = ".";
7+
[Option(
8+
'd',
9+
"dir",
10+
Required = false,
11+
Default = ".",
12+
HelpText = "The root directory to start recursive searching from.")]
13+
public string Directory { get; set; } = ".";
1414

15-
[Option(
16-
'a',
17-
"auth",
18-
Required = true,
19-
HelpText = "Auth key for your DeepL API access.")]
20-
public string AuthKey { get; set; } = "";
15+
[Option(
16+
'a',
17+
"auth",
18+
Required = true,
19+
HelpText = "Auth key for your DeepL API access.")]
20+
public string AuthKey { get; set; } = "";
2121

22-
[Option(
23-
'e',
24-
"excludes-regex",
25-
Required = false,
26-
Default = "",
27-
HelpText = "Regex for names of default ResX files in order to decide whether to exclude file from processing.")]
28-
public string ExcludesRegex { get; set; } = "";
22+
[Option(
23+
'e',
24+
"excludes-regex",
25+
Required = false,
26+
Default = "",
27+
HelpText = "Regex for names of default ResX files in order to decide whether to exclude file from processing.")]
28+
public string ExcludesRegex { get; set; } = "";
2929

30-
[Option(
31-
'c',
32-
"data-copies-regex",
33-
Required = false,
34-
Default = "",
35-
HelpText = "Regex for names of default ResX files whose data should be copied instead of translated.")]
36-
public string DataCopiesRegex { get; set; } = "";
30+
[Option(
31+
'c',
32+
"data-copies-regex",
33+
Required = false,
34+
Default = "",
35+
HelpText = "Regex for names of default ResX files whose data should be copied instead of translated.")]
36+
public string DataCopiesRegex { get; set; } = "";
3737

38-
[Option(
39-
'f',
40-
"filter-keys-with-overrides",
41-
Required = false,
42-
Default = false,
43-
HelpText = "If set the default keys are filtered by the super set of override keys per ResX file family.")]
44-
public bool TakeOverridesKeysSuperSetAsKeyFilter { get; set; }
38+
[Option(
39+
'f',
40+
"filter-keys-with-overrides",
41+
Required = false,
42+
Default = false,
43+
HelpText = "If set the default keys are filtered by the super set of override keys per ResX file family.")]
44+
public bool TakeOverridesKeysSuperSetAsKeyFilter { get; set; }
45+
46+
[Option(
47+
'l',
48+
"localizations-filter",
49+
Required = false,
50+
Default = "",
51+
HelpText = "Concat CultureInfo-/language-codes joined with ';' in order to filter supported languages from the translation provider. Not usable in combination with localizations-excludes.")]
52+
public string LocalizationFilter { get; set; } = "";
53+
54+
[Option(
55+
'x',
56+
"localizations-excludes",
57+
Required = false,
58+
Default = "",
59+
HelpText = "Concat CultureInfo-/language-codes joined with ';' in order to exclude supported languages from the translation provider. Not usable in combination with localizations-filter.")]
60+
public string LocalizationExcludes { get; set; } = "";
4561

46-
public override string ToString() =>
47-
$"{nameof(Directory)}: {Directory}, {nameof(ExcludesRegex)}: {ExcludesRegex}, {nameof(DataCopiesRegex)}: {DataCopiesRegex}, {nameof(TakeOverridesKeysSuperSetAsKeyFilter)}: {TakeOverridesKeysSuperSetAsKeyFilter}";
48-
}
49-
}
62+
public override string ToString() =>
63+
$"{nameof(Directory)}: {Directory}, {nameof(AuthKey)}: {AuthKey}, {nameof(ExcludesRegex)}: {ExcludesRegex}, {nameof(DataCopiesRegex)}: {DataCopiesRegex}, {nameof(TakeOverridesKeysSuperSetAsKeyFilter)}: {TakeOverridesKeysSuperSetAsKeyFilter}, {nameof(LocalizationFilter)}: {LocalizationFilter}, {nameof(LocalizationExcludes)}: {LocalizationExcludes}";
64+
}

Action/AssemblyInfo.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
global using System;
2+
3+
using System.Runtime.CompilerServices;
4+
5+
[assembly:InternalsVisibleTo("MrMeeseeks.ResXTranslationCombinator.Action")]

Action/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Threading.Tasks;
1+
using System.Threading.Tasks;
32
using CommandLine;
43
using MrMeeseeks.ResXTranslationCombinator.Action;
54
using StrongInject;

Action/StrongInjectContainer.cs

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,40 @@
77
using StrongInject;
88
using StrongInject.Modules;
99

10-
namespace MrMeeseeks.ResXTranslationCombinator.Action
11-
{
12-
[Register(typeof(DeepLContext), typeof(IContext))]
13-
[Register(typeof(ResXCombinator<>), typeof(IResXCombinator<>))]
14-
[Register(typeof(CopyTranslator), Scope.SingleInstance, typeof(ICopyTranslator))]
15-
[Register(typeof(DeepLTranslator), Scope.SingleInstance, typeof(IDeepLTranslator))]
16-
[Register(typeof(DataMappingFactory), typeof(IDataMappingFactory))]
17-
[Register(typeof(DataMapping), typeof(IDataMapping))]
10+
namespace MrMeeseeks.ResXTranslationCombinator.Action;
11+
12+
[Register(typeof(DeepLContext), typeof(IContext))]
13+
[Register(typeof(ResXCombinator<>), typeof(IResXCombinator<>))]
14+
[Register(typeof(CopyTranslator), Scope.SingleInstance, typeof(ICopyTranslator))]
15+
[Register(typeof(DeepLTranslator), Scope.SingleInstance, typeof(IDeepLTranslator))]
16+
[Register(typeof(DataMappingFactory), typeof(IDataMappingFactory))]
17+
[Register(typeof(DataMapping), typeof(IDataMapping))]
1818

19-
[Register(typeof(ResXNode), typeof(IResXNode))]
20-
[Register(typeof(ResXReader), typeof(IResXReader))]
21-
[Register(typeof(ResXWriter), typeof(IResXWriter))]
22-
[Register(typeof(ResXWriterFactory), typeof(IResXWriterFactory))]
23-
[Register(typeof(ResXElementsFactory), typeof(IResXElementsFactory))]
19+
[Register(typeof(ResXNode), typeof(IResXNode))]
20+
[Register(typeof(ResXReader), typeof(IResXReader))]
21+
[Register(typeof(ResXWriter), typeof(IResXWriter))]
22+
[Register(typeof(ResXWriterFactory), typeof(IResXWriterFactory))]
23+
[Register(typeof(ResXElementsFactory), typeof(IResXElementsFactory))]
2424

25-
[Register(typeof(Logger), typeof(ILogger))]
25+
[Register(typeof(Logger), typeof(ILogger))]
2626

27-
[Register(typeof(Translator))]
28-
[Register(typeof(FileInfo))]
29-
[Register(typeof(DirectoryInfo))]
27+
[Register(typeof(Translator))]
28+
[Register(typeof(FileInfo))]
29+
[Register(typeof(DirectoryInfo))]
30+
31+
[Register(typeof(IntersectingCultureInfosFilter), typeof(IIntersectingCultureInfosFilter))]
32+
[Register(typeof(ExcludingCultureInfosFilter), typeof(IExcludingCultureInfosFilter))]
33+
[Register(typeof(NonChangingCultureInfosFilter), typeof(INonChangingCultureInfosFilter))]
34+
[Register(typeof(CreateCultureInfosFilter), typeof(ICreateCultureInfosFilter))]
3035

31-
[RegisterModule(typeof(StandardModule))]
32-
internal partial class StrongInjectContainer : IAsyncContainer<IContext>
33-
{
34-
[Instance] private IActionInputs ActionInputs { get; }
36+
[RegisterModule(typeof(StandardModule))]
37+
internal partial class StrongInjectContainer : IAsyncContainer<IContext>
38+
{
39+
[Instance] private IActionInputs ActionInputs { get; }
3540

36-
[Factory] private Regex CreateRegex(string pattern) => new (pattern);
41+
[Factory] private Regex CreateRegex(string pattern) => new (pattern);
3742

38-
public StrongInjectContainer(
39-
IActionInputs actionInputs) =>
40-
ActionInputs = actionInputs;
41-
}
43+
public StrongInjectContainer(
44+
IActionInputs actionInputs) =>
45+
ActionInputs = actionInputs;
4246
}

Main/AssemblyInfo.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
global using System;
2+
global using System.Collections;
3+
global using System.Collections.Generic;
4+
global using System.Collections.Immutable;
5+
global using System.Linq;
6+
17
using System.Runtime.CompilerServices;
28

39
[assembly:InternalsVisibleTo("MrMeeseeks.ResXTranslationCombinator.Action")]

Main/IActionInputs.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
namespace MrMeeseeks.ResXTranslationCombinator
1+
namespace MrMeeseeks.ResXTranslationCombinator;
2+
3+
public interface IActionInputs
24
{
3-
public interface IActionInputs
4-
{
5-
string Directory { get; }
6-
string AuthKey { get; }
7-
string ExcludesRegex { get; }
8-
string DataCopiesRegex { get; }
9-
bool TakeOverridesKeysSuperSetAsKeyFilter { get; }
10-
}
5+
string Directory { get; }
6+
string AuthKey { get; }
7+
string ExcludesRegex { get; }
8+
string DataCopiesRegex { get; }
9+
bool TakeOverridesKeysSuperSetAsKeyFilter { get; }
10+
string LocalizationFilter { get; }
11+
string LocalizationExcludes { get; }
1112
}

Main/Main.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<WarningsAsErrors>nullable</WarningsAsErrors>
77
<RootNamespace>MrMeeseeks.ResXTranslationCombinator</RootNamespace>
88
<AssemblyName>MrMeeseeks.ResXTranslationCombinator</AssemblyName>
9+
<LangVersion>10</LangVersion>
910
</PropertyGroup>
1011

1112
<ItemGroup>

Main/ResX/ResXElementsFactory.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
using System.Xml.Linq;
22

3-
namespace MrMeeseeks.ResXTranslationCombinator.ResX
3+
namespace MrMeeseeks.ResXTranslationCombinator.ResX;
4+
5+
public interface IResXElementsFactory
46
{
5-
public interface IResXElementsFactory
6-
{
7-
XElement CreateNewRoot();
8-
XElement CreateNewDataElement();
9-
}
7+
XElement CreateNewRoot();
8+
XElement CreateNewDataElement();
9+
}
1010

11-
internal class ResXElementsFactory : IResXElementsFactory
12-
{
13-
private readonly XElement _rootTemplate;
14-
private readonly XElement _dataTemplate;
11+
internal class ResXElementsFactory : IResXElementsFactory
12+
{
13+
private readonly XElement _rootTemplate;
14+
private readonly XElement _dataTemplate;
1515

16-
public ResXElementsFactory(
17-
(XElement RootTemplate, XElement DataTemplate) tuple) =>
18-
(_rootTemplate, _dataTemplate) = tuple;
16+
public ResXElementsFactory(
17+
(XElement RootTemplate, XElement DataTemplate) tuple) =>
18+
(_rootTemplate, _dataTemplate) = tuple;
1919

20-
public XElement CreateNewRoot() => new(_rootTemplate);
20+
public XElement CreateNewRoot() => new(_rootTemplate);
2121

22-
public XElement CreateNewDataElement() => new(_dataTemplate);
23-
}
22+
public XElement CreateNewDataElement() => new(_dataTemplate);
2423
}

Main/ResX/ResXNode.cs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
namespace MrMeeseeks.ResXTranslationCombinator.ResX
1+
namespace MrMeeseeks.ResXTranslationCombinator.ResX;
2+
3+
public interface IResXNode
24
{
3-
public interface IResXNode
4-
{
5-
string Name { get; }
6-
string Value { get; }
7-
string Comment { get; }
8-
}
5+
string Name { get; }
6+
string Value { get; }
7+
string Comment { get; }
8+
}
99

10-
internal record ResXNode : IResXNode
11-
{
12-
public ResXNode((string Name, string Value, string Comment) tuple) => (Name, Value, Comment) = tuple;
10+
internal record ResXNode : IResXNode
11+
{
12+
public ResXNode((string Name, string Value, string Comment) tuple) => (Name, Value, Comment) = tuple;
1313

14-
public string Name { get; }
15-
public string Value { get; }
16-
public string Comment { get; }
17-
};
18-
}
14+
public string Name { get; }
15+
public string Value { get; }
16+
public string Comment { get; }
17+
};

0 commit comments

Comments
 (0)