Beispiel #1
0
        public override void Initialize(IInitializationContext context)
        {
            base.Initialize(context);

            MinDelay = context.GetOrCreateSetting("DeepL", "MinDelaySeconds", 2.0f);
            if (MinDelay < MinimumMinDelaySeconds)
            {
                XuaLogger.AutoTranslator.Warn($"[DeepL] Cannot set MinDelaySeconds below {MinimumMinDelaySeconds} second(s). Setting MinDelaySeconds={MinimumMinDelaySeconds}");
                context.SetSetting("DeepL", "MinDelaySeconds", MinimumMinDelaySeconds);
            }

            MaxDelay = context.GetOrCreateSetting("DeepL", "MaxDelaySeconds", 7.0f);
            if (MaxDelay < MinimumMaxDelaySeconds)
            {
                XuaLogger.AutoTranslator.Warn($"[DeepL] Cannot set MaxDelaySeconds below {MinimumMaxDelaySeconds} second(s). Setting MaxDelaySeconds={MinimumMaxDelaySeconds}");
                context.SetSetting("DeepL", "MaxDelaySeconds", MinimumMaxDelaySeconds);
            }

            if (!SupportedLanguages.Contains(FixLanguage(context.SourceLanguage)))
            {
                throw new EndpointInitializationException($"The source language '{context.SourceLanguage}' is not supported.");
            }
            if (!SupportedLanguages.Contains(FixLanguage(context.DestinationLanguage)))
            {
                throw new EndpointInitializationException($"The destination language '{context.DestinationLanguage}' is not supported.");
            }

            Arguments = Convert.ToBase64String(Encoding.UTF8.GetBytes("DeepLTranslate.ExtProtocol.ExtDeepLTranslate, DeepLTranslate.ExtProtocol"), Base64FormattingOptions.None);
        }
        public override void Initialize(IInitializationContext context)
        {
            var defaultPath = GetDefaultInstallationPath();
            var path        = context.GetOrCreateSetting("ezTrans", "InstallationPath", defaultPath);

            if (string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(defaultPath))
            {
                context.SetSetting("ezTrans", "InstallationPath", defaultPath);
                path = defaultPath;
            }

            //subprocess path
            var exePath = Path.Combine(context.TranslatorDirectory, @"FullNET\ezTransXP.ExtProtocol.exe");

            var fileExists = File.Exists(exePath);

            if (!fileExists)
            {
                throw new EndpointInitializationException($"Could not find any executable at '{exePath}'");
            }

            ExecutablePath = exePath;

            //argument is ezTrans installation path
            Arguments = Convert.ToBase64String(Encoding.UTF8.GetBytes(path));

            if (context.SourceLanguage != "ja")
            {
                throw new EndpointInitializationException("Current implementation only supports japanese-to-korean.");
            }
            if (context.DestinationLanguage != "ko")
            {
                throw new EndpointInitializationException("Current implementation only supports japanese-to-korean.");
            }
        }
        public override void Initialize(IInitializationContext context)
        {
            var defaultPath = GetDefaultInstallationPath();
            var pathToLec   = context.GetOrCreateSetting("LecPowerTranslator15", "InstallationPath", defaultPath);

            if (string.IsNullOrEmpty(pathToLec) && !string.IsNullOrEmpty(defaultPath))
            {
                context.SetSetting("LecPowerTranslator15", "InstallationPath", defaultPath);
                pathToLec = defaultPath;
            }

            if (string.IsNullOrEmpty(pathToLec))
            {
                throw new EndpointInitializationException("The LecPowerTranslator15 requires the path to the installation folder.");
            }

            context.DisableSpamChecks();

            var exePath = Path.Combine(context.TranslatorDirectory, Path.Combine("FullNET", "Lec.ExtProtocol.exe"));

            var fileExists = File.Exists(exePath);

            if (!fileExists)
            {
                throw new EndpointInitializationException($"Could not find any executable at '{exePath}'");
            }

            ExecutablePath = exePath;
            Arguments      = Convert.ToBase64String(Encoding.UTF8.GetBytes(pathToLec));

            if (context.SourceLanguage != "ja")
            {
                throw new EndpointInitializationException("Current implementation only supports japanese-to-english.");
            }
            if (context.DestinationLanguage != "en")
            {
                throw new EndpointInitializationException("Current implementation only supports japanese-to-english.");
            }
        }