Factor Dictionary.ReplaceKey method
This commit is contained in:
@@ -532,5 +532,24 @@ namespace umbraco.cms.businesslogic
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
// zb023 - utility method
|
||||
public static string ReplaceKey(string text)
|
||||
{
|
||||
if (text.StartsWith("#") == false)
|
||||
return text;
|
||||
|
||||
var lang = Language.GetByCultureCode(Thread.CurrentThread.CurrentCulture.Name);
|
||||
|
||||
if (lang == null)
|
||||
return "[" + text + "]";
|
||||
|
||||
if (DictionaryItem.hasKey(text.Substring(1, text.Length - 1)) == false)
|
||||
return "[" + text + "]";
|
||||
|
||||
var di = new DictionaryItem(text.Substring(1, text.Length - 1));
|
||||
return di.Value(lang.id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ namespace umbraco.editorControls
|
||||
{
|
||||
foreach (object key in _prevalues.Keys)
|
||||
{
|
||||
this.Items.Add(new ListItem(dropdown.DictionaryReplace(_prevalues[key].ToString()), key.ToString()));
|
||||
this.Items.Add(new ListItem(Dictionary.ReplaceKey(_prevalues[key].ToString()), key.ToString()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -67,7 +67,7 @@ namespace umbraco.editorControls
|
||||
{
|
||||
foreach (KeyValuePair<int, String> item in Prevalues)
|
||||
{
|
||||
this.Items.Add(new ListItem(dropdown.DictionaryReplace(item.Value), item.Key.ToString()));
|
||||
this.Items.Add(new ListItem(Dictionary.ReplaceKey(item.Value), item.Key.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,26 +76,5 @@ namespace umbraco.editorControls
|
||||
if (_data != null && _data.Value != null)
|
||||
this.SelectedValue = _data.Value.ToString();
|
||||
}
|
||||
|
||||
static string DictionaryReplace(string text)
|
||||
{
|
||||
if (!text.StartsWith("#"))
|
||||
return text;
|
||||
else
|
||||
{
|
||||
Language lang = Language.GetByCultureCode(System.Threading.Thread.CurrentThread.CurrentCulture.Name);
|
||||
if (lang != null)
|
||||
{
|
||||
if (Dictionary.DictionaryItem.hasKey(text.Substring(1, text.Length - 1)))
|
||||
{
|
||||
Dictionary.DictionaryItem di = new Dictionary.DictionaryItem(text.Substring(1, text.Length - 1));
|
||||
return di.Value(lang.id);
|
||||
}
|
||||
}
|
||||
|
||||
return "[" + text + "]";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user