public static string GetString(string dictionary, string key) { if (dictionary == null) { throw new ArgumentNullException("dictionary"); } if (dictionary == string.Empty) { throw new ArgumentException("dictionary is empty", "dictionary"); } if (key == null) { throw new ArgumentNullException("key"); } if (key == string.Empty) { throw new ArgumentException("key is empty", "key"); } string assembly = LocalizeDictionary.GetAssemblyName(Assembly.Load(LocalizeDictionary.AssemblyName)); try { return((string)LocalizeDictionary.Instance.GetLocalizedObject <object>( assembly, dictionary, key, LocalizeDictionary.Instance.Culture)); } catch { return(string.Format("No resource key with name '{0}' in dictionary '{1}' in assembly '{2}' founded! ({2}.{1}.{0})", key, dictionary, assembly)); } }
/// <summary> /// Initialize the LocalizeExtension /// </summary> /// <remarks> /// This constructor register the <see cref="EventHandler"/> <c>OnCultureChanged</c> on <c>LocalizeDictionary</c> /// to get an acknowledge of changing the culture /// </remarks> /// <param name="key"> /// Three types are supported: /// Direct: passed key = key; /// Dict/Key pair: this have to be separated like ResXDictionaryName:ResourceKey /// Assembly/Dict/Key pair: this have to be separated like ResXDictionaryName:ResourceKey /// </param> protected LocalizeExtension(string key) : this() { // parse the key value and split it up if necessary LocalizeDictionary.ParseKey(key, out m_Assembly, out m_Dict, out m_Key); }