/// <summary>
 /// Sets the Text or HeaderText property of objects to a language specific string using the corresponding identifiers.
 /// </summary>
 /// <param name="languagePack">The language pack to use.</param>
 /// <param name="objects">The controls and their corresponding string identifiers to use.</param>
 public static void ApplyLanguageOnComponents(UILanguagePack languagePack, IDictionary <object, string> objects)
 {
     foreach (var keyPair in objects)
     {
         TryApplyLanguageOnComponent(keyPair.Key, languagePack, keyPair.Value);
     }
 }
 /// <summary>
 /// Gets the language pack by its language identifier.
 /// </summary>
 /// <param name="language">The language of the language pack to get.</param>
 /// <returns>A language pack holding the given identifier, or null if none can be found.</returns>
 public virtual UILanguagePack GetLanguagePack(UILanguage language)
 {
     UILanguagePack pack;
     if (!_cachedLanguagePacks.TryGetValue(language, out pack))
     {
         var path = GetLanguagePackFilePath(language);
         if (File.Exists(path.FullPath))
         {
             var fallbackPack = language == UILanguage.Default ? null : DefaultLanguagePack;
             pack = new UILanguagePack(path, fallbackPack);
             _cachedLanguagePacks.Add(language, pack);
         }
     }
     return pack;
 }
Exemple #3
0
        /// <summary>
        /// Tries to set the Text or HeaderText property on an object by using the specified string identifier.
        /// </summary>
        /// <param name="component">The component to set the tex to.</param>
        /// <param name="languagePack">The language pack to use.</param>
        /// <param name="id">The string identifier to use.</param>
        public static bool TryApplyLanguageOnComponent(object component, UILanguagePack languagePack, string id)
        {
            var property = FindTextProperty(component);
            if (property == null || !property.CanWrite)
                return false;

            string value;
            if (languagePack.TryGetValue(id, out value))
            {
                property.SetValue(component, value, null);
                return true;
            }

            return false;
        }
Exemple #4
0
        /// <summary>
        /// Gets the language pack by its language identifier.
        /// </summary>
        /// <param name="language">The language of the language pack to get.</param>
        /// <returns>A language pack holding the given identifier, or null if none can be found.</returns>
        public virtual UILanguagePack GetLanguagePack(UILanguage language)
        {
            UILanguagePack pack;

            if (!_cachedLanguagePacks.TryGetValue(language, out pack))
            {
                var path = GetLanguagePackFilePath(language);
                if (File.Exists(path.FullPath))
                {
                    pack = new UILanguagePack(path);
                    _cachedLanguagePacks.Add(language, pack);
                }
            }
            return(pack);
        }
        /// <summary>
        /// Gets the language pack by its language identifier.
        /// </summary>
        /// <param name="language">The language of the language pack to get.</param>
        /// <returns>A language pack holding the given identifier, or null if none can be found.</returns>
        public virtual UILanguagePack GetLanguagePack(UILanguage language)
        {
            UILanguagePack pack;

            if (!_cachedLanguagePacks.TryGetValue(language, out pack))
            {
                var path = GetLanguagePackFilePath(language);
                if (File.Exists(path.FullPath))
                {
                    var fallbackPack = language == UILanguage.Default ? null : DefaultLanguagePack;
                    pack = new UILanguagePack(path, fallbackPack);
                    _cachedLanguagePacks.Add(language, pack);
                }
            }
            return(pack);
        }
Exemple #6
0
        /// <summary>
        /// Tries to set the Text or HeaderText property on an object by using the specified string identifier.
        /// </summary>
        /// <param name="component">The component to set the tex to.</param>
        /// <param name="languagePack">The language pack to use.</param>
        /// <param name="id">The string identifier to use.</param>
        public static bool TryApplyLanguageOnComponent(object component, UILanguagePack languagePack, string id)
        {
            var property = FindTextProperty(component);

            if (property == null || !property.CanWrite)
            {
                return(false);
            }

            string value;

            if (languagePack.TryGetValue(id, out value))
            {
                property.SetValue(component, value, null);
                return(true);
            }

            return(false);
        }
 public UILanguagePack(FilePath filePath, UILanguagePack fallBackPack)
     : base(filePath)
 {
     FallbackMap = fallBackPack;
 }
Exemple #8
0
 /// <summary>
 /// Sets the Text or HeaderText property of objects to a language specific string using the corresponding identifiers.
 /// </summary>
 /// <param name="languagePack">The language pack to use.</param>
 /// <param name="objects">The controls and their corresponding string identifiers to use.</param>
 public static void ApplyLanguageOnComponents(UILanguagePack languagePack, IDictionary<object, string> objects)
 {
     foreach (var keyPair in objects)
         TryApplyLanguageOnComponent(keyPair.Key, languagePack, keyPair.Value);
 }
Exemple #9
0
 /// <summary>
 /// Gets the language pack by its language identifier.
 /// </summary>
 /// <param name="language">The language of the language pack to get.</param>
 /// <returns>A language pack holding the given identifier, or null if none can be found.</returns>
 public virtual UILanguagePack GetLanguagePack(UILanguage language)
 {
     UILanguagePack pack;
     if (!_cachedLanguagePacks.TryGetValue(language, out pack))
     {
         var path = GetLanguagePackFilePath(language);
         if (File.Exists(path.FullPath))
         {
             pack = new UILanguagePack(path);
             _cachedLanguagePacks.Add(language, pack);
         }
     }
     return pack;
 }
 public UILanguagePack(FilePath filePath, UILanguagePack fallBackPack)
     : base(filePath)
 {
     FallbackMap = fallBackPack;
 }