static UILanguage() { var xmlDocument = new XmlDocument(); xmlDocument.Load(Path.Combine(Path.GetDirectoryName(typeof(UILanguage).Assembly.Location), "MUI", "languages.xml")); var nodes = xmlDocument.GetElementsByTagName("Language"); _installedLanguages = new UILanguage[nodes.Count]; for (int i = 0; i < nodes.Count; i++) { _installedLanguages[i] = new UILanguage(nodes[i].Attributes["name"].Value, nodes[i].Attributes["id"].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; }
/// <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); }
/// <summary> /// Gets the language pack file path by its language identifier. /// </summary> /// <param name="language">The language of the language pack to get.</param> /// <returns>A file path to the language pack.</returns> public virtual FilePath GetLanguagePackFilePath(UILanguage language) { return(new FilePath(_muiDirectory).Combine(language.PackIdentifier + ".xml")); }
/// <summary> /// Gets the language pack file path by its language identifier. /// </summary> /// <param name="language">The language of the language pack to get.</param> /// <returns>A file path to the language pack.</returns> public virtual FilePath GetLanguagePackFilePath(UILanguage language) { return new FilePath(_muiDirectory).Combine(language.PackIdentifier + ".xml"); }
/// <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; }