valdisiljuconoks / localization-provider-opti

Database driven localization provider for Optimizely (ex. Episerver) websites
Apache License 2.0
11 stars 16 forks source link

Error when opening episervers add/edit admin tool #73

Closed MathiasAnderssonKnowit closed 8 months ago

MathiasAnderssonKnowit commented 4 years ago

Hi!

When trying to edit or create a new episerver user we get a stack with your localization tool. I believe this is due to two translations are trying to be accomplished on one label (Trying to translate the resource, then the result of the resource which is an empty string if it wasn't added).

When I tried to add the following translations the tool started to work again: /admin/edituser/userguisettings/description /admin/edituser/userguisettings/displayname

Our configuration is:

ConfigurationContext.Setup(cfg =>
            {
                cfg.EnableLegacyMode = () => true;
            });
<localization fallbackBehavior="FallbackCulture" fallbackCulture="en">
      <providers>
        <add name="db" type="DbLocalizationProvider.EPiServer.DatabaseLocalizationProvider, DbLocalizationProvider.EPiServer" />
      </providers>
    </localization>

We are running CMS v11.13.1 DBLocalizationProvider.EPiServer v6.0.2 DBLocalizationProvider.AdminUI.EPiServer v6.0.2

We get a null exception as the following when going to the admin tool:

[ArgumentNullException: Value cannot be null.
Parameter name: resourceKey]
   EPiServer.Framework.Localization.LocalizationService.GetStringByCulture(String resourceKey, FallbackBehaviors fallbackBehavior, String fallback, CultureInfo culture) +424
   EPiServer.UI.WebControls.TabStrip.LoadPlugIns() +686
   EPiServer.UI.WebControls.TabStrip.OnInit(EventArgs e) +33
   System.Web.UI.Control.InitRecursive(Control namingContainer) +454
   System.Web.UI.Control.InitRecursive(Control namingContainer) +219
   System.Web.UI.Control.AddedControl(Control control, Int32 index) +239
   System.Web.UI.Control.OnInit(EventArgs e) +99
   System.Web.UI.Control.InitRecursive(Control namingContainer) +454
   System.Web.UI.Control.InitRecursive(Control namingContainer) +219
   System.Web.UI.Control.InitRecursive(Control namingContainer) +219
   System.Web.UI.Control.InitRecursive(Control namingContainer) +219
   System.Web.UI.Control.InitRecursive(Control namingContainer) +219
   System.Web.UI.Control.InitRecursive(Control namingContainer) +219
   System.Web.UI.Control.InitRecursive(Control namingContainer) +219
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1719
valdisiljuconoks commented 4 years ago

Hi,

I think it's good idea to have also Xml file based provider available if all resources from those files are not migrated to database provider.

However, built-in resources should still resolve successfully..

valdisiljuconoks commented 4 years ago

Can you repro this is Alloy?

MathiasAnderssonKnowit commented 4 years ago

Hi,

I do not have an alloy site setup currently to reproduce this. Could it be in the v6.0.2 version? I agree that it should resolve successfully. Could it be that we are only relying on the DB provider now?

As said, I believe it's trying to resolve the label twice. First to resolve the /admin/edituser/userguisettings/description, which becomes an empty string, and then it's trying to resolve the empty string on page load - hence the null exception.

If this is not the cause I think the plugin should fallback to the resource key, e.g /admin/edituser/userguisettings/description?