Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

84 lines (76 sloc) 3.745 kB
/*
* Copyright (c) 2011, Jonas Gauffin. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
using System;
using System.Web.Mvc;
namespace Griffin.MvcContrib.Localization.Types
{
/// <summary>
/// Used to be able to provide localized strings from any source.
/// </summary>
/// <seealso cref="CommonPrompts"/>
public interface ILocalizedStringProvider
{
/// <summary>
/// Get a localized string for a model property
/// </summary>
/// <param name="model">Model being localized</param>
/// <param name="propertyName">Property to get string for</param>
/// <returns>Translated string if found; otherwise null.</returns>
string GetModelString(Type model, string propertyName);
/// <summary>
/// Get a localized metadata for a model property
/// </summary>
/// <param name="model">Model being localized</param>
/// <param name="propertyName">Property to get string for</param>
/// <param name="metadataName">Valid names are: Watermark, Description, NullDisplayText, ShortDisplayText.</param>
/// <returns>Translated string if found; otherwise null.</returns>
/// <remarks>
/// Look at <see cref="ModelMetadata"/> to know more about the meta data
/// </remarks>
string GetModelString(Type model, string propertyName, string metadataName);
/// <summary>
/// Get a translated string for a validation attribute
/// </summary>
/// <param name="attributeType">Type of attribute</param>
/// <returns>Translated validation message if found; otherwise null.</returns>
/// <remarks>
/// Used to get localized error messages for the DataAnnotation attributes. The returned string
/// should have the same format as the built in messages, such as "{0} is required.".
/// </remarks>
string GetValidationString(Type attributeType);
/// <summary>
/// Get a translated string for a validation attribute
/// </summary>
/// <param name="attributeType">Type of attribute</param>
/// <param name="modelType">Your view model</param>
/// <param name="propertyName">Property in your view model</param>
/// <returns>Translated validation message if found; otherwise null.</returns>
/// <remarks>
/// Tries to get a validation string which is specific for a view model property.
/// </remarks>
string GetValidationString(Type attributeType, Type modelType, string propertyName);
/// <summary>
/// Gets a enum string
/// </summary>
/// <param name="enumType">Type of enum</param>
/// <param name="name">Name of the value to translation for</param>
/// <returns>Translated name if found; otherwise null.</returns>
string GetEnumString(Type enumType, string name);
}
}
Jump to Line
Something went wrong with that request. Please try again.