Esempio n. 1
0
        public FiskmoMTEngine(string srcLangCode, string trgLangCode, FiskmoMTOptions options)
        {
            var test = LanguageHelper.GetIsoCode2LetterFromIsoCode3Letter(trgLangCode);
            var lang = new Language(trgLangCode);

            this.srcLangCode = srcLangCode;
            this.trgLangCode = trgLangCode;
            this.options     = options;
        }
Esempio n. 2
0
        /// <summary>
        /// Stores multiple string pairs as translation with the help of the dummy MT service.
        /// </summary>
        /// <param name="tokenCode">The token code.</param>
        /// <param name="sources">The source strings.</param>
        /// <param name="targets">The target strings.</param>
        /// <param name="srcLangCode">The source language code.</param>
        /// <param name="trgLangCode">The target language code.</param>
        /// <returns>The indices of the translation units that were succesfully stored.</returns>
        public static int[] BatchStoreTranslation(FiskmoMTOptions options, List <string> sources, List <string> targets, string srcLangCode, string trgLangCode)
        {
            // Always dispose allocated resources
            var proxy = getNewProxy(options.GeneralSettings.MtServicePort);

            using (proxy as IDisposable)
            {
                return(proxy.BatchStoreTranslation(GetTokenCode(options), sources, targets, srcLangCode, trgLangCode));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Stores a single string pair as translation with the help of the dummy MT service.
        /// </summary>
        /// <param name="tokenCode">The token code.</param>
        /// <param name="source">The source string.</param>
        /// <param name="target">The target string.</param>
        /// <param name="srcLangCode">The source language code.</param>
        /// <param name="trgLangCode">The target language code.</param>
        public static void StoreTranslation(FiskmoMTOptions options, string source, string target, string srcLangCode, string trgLangCode)
        {
            // Always dispose allocated resources
            var proxy = getNewProxy(options.GeneralSettings.MtServicePort);

            using (proxy as IDisposable)
            {
                proxy.StoreTranslation(GetTokenCode(options), source, target, srcLangCode, trgLangCode);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Translates multiple strings with the help of the dummy MT service.
        /// </summary>
        /// <param name="tokenCode">The token code.</param>
        /// <param name="input">The strings to translate.</param>
        /// <param name="srcLangCode">The source language code.</param>
        /// <param name="trgLangCode">The target language code.</param>
        /// <returns>The translated strings.</returns>
        public static List <string> BatchTranslate(FiskmoMTOptions options, List <string> input, string srcLangCode, string trgLangCode)
        {
            // Always dispose allocated resources
            var proxy = getNewProxy(options.GeneralSettings.MtServicePort);

            using (proxy as IDisposable)
            {
                string[] result = proxy.BatchTranslate(GetTokenCode(options), input, srcLangCode, trgLangCode, "").ToArray();
                return(result.ToList());
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Translates a single string with the help of the dummy MT service.
        /// </summary>
        /// <param name="tokenCode">The token code.</param>
        /// <param name="input">The string to translate.</param>
        /// <param name="srcLangCode">The source language code.</param>
        /// <param name="trgLangCode">The target language code.</param>
        /// <returns>The translated string.</returns>
        public static string Translate(FiskmoMTOptions options, string input, string srcLangCode, string trgLangCode)
        {
            // Always dispose allocated resources
            var proxy = getNewProxy(options.GeneralSettings.MtServicePort);

            using (proxy as IDisposable)
            {
                string result = proxy.Translate(GetTokenCode(options), input, srcLangCode, trgLangCode, "");
                return(result);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Gets the valid token code.
        /// </summary>
        /// <returns>The token code.</returns>
        public static string GetTokenCode(FiskmoMTOptions options)
        {
            if (TokenCodeExpires < DateTime.Now)
            {
                // refresh the token code
                // Always dispose allocated resources
                var proxy = getNewProxy(options.GeneralSettings.MtServicePort);
                using (proxy as IDisposable)
                {
                    TokenCode        = proxy.Login("user", "user");
                    TokenCodeExpires = DateTime.Now.AddMinutes(1);
                }
            }

            return(TokenCode);
        }
Esempio n. 7
0
 /// <summary>
 /// Lists the supported languages of the dummy MT service.
 /// </summary>
 /// <returns>The list of the supported languages.</returns>
 public static List <string> ListSupportedLanguages(FiskmoMTOptions options)
 {
     return(ListSupportedLanguages(GetTokenCode(options), options.GeneralSettings.MtServicePort));
 }
Esempio n. 8
0
 public FiskmoMTSession(string srcLangCode, string trgLangCode, FiskmoMTOptions options)
 {
     this.srcLangCode = srcLangCode;
     this.trgLangCode = trgLangCode;
     this.options     = options;
 }