A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/signumsoftware/framework/commit/b33e499e50fc855d2bd044c65361b13bfbbf257e below:

add Upgrade_20210119_DeepL · signumsoftware/framework@b33e499 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+93

-0

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+93

-0

lines changed Original file line number Diff line number Diff line change

@@ -44,6 +44,7 @@ static void Main(string[] args)

44 44

new Upgrade_20201231_AnyCPU(),

45 45

new Upgrade_20210108_RemoveLangVersion(),

46 46

new Upgrade_20210113_TimezoneInDockerfile(),

47 +

new Upgrade_20210119_DeepL(),

47 48

}.Run(uctx);

48 49

}

49 50

}

Original file line number Diff line number Diff line change

@@ -0,0 +1,92 @@

1 +

using Signum.Utilities;

2 +

using System;

3 +

using System.Collections.Generic;

4 +

using System.IO;

5 +

using System.Linq;

6 +

using System.Security.Cryptography.X509Certificates;

7 +

using System.Text;

8 +

using System.Threading.Tasks;

9 + 10 +

namespace Signum.Upgrade.Upgrades

11 +

{

12 +

class Upgrade_20210119_DeepL : CodeUpgradeBase

13 +

{

14 +

public override string Description => "Add DeepL support and parallel translations";

15 + 16 +

public override void Execute(UpgradeContext uctx)

17 +

{

18 +

uctx.ChangeCodeFile(@"Southwind.Entities/ApplicationConfiguration.cs ", file =>

19 +

{

20 +

file.InsertBeforeFirstLine(a => a.Contains("[AutoInit]"),

21 +

@"

22 +

[Serializable]

23 +

public class TranslationConfigurationEmbedded : EmbeddedEntity

24 +

{

25 +

[Description(""Azure Cognitive Service API Key"")]

26 +

[StringLengthValidator(Max = 300), FileNameValidator]

27 +

public string? AzureCognitiveServicesAPIKey { get; set; }

28 + 29 +

[Description(""Azure Cognitive Service Region"")]

30 +

[StringLengthValidator(Max = 300), FileNameValidator]

31 +

public string? AzureCognitiveServicesRegion { get; set; }

32 + 33 +

[Description(""DeepL API Key"")]

34 +

[StringLengthValidator(Max = 300), FileNameValidator]

35 +

public string? DeepLAPIKey { get; set; }

36 +

}

37 + 38 +

");

39 + 40 +

file.InsertAfterFirstLine(a => a.Contains("public FoldersConfigurationEmbedded Folders { get; set; }"),

41 +

@"

42 +

public TranslationConfigurationEmbedded Translation { get; set; }");

43 +

});

44 + 45 +

uctx.ChangeCodeFile(@"Southwind.React/App/Agile360/Templates/ApplicationConfiguration.tsx", file =>

46 +

{

47 +

file.InsertAfterLastLine(a => a.Contains("</Tab>"),

48 +

@"<Tab eventKey=""translation"" title={ctx.niceName(a => a.translation)}>

49 +

<RenderEntity ctx={ctx.subCtx(a => a.translation)} />

50 +

</Tab>");

51 + 52 +

});

53 + 54 +

uctx.ChangeCodeFile(@"Southwind.React/Startup.cs", file =>

55 +

{

56 +

file.ReplaceLine(a => a.Contains("TranslationServer.Start(app, new AlreadyTranslatedTranslator"),

57 +

@"TranslationServer.Start(app,

58 +

new AlreadyTranslatedTranslator(),

59 +

new AzureTranslator(

60 +

() => Starter.Configuration.Value.Translation.AzureCognitiveServicesAPIKey,

61 +

() => Starter.Configuration.Value.Translation.AzureCognitiveServicesRegion),

62 +

new DeepLTranslator(() => Starter.Configuration.Value.Translation.DeepLAPIKey)

63 +

);");

64 + 65 +

});

66 + 67 +

var azureKey = SafeConsole.AskString("Azure API Key?");

68 +

var deeplKey = SafeConsole.AskString("DeepL API Key?");

69 + 70 +

uctx.ChangeCodeFile(@"Southwind.Terminal\SouthwindMigrations.cs", file =>

71 +

{

72 +

file.InsertBeforeFirstLine(a => a.Contains("Folders = new FoldersConfigurationEmbedded"),

73 +

@$"Translation = new TranslationConfigurationEmbedded

74 +

{{

75 +

AzureCognitiveServicesAPIKey = ""{azureKey}"",

76 +

DeepLAPIKey = ""{deeplKey}"",

77 +

}},");

78 +

});

79 + 80 +

uctx.ChangeCodeFile(@"Southwind.Test.Environment/BasicLoader.cs", file =>

81 +

{

82 +

file.InsertBeforeFirstLine(a => a.Contains("Folders = new FoldersConfigurationEmbedded"),

83 +

@$"Translation = new TranslationConfigurationEmbedded

84 +

{{

85 +

AzureCognitiveServicesAPIKey = ""{azureKey}"",

86 +

DeepLAPIKey = ""{deeplKey}"",

87 +

}},");

88 + 89 +

});

90 +

}

91 +

}

92 +

}

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4