Nop 4.0 customer registration page date picker not localized

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Hi!

I can't get the date picker on the customer registration page to get localized. When I click on Register, the date picker have the default values "Day", "Month" and "Year" but I would like them localized. All string resources in the table are translated so I cannot figure out where to change this, not even when I look in the sourcecode.
Help is preciated :)

Regards Markus
6 years ago
d99mj wrote:
Hi!

I can't get the date picker on the customer registration page to get localized. When I click on Register, the date picker have the default values "Day", "Month" and "Year" but I would like them localized. All string resources in the table are translated so I cannot figure out where to change this, not even when I look in the sourcecode.
Help is preciated :)

Regards Markus


Resource Names are

Common.Day
Common.Month
Common.Year

Try to change below resources.
6 years ago
Hi!

Thanks for you help! Unfortunately they already are translated and it still doesen't work. I have tried to change the resource value from Nop Admin, empty cache and still no luck. When I debug and step through the code it seems like the translated sring resources are never requested. Only the hard coded default values are returned.
In version 3.9 it worked with the same database (now updated with the upgrade script).

More tips are apreciated! :)

Regards Markus
6 years ago
It seems that the if statement below always evaluates to false why the localized strings never are used. Is it a bug or do I need to change a setting anywhere to get the values of Common.Day, Common.Month and Common.Year instead?


            if (bool.TryParse(LocalizeLabels, out bool localizeLabels) && localizeLabels)
            {
                var locService = EngineContext.Current.Resolve<ILocalizationService>();
                dayLocale = locService.GetResource("Common.Day");
                monthLocale = locService.GetResource("Common.Month");
                yearLocale = locService.GetResource("Common.Year");
            }
            else
            {
                dayLocale = "Day";
                monthLocale = "Month";
                yearLocale = "Year";
            }


Regards Markus
5 years ago
d99mj wrote:
It seems that the if statement below always evaluates to false why the localized strings never are used. Is it a bug or do I need to change a setting anywhere to get the values of Common.Day, Common.Month and Common.Year instead?


            if (bool.TryParse(LocalizeLabels, out bool localizeLabels) && localizeLabels)
            {
                var locService = EngineContext.Current.Resolve<ILocalizationService>();
                dayLocale = locService.GetResource("Common.Day");
                monthLocale = locService.GetResource("Common.Month");
                yearLocale = locService.GetResource("Common.Year");
            }
            else
            {
                dayLocale = "Day";
                monthLocale = "Month";
                yearLocale = "Year";
            }


Regards Markus


Hey Markus,

I came across the same issue, not sure if you resolved it yet; As you noticed LocalizeLabels only exists as a local var and is always NULL.

My fix is the following:

            try
            {
                var locService = EngineContext.Current.Resolve<ILocalizationService>();
                dayLocale = locService.GetResource("Common.Day");
                monthLocale = locService.GetResource("Common.Month");
                yearLocale = locService.GetResource("Common.Year");
            }
            catch
            {
                dayLocale = "Day";
                monthLocale = "Month";
                yearLocale = "Year";
            }
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.