コード例 #1
0
        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);
        }
コード例 #2
0
 /// <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));
 }
コード例 #3
0
 /// <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));
 }