Base solution for your next web application
Open Closed

need help extending default localization resources #6731


User avatar
0
alexanderpilhar created

6.8.0, Angular, .NET Framework

Is it possible to extend default localization resources like described here?: Extending Localization Sources

I'm asking because I get the following error when I try to do so:

FATAL 2019-03-29 13:39:47,595 [1    ] Abp.AbpBootstrapper                      - Abp.AbpInitializationException: ProjectName source contains more than one dictionary for the culture: en
   bei Abp.Localization.Dictionaries.Xml.XmlEmbeddedFileLocalizationDictionaryProvider.Initialize(String sourceName)
   bei Abp.Localization.MultiTenantLocalizationSource.Initialize(ILocalizationConfiguration configuration, IIocResolver iocResolver)
   bei Abp.Localization.LocalizationManager.InitializeSources()
   bei Abp.AbpKernelModule.PostInitialize()
   bei System.Collections.Generic.List`1.ForEach(Action`1 action)
   bei Abp.AbpBootstrapper.Initialize()
Abp.AbpInitializationException: ProjectName source contains more than one dictionary for the culture: en
   bei Abp.Localization.Dictionaries.Xml.XmlEmbeddedFileLocalizationDictionaryProvider.Initialize(String sourceName)
   bei Abp.Localization.MultiTenantLocalizationSource.Initialize(ILocalizationConfiguration configuration, IIocResolver iocResolver)
   bei Abp.Localization.LocalizationManager.InitializeSources()
   bei Abp.AbpKernelModule.PostInitialize()
   bei System.Collections.Generic.List`1.ForEach(Action`1 action)
   bei Abp.AbpBootstrapper.Initialize()
FATAL 2019-03-29 13:39:47,700 [1    ] soft.AspNetCore.Hosting.Internal.WebHost - Application startup exception
Abp.AbpInitializationException: ProjectName source contains more than one dictionary for the culture: en
   bei Abp.Localization.Dictionaries.Xml.XmlEmbeddedFileLocalizationDictionaryProvider.Initialize(String sourceName)
   bei Abp.Localization.MultiTenantLocalizationSource.Initialize(ILocalizationConfiguration configuration, IIocResolver iocResolver)
   bei Abp.Localization.LocalizationManager.InitializeSources()
   bei Abp.AbpKernelModule.PostInitialize()
   bei System.Collections.Generic.List`1.ForEach(Action`1 action)
   bei Abp.AbpBootstrapper.Initialize()
   bei Abp.AspNetCore.AbpApplicationBuilderExtensions.InitializeAbp(IApplicationBuilder app)
   bei Abp.AspNetCore.AbpApplicationBuilderExtensions.UseAbp(IApplicationBuilder app, Action`1 optionsAction)
   bei CompanyName.ProjectName.Web.Startup.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)

My folder structure for localization resources looks like this:

  • Localization
    • ProjectName
      • ProjectName.xml
      • ProjectName-xx.xml
      • ...
    • ProjectNameExtended.xml
      • ProjectName.xml
      • ProjectName-xx.xml
      • ...

ProjectNameLocalizationConfigurer.cs looks like this:

public static void Configure(ILocalizationConfiguration localizationConfiguration)
{
    localizationConfiguration.Sources.Add(
        new DictionaryBasedLocalizationSource(
            ProjectNameConsts.LocalizationSourceName,
            new XmlEmbeddedFileLocalizationDictionaryProvider(
                typeof(ProjectNameLocalizationConfigurer).GetAssembly(),
                "CompanyName.ProjectName.Localization.ProjectName"
            )
        )
    );

    localizationConfiguration.Sources.Extensions.Add(
        new LocalizationSourceExtensionInfo(
            "(ProjectName",
            new XmlEmbeddedFileLocalizationDictionaryProvider(
                typeof(ProjectNameLocalizationConfigurer).GetAssembly(),
                "CompanyName.ProjectName.Localization.ProjectNameExtended"
            )
        )
    );
}

Please, advise!

EDIT: Removed project name from code-block


No answer yet!