Skip to content

Commit a6f8671

Browse files
authored
Merge pull request #9 from bastianeicher/main
Add support for additional context
2 parents 0d5b238 + 9db5bd2 commit a6f8671

5 files changed

Lines changed: 22 additions & 4 deletions

File tree

Action/ActionInputs.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ public class ActionInputs : IActionInputs
3434
Default = "",
3535
HelpText = "The name of the glossary to use for translation. Only works if source-lang is also set.")]
3636
public string GlossaryName { get; set; } = "";
37+
38+
[Option(
39+
't',
40+
"context",
41+
Required = false,
42+
Default = "",
43+
HelpText = "Free-form text to provide additional context for the contents of the ResX files.")]
44+
public string Context { get; set; } = "";
3745

3846
[Option(
3947
'e',

Main/IActionInputs.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public interface IActionInputs
66
string AuthKey { get; }
77
string SourceLang { get; }
88
string GlossaryName { get; }
9+
string Context { get; }
910
string ExcludesRegex { get; }
1011
string DataCopiesRegex { get; }
1112
bool TakeOverridesKeysSuperSetAsKeyFilter { get; }

Main/Main.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="DeepL.net" Version="1.5.0" />
14-
<PackageReference Include="morelinq" Version="3.3.2" />
15-
<PackageReference Include="System.Reactive" Version="5.0.0" />
13+
<PackageReference Include="DeepL.net" Version="1.8.0" />
14+
<PackageReference Include="morelinq" Version="4.1.0" />
15+
<PackageReference Include="System.Reactive" Version="6.0.0" />
1616
</ItemGroup>
1717

1818
</Project>

Main/Translation/DeepLTranslator.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ internal class DeepLTranslator : IDeepLTranslator, IContainerInstance
2121
private IImmutableSet<CultureInfo>? _cachedSupportedCultureInfos;
2222
private string? _sourceLanguage;
2323
private string? _glossaryName;
24+
private string? _context;
2425

2526
public DeepLTranslator(
2627
IActionInputs actionInputs,
@@ -31,6 +32,7 @@ public DeepLTranslator(
3132
_deepLClient = deepLClientFactory(actionInputs.AuthKey);
3233
_sourceLanguage = string.IsNullOrEmpty(actionInputs.SourceLang) ? null : actionInputs.SourceLang;
3334
_glossaryName = string.IsNullOrEmpty(actionInputs.GlossaryName) ? null : actionInputs.GlossaryName;
35+
_context = string.IsNullOrEmpty(actionInputs.Context) ? null : actionInputs.Context;
3436
}
3537

3638
public bool TranslationsShouldBeCached => true;
@@ -90,7 +92,8 @@ public async Task<string[]> Translate(
9092
PreserveFormatting = true,
9193
TagHandling = "xml",
9294
IgnoreTags = { "placeholder" },
93-
GlossaryId = glossary?.GlossaryId
95+
GlossaryId = glossary?.GlossaryId,
96+
Context = _context
9497
}
9598
);
9699

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ inputs:
1919
description: 'The name of the glossary to use for translation. Only works if source-lang is also set.'
2020
required: false
2121
default: ''
22+
context:
23+
description: 'Free-form text to provide additional context for the contents of the ResX files.'
24+
required: false
25+
default: ''
2226
excludes-regex:
2327
description: 'Regex for names of default ResX files in order to decide whether to exclude file from processing.'
2428
required: false
@@ -56,6 +60,8 @@ runs:
5660
- ${{ inputs.source-lang }}
5761
- '-g'
5862
- ${{ inputs.glossary-name }}
63+
- '-t'
64+
- ${{ inputs.context }}
5965
- '-e'
6066
- ${{ inputs.excludes-regex }}
6167
- '-c'

0 commit comments

Comments
 (0)