public ResourceManagerLocalizerFixture( ) { var resourceManager = new DictionaryResourceManager("en-US"); resourceManager.Add("en-US", new Hashtable( ) { { "Items", "{0} items" }, { "Items.Zero", "No items" }, { "Items.One", "{0} item" }, { "Pixels", "{0} pixels" }, { "Pixels.One", "{0} pixel" } }); resourceManager.Add("fr-FR", new Hashtable( ) { { "Items", "{0} items" }, { "Items.Zero", "Aucun item" }, { "Items.One", "{0} item" }, { "Pixels", "{0} pixels" }, { "Pixels.One", "{0} pixel" } }); Localizer = new ResourceManagerLocalizer(resourceManager); }
/// <summary> /// Override this method to use a custom localization. /// </summary> /// <param name="id">The id of the string.</param> /// <returns> The localized text. </returns> public virtual string GetLocalizedString(MapStringId id) { return(ResourceManagerLocalizer.GetString(id)); }
/// <summary> /// Gets the localizes string for a <see cref="MapStringId"/>. /// </summary> /// <param name="id">The id of the string.</param> /// <returns> The localized text. </returns> public static string GetString(MapStringId id) { return(Active == null?ResourceManagerLocalizer.GetString(id) : Active.GetLocalizedString(id)); }