-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor option handling, configure now deparate in and output dir an…
…d files
- Loading branch information
1 parent
ebe81b6
commit 9ceff4c
Showing
9 changed files
with
139 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
tools/NetDeepL.TranslationWorker/Abstractions/IConfigFileProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
tools/NetDeepL.TranslationWorker/Models/Config/ConfigFile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using NetDeepL.Models; | ||
|
||
namespace NetDeepL.TranslationWorker.Models.Config | ||
{ | ||
public class ConfigFile | ||
{ | ||
public ConfigFile() | ||
{ | ||
|
||
} | ||
|
||
public ConfigFile(ConfigFileRaw raw) | ||
{ | ||
DeepLApiKey = raw.DeepLApiKey; | ||
LanguagesToTranslate = raw.LanguagesToTranslate.Split(',', System.StringSplitOptions.RemoveEmptyEntries) | ||
.Select(x => Enum.Parse<Languages>(x)).ToArray(); | ||
SourceLanguage = Enum.Parse<Languages>(raw.SourceLanguage); | ||
DelayMilliseconds = int.Parse(raw.DelayMilliseconds); | ||
var currentDir = new DirectoryInfo(Directory.GetCurrentDirectory()); | ||
InputPath = string.IsNullOrWhiteSpace(raw.InputPath) ? currentDir : new DirectoryInfo(raw.InputPath); | ||
OutputPath = string.IsNullOrWhiteSpace(raw.OutputPath) ? currentDir : new DirectoryInfo(raw.OutputPath); | ||
} | ||
|
||
public string DeepLApiKey { get; } | ||
public Languages[] LanguagesToTranslate { get; } | ||
public Languages SourceLanguage { get; } | ||
public int DelayMilliseconds { get; } | ||
public DirectoryInfo InputPath { get; } | ||
public DirectoryInfo OutputPath { get; } | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
tools/NetDeepL.TranslationWorker/Models/Config/ConfigFileRaw.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
using System; | ||
using System.IO; | ||
|
||
namespace NetDeepL.TranslationWorker.Models.Config | ||
{ | ||
public class ConfigFileRaw | ||
{ | ||
public ConfigFileRaw() | ||
{ | ||
var currentDir = Directory.GetCurrentDirectory(); | ||
OutputPath = $"{currentDir}\\output"; | ||
InputPath = $"{currentDir}\\input"; | ||
} | ||
|
||
public string DeepLApiKey { get; set; } = Guid.Empty.ToString(); | ||
public string LanguagesToTranslate { get; set; } = "EN,DE,FR,ES,PT,IT,NL,PL,RU # multiple possible"; | ||
public string SourceLanguage { get; set; } = "EN,DE,FR,ES,PT,IT,NL,PL,RU # only select one language"; | ||
public string DelayMilliseconds { get; set; } = "500 # 1 second = 1000 millisecond, if this value is too low DeepL could response with code 429"; | ||
public string InputPath { get; set; } | ||
public string OutputPath { get; set; } | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
tools/NetDeepL.TranslationWorker/NetDeepL.TranslationWorker.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters