Localisation to UK breaks CMS
# help-with-umbraco
j
After we add this code to the Startup file all our users who are set to US can no longer login to the CMS. var supportedCultures = new[] { new CultureInfo("en-GB"), }; services.Configure(options => { options.DefaultRequestCulture = new RequestCulture("en-GB"); options.SupportedCultures = supportedCultures; options.SupportedUICultures = supportedCultures; }); Is there a fix or do we need to remove this from the Startup? The reason why we added this as our Date formats in the front end using Edge shows dates as US and not UK.
s
You don't need to add this to your startup file, configure your home node to be
en-GB
in Cultures & Hostnames
j
it is already - we ran out of options so added this code which seemed to fix the front end. The dates are coming from a XML (YYYY-MM-dd) file uploaded in the CMS and outputted to the front end using jquery.
s
Then
<html lang="@System.Threading.Thread.CurrentThread.CurrentCulture.Name">
might help as well in your layout template
j
If we update Edge - and set the default language to UK then the dates are in UK format - but of course we cant tell all the users to do that 🙂
Currently our html lang is "en"
s
Setting
<html lang="en-GB">
might help as well in your layout template
And try to put
<p>@System.Threading.Thread.CurrentThread.CurrentCulture.Name</p>
somewhere in your template to check what the actual language is that's being set.
s
what does
<p>@System.Threading.Thread.CurrentThread.CurrentCulture.Name</p>
result in?
j
it is outputted as en-GB
s
same for
<p>@System.Threading.Thread.CurrentThread.CurrentUICulture.Name</p>
?
You have actually removed the additions to
Startup.cs
when testing this, right?
j
I'll have a double check 🙂
s
using jquery
--> a jQuery plugin?
j
The odd thing is - the same code works in our version 8 site on Azure - but when upgrading to 13 it started with this issue.
And to confirm - the startup file does not have the en-GB updates that broke the CMS
s
1. what does
<p>@System.Threading.Thread.CurrentThread.CurrentUICulture.Name</p>
say? 2. what jQuery plugin are you using?|
2. "https://code.jquery.com/jquery-3.6.1.min.js
s
Alright I am out of ideas, everything is set correctly and works for other people. If you can isolate the jQuery stuff to an example I can copy/paste into a fresh site I can look again, but it doesn't seem like Umbraco is the problem here.
j
Thanks for all your help - i'll see if we can do something with the data. Thaks again
s
I can't tell how that date ends up in the UI, so maybe it needs help, something like: https://stackoverflow.com/a/52035595/23234415 If you can just display the date with Razor wouldn't that be much easier? 😅
j
I have started to alter the date in code in the API. I'll see if that helps. 🙂
c
Hi, not sure if I can hijack this thread, but I have similar problem. Root node is set to en-GB, all other are Inherit. But if I put @CultureInfo.CurrentCulture into header view I always get 'en-us'. I am not overriding culture/language anywhere in code. I also only have English(Uk) in Settings->Languages and is set to default. (also umbraco 13)
@CultureInfo.CurrentCulture on home page view still says 'en-us'
s
Maybe you do need to add a domain then, but it can just be
/
instead of a full domain
We also fixed something in 13.4.0, so you might need to upgrade? https://github.com/umbraco/Umbraco-CMS/issues/16555
But seems to only apply if you use
IVirtualPageController
c
I tried adding domain (/ or actual one), doesnt work I have latest version 13.4.0
c
yea, it works in fresh umbraco project, just trying to figure out why its not working anymore. I did update this umbraco from v10, if that makes a difference
11 Views