Language prompts

The library can load language prompts from any kind of source, although there are built in support for text files and attributes.

If you are only using english, just add the AttributeLanguageProvider to use the default text strings.

Text files

Text files should contain one line per PropertyName/Text pair.

FirstName: Förnamn
LastName: Efternamn

The text file should be placed next to your model and it's "Build Action" should be set to "Embedded Resource".
If your models name is User, the text file should be named User.1053.validation.txt, where 1053 is the lcid for Swedish in this case.


The attribute support is currently under development and is mainly used to provide languages for the actual validations. But it can still be used to provide language (even though I don't recommend it).

[LanguagePrompt("FirstName", 1053, "Förnamn")]
public class MyModel
  public string FirstName {get;set;}

Events / Stringtable

If you keep your language in standard resource files, you can just hook the LanguageRequested event.

public class Program
    private static OnDemandPrompts _stringTablePrompts = new OnDemandPrompts(name => ResourceManager.GetString(name));

    public static void Main(string[] argv)
      Validator.LanguageProviders.LanguageRequested += OnGetLanguage;

    public static void OnGetLanguage(object source, LanguageEventArgs args)
        args.Language = _stringTablePrompts ;

Last edited Mar 15, 2010 at 5:02 PM by jgauffin, version 5


No comments yet.