public static SmartFormatter CreateDefaultSmartFormat() { // Register all default extensions here: var result = new SmartFormatter(); // Add all extensions: // Note, the order is important; the extensions // will be executed in this order: var listFormatter = new ListFormatter(result); result.AddExtensions( (ISource)listFormatter, new ReflectionSource(result), new DictionarySource(result), // These default extensions reproduce the String.Format behavior: new DefaultSource(result) ); result.AddExtensions( (IFormatter)listFormatter, new PluralLocalizationFormatter("en"), new ConditionalFormatter(), new TimeFormatter("en"), new DefaultFormatter() ); return result; }
static Localizer() { formatter = new SmartFormatter(); var listFormatter = new ListFormatter(formatter); formatter.AddExtensions( listFormatter, new DefaultSource(formatter) ); formatter.AddExtensions( listFormatter, new PluralLocalizationFormatter("en"), new ChooseFormatter(), new DefaultFormatter() ); }