Esempio n. 1
0
        /// <summary>
        /// Adds a translation given by a stream.
        /// </summary>
        /// <param name="stream">the stream with the content</param>
        /// <param name="extension">determines the data format of the stream content (for example: .xml)</param>
        /// <param name="culture">the language the content translates into</param>
        /// <param name="channel">an optional name for this set of translations</param>
        public static void Add(Stream stream, string extension, CultureInfo culture, string channel = "")
        {
            if (channel == null)
            {
                throw new ArgumentException("name can not be null");
            }
            if (culture == null)
            {
                throw new ArgumentException("culture can not be null");
            }

            ITranslationProvider provider = TranslationProviderFactory.Create(extension);

            if (provider == null)
            {
                throw new Exception("For this data format exists no Translation provider");
            }

            var dict = provider.Parse(stream);

            dictionaries[culture.TwoLetterISOLanguageName, channel] = dict;
        }