1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
4 namespace System.Activities.Presentation.Internal.PropertyEditing
7 using System.Collections.Generic;
10 // Helper class that looks up (and keeps a map of) category names and their localized versions.
12 internal static class CategoryNameMap
15 private static Dictionary<string, string> _cache = new Dictionary<string, string>();
18 // Gets the localized value of the specified category name. If the input string
19 // is already localized, it won't be found in Cider's resources and, hence, it
20 // will be returned as is.
22 // Note that we pull category names from CategoryAttributes which already look up
23 // the localized version for common categories, such as "Misc", "Layout" and "Appearance",
24 // by default. This method just takes care of the few others that are WPF-specific and that
25 // we want to be localized as well.
27 // <param name="categoryName">Category name to look up</param>
28 // <returns>Translated version of the category name or the original name if not found.</returns>
29 public static string GetLocalizedCategoryName(string categoryName)
31 if (categoryName == null)
36 string localizedCategoryName;
37 if (_cache.TryGetValue(categoryName, out localizedCategoryName))
39 return localizedCategoryName;
42 localizedCategoryName = GetLocalizedWPFCategoryName(categoryName) ?? categoryName;
43 _cache[categoryName] = localizedCategoryName;
44 return localizedCategoryName;
47 private static string GetLocalizedWPFCategoryName(string categoryName)
49 return (string)System.Activities.Presentation.Internal.Properties.Resources.ResourceManager.GetString(string.Concat("PropertyCategory", categoryName.Replace(' ', '_')));