public Task Track() { return(this.googleAnalyticsService.TrackAppScreenAsync("DynamicTranslator", ApplicationVersion.GetCurrentVersion(), "dynamictranslator", "dynamictranslator", "MainWindow")); }
async Task Trace(string currentString, string fromLanguageExtension) { await this.googleAnalytics.TrackEventAsync("DynamicTranslator", "Translate", $"{currentString} | {fromLanguageExtension} - {this.applicationConfiguration.ToLanguage.Extension} | v{ApplicationVersion.GetCurrentVersion()} ", null); await this.googleAnalytics.TrackAppScreenAsync("DynamicTranslator", ApplicationVersion.GetCurrentVersion(), "dynamictranslator", "dynamictranslator", "notification"); }
public WireUp( Action <IConfigurationBuilder> configure = null, Action <IServiceCollection> postConfigureServices = null) { IConfigurationBuilder cb = new ConfigurationBuilder() .AddIniFile("DynamicTranslator.ini", configure != null, false); configure?.Invoke(cb); IConfigurationRoot configuration = cb.Build(); var services = new ServiceCollection(); services .AddGoogleTranslator(google => { google.SupportedLanguages = LanguageMapping.All.ToLanguages(); google.Url = GoogleTranslator.Url; }) .AddPromptTranslator(prompt => { prompt.Url = PromptTranslator.Url; prompt.Limit = PromptTranslator.CharacterLimit; prompt.Template = PromptTranslator.Template; prompt.Ts = PromptTranslator.Ts; prompt.SupportedLanguages = LanguageMapping.Prompt.ToLanguages(); }) .AddSesliSozlukTranslator(sesliSozluk => { sesliSozluk.SupportedLanguages = LanguageMapping.SesliSozluk.ToLanguages(); sesliSozluk.Url = "https://www.seslisozluk.net/c%C3%BCmle-%C3%A7eviri/"; }) .AddTurengTranslator(tureng => { tureng.SupportedLanguages = LanguageMapping.Tureng.ToLanguages(); tureng.Url = "https://tureng.com/en/turkish-english/"; }) .AddSingleton(configuration) .AddSingleton <ActiveTranslatorConfiguration>() .AddSingleton <IApplicationConfiguration>(sp => { var clientConfiguration = new ClientConfiguration { AppVersion = ApplicationVersion.GetCurrentVersion(), Id = string.IsNullOrEmpty(configuration["ClientId"]) ? GenerateUniqueClientId() : configuration["ClientId"], MachineName = Environment.MachineName.Normalize() }; string existingToLanguage = configuration["ToLanguage"]; string existingFromLanguage = configuration["FromLanguage"]; return(new ApplicationConfiguration { IsLanguageDetectionEnabled = true, IsExtraLoggingEnabled = true, LeftOffset = 500, TopOffset = 15, SearchableCharacterLimit = int.Parse(configuration["CharacterLimit"] ?? "300"), MaxNotifications = 4, ToLanguage = new Language(existingToLanguage, LanguageMapping.All[existingToLanguage]), FromLanguage = new Language(existingFromLanguage, LanguageMapping.All[existingFromLanguage]), ClientConfiguration = clientConfiguration }); }) .AddTransient <IGoogleAnalyticsTracker, GoogleAnalyticsTracker>() .AddTransient <IGoogleLanguageDetector, GoogleLanguageDetector>() .AddTransient <IGoogleAnalyticsService, GoogleAnalyticsService>() .AddTransient <IFinder, Finder>() .AddSingleton(new CookieContainer()) .AddSingleton <ResultOrganizer>() .AddHttpClient <TranslatorClient>(TranslatorClient.Name) .SetHandlerLifetime(TimeSpan.FromMinutes(5)) .ConfigurePrimaryHttpMessageHandler(sp => MessageHandler); postConfigureServices?.Invoke(services); ServiceProvider = services.BuildServiceProvider(); }