我使用資源爲我的MVC應用程序存儲用於本地化目的不同的字符串。 我正在使用HttpHandler來處理JavaScript並將Translate(KEY)
調用更改爲資源中實際的本地化字符串值。 這來自於這裏:Localize text in JavaScript files in ASP.NET使用getobject()拋出MissingManifestResourceException
問題是,當我從我的資源管理器調用GetObject方法我得到MissingManifestResourceException Could not find any resources appropriate for the specified culture or the neutral culture.
下面是相關的代碼部分(這個錯誤來自6號線在下面的代碼片段):
private string TranslateScript(string text)
{
MatchCollection matches = REGEX.Matches(text);
ResourceManager manager = new ResourceManager(typeof(CamelotShiftManagement.Strings.SharedStrings));
foreach (Match match in matches)
{
object obj = manager.GetObject(match.Groups[1].Value, CultureInfo.CurrentCulture); //This throws the MissingManifestResourceException for some reson!!!!
if (obj != null)
{
text = text.Replace(match.Value, CleanText(obj.ToString()));
}
}
return text;
}
我在做什麼錯?