<|start_filename|>GTranslatorAPI/TranslateException.cs<|end_filename|>
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GTranslatorAPI
{
    public class TranslateException
        : Exception
    {
        /// <summary>
        /// exception during translate operation
        /// </summary>
        /// <param name="txt">error text</param>
        public TranslateException(string txt)
            : base(txt)
        {

        }

        /// <summary>
        /// exception during translate operation
        /// </summary>
        /// <param name="txt">error text</param>
        /// <param name="ex">inner exception</param>
        public TranslateException(string txt,Exception ex)
            : base(txt,ex)
        {

        }
    }
}


<|start_filename|>GTranslatorAPI/Languages.cs<|end_filename|>
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GTranslatorAPI
{
    public enum Languages
    {
        af,
		auto,
        sq,
        ar,
        az,
        eu,
        be,
        bn,
        bg,
        ca,
        zh_CN,
        zh_TW,
        hr,
        cs,
        da,
        nl,
        en,
        eo,
        et,
        tl,
        fi,
        fr,
        gl,
        ka,
        de,
        el,
        gu,
        ht,
        iw,
        hi,
        hu,
        ice,    // is
        id,
        ga,
        it,
        ja,
        kn,
        ko,
        la,
        lv,
        lt,
        mk,
        ms,
        mt,
        no,
        fa,
        pl,
        pt,
        ro,
        ru,
        sr,
        sk,
        sl,
        es,
        sw,
        sv,
        ta,
        te,
        th,
        tr,
        uk,
        ur,
        vi,
        cy,
        yi
    }
}


<|start_filename|>GTranslatorAPI/GTranslatorAPISettings.cs<|end_filename|>
﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using static GTranslatorAPI.Properties.Settings;

namespace GTranslatorAPI
{
    public class GTranslatorAPISettings
    {
        /// <summary>
        /// if true, the texts are split and translated using multiple queries
        /// </summary>
        public bool SplitStringBeforeTranslate { get; set; } = true;

        /// <summary>
        /// if true and SplitStringBeforeTranslate, the translation of segments is parrallelized
        /// </summary>
        public bool ParallelizeTranslationOfSegments { get; set; } = true;

        /// <summary>
        /// Google trad api uri (path and query)
        /// </summary>
        public string GTranslatorAPIURL { get; set; } = "https://translate.googleapis.com/translate_a/single?client=gtx&sl={srcl}&tl={tgtl}&dt=t&q={txt}";

        /// <summary>
        /// query time out
        /// </summary>
        public int NetworkQueryTimeout { get; set; } = 2000;

        /// <summary>
        /// user agent
        /// </summary>
        public string UserAgent { get; set; } = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36";

        /// <summary>
        /// builds a new instance of the API settings
        /// </summary>
        public GTranslatorAPISettings()
        {
            this.GTranslatorAPIURL = Default.GTranslatorAPIURL;
            this.NetworkQueryTimeout = Default.NetworkQueryTimeout;
            this.UserAgent = Default.UserAgent;
            this.ParallelizeTranslationOfSegments = Default.ParallelizeTranslationOfSegments;
            this.SplitStringBeforeTranslate = Default.SplitStringBeforeTranslate;
        }
    }
}
