Browse Source

Deepl auth key fixed.

pull/462/head
Sebastian 6 years ago
parent
commit
62957c84d2
  1. 12
      backend/src/Squidex.Infrastructure/Translations/DeepLTranslator.cs
  2. 4
      backend/src/Squidex/appsettings.json

12
backend/src/Squidex.Infrastructure/Translations/DeepLTranslator.cs

@ -23,7 +23,7 @@ namespace Squidex.Infrastructure.Translations
{ {
private const string Url = "https://api.deepl.com/v2/translate"; private const string Url = "https://api.deepl.com/v2/translate";
private readonly HttpClient httpClient = new HttpClient(); private readonly HttpClient httpClient = new HttpClient();
private readonly DeepLTranslatorOptions deepLOptions; private readonly DeepLTranslatorOptions deeplOptions;
private readonly IJsonSerializer jsonSerializer; private readonly IJsonSerializer jsonSerializer;
private sealed class Response private sealed class Response
@ -36,12 +36,12 @@ namespace Squidex.Infrastructure.Translations
public string Text { get; set; } public string Text { get; set; }
} }
public DeepLTranslator(IOptions<DeepLTranslatorOptions> deepLOptions, IJsonSerializer jsonSerializer) public DeepLTranslator(IOptions<DeepLTranslatorOptions> deeplOptions, IJsonSerializer jsonSerializer)
{ {
Guard.NotNull(deepLOptions); Guard.NotNull(deeplOptions);
Guard.NotNull(jsonSerializer); Guard.NotNull(jsonSerializer);
this.deepLOptions = deepLOptions.Value; this.deeplOptions = deeplOptions.Value;
this.jsonSerializer = jsonSerializer; this.jsonSerializer = jsonSerializer;
} }
@ -53,14 +53,14 @@ namespace Squidex.Infrastructure.Translations
return new Translation(TranslationResult.NotTranslated, sourceText); return new Translation(TranslationResult.NotTranslated, sourceText);
} }
if (string.IsNullOrWhiteSpace(deepLOptions.AuthKey)) if (string.IsNullOrWhiteSpace(deeplOptions.AuthKey))
{ {
return new Translation(TranslationResult.NotImplemented); return new Translation(TranslationResult.NotImplemented);
} }
var parameters = new Dictionary<string, string> var parameters = new Dictionary<string, string>
{ {
["auth_key"] = deepLOptions.AuthKey, ["auth_key"] = deeplOptions.AuthKey,
["text"] = sourceText, ["text"] = sourceText,
["target_lang"] = GetLanguageCode(targetLanguage) ["target_lang"] = GetLanguageCode(targetLanguage)
}; };

4
backend/src/Squidex/appsettings.json

@ -534,7 +534,9 @@
/* /*
* The deepl api key if you want to support automated translations. * The deepl api key if you want to support automated translations.
*/ */
"deeplAuthKey": "" "deepl": {
"authKey": ""
}
}, },
"rebuild": { "rebuild": {

Loading…
Cancel
Save