/// <summary> /// Get localized property value of a plugin /// </summary> /// <param name="descriptor">Plugin descriptor</param> /// <param name="localizationService">Localization service</param> /// <param name="propertyName">Name of the property</param> /// <param name="languageId">Language identifier</param> /// <param name="returnDefaultValue">A value indicating whether to return default value (if localized is not found)</param> /// <returns>Localized value</returns> public static string GetLocalizedValue(this PluginDescriptor descriptor, ILocalizationService localizationService, string propertyName, int languageId = 0, bool returnDefaultValue = true) { if (localizationService == null) { throw new ArgumentNullException(nameof(localizationService)); } if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } if (propertyName == null) { throw new ArgumentNullException(nameof(propertyName)); } string systemName = descriptor.SystemName; string resourceName = string.Format("Plugins.{0}.{1}", propertyName, systemName); string result = localizationService.GetResource(resourceName, languageId, false, "", true); if (String.IsNullOrEmpty(result) && returnDefaultValue) { var fastProp = FastProperty.GetProperty(descriptor.GetType(), propertyName); if (fastProp != null) { result = fastProp.GetValue(descriptor) as string; } } return(result); }