/// <summary> /// Get the label with the specified key from the resource files. /// </summary> /// <param name="controller">Controller that requests the resource.</param> /// <param name="key">The key.</param> /// <param name="fallbackToKey">If true then if a resource is not found with the specified key the key is returned.</param> private static string Resource(ControllerBase controller, RouteData routeData, string key, bool fallbackToKey) { var resClass = LocalizationHelpers.FindResourceStringClassType(controller.GetType()); var widgetName = routeData != null ? routeData.Values["widgetName"] as string : null; if (!string.IsNullOrEmpty(widgetName)) { var widget = FrontendManager.ControllerFactory.ResolveControllerType(widgetName); if (widget != null) { var widgetResClass = LocalizationHelpers.FindResourceStringClassType(widget); string res; if (widgetResClass != null && Res.TryGet(widgetResClass.Name, key, null, out res)) { return(res); } } } string result; if (Res.TryGet(resClass.Name, key, null, out result)) { return(result); } if (fallbackToKey) { return(key); } return("#ResourceNotFound: {0}, {1}#".Arrange(resClass.Name, key)); }
public static string Label(this ViewPage page, string key) { var controller = LocalizationHelpers.GetController(page); var resClass = LocalizationHelpers.FindResourceStringClassType(controller.GetType()); return(Res.Get(resClass, key, System.Globalization.CultureInfo.InvariantCulture)); }
/// <summary> /// Get the label with the specified key from the resource files. /// </summary> /// <param name="key">The key.</param> public static string Label(this ViewPage page, string key) { var controller = LocalizationHelpers.GetController(page); var resClass = LocalizationHelpers.FindResourceStringClassType(controller); return(Res.Get(resClass, key)); }
/// <summary> /// Get the label with the specified key from the resource files. /// </summary> /// <param name="controller">Controller that requests the resource.</param> /// <param name="key">The key.</param> public static string Label(IController controller, string key) { var resClass = LocalizationHelpers.FindResourceStringClassType(controller); return(Res.Get(resClass, key)); }