Date.ToLongDateString() returning date in German only on prod environment (8.2)
I have a listing page for articles that includes the date, converted into a long date string ("Friday, December 21 2018"). On all of my lower environments it is showing the dates in English but on prod it is showing the date in German.
date.Text = item.Date.ToLongDateString();
The site doesn't even use German as a language, just English and French. The listing page and all story items are English. I figure this must be an environmental Sitecore issue, since it shows in English on all lower environments. What could be causing this, and can I fix it without a code change?
multilingual
add a comment |
I have a listing page for articles that includes the date, converted into a long date string ("Friday, December 21 2018"). On all of my lower environments it is showing the dates in English but on prod it is showing the date in German.
date.Text = item.Date.ToLongDateString();
The site doesn't even use German as a language, just English and French. The listing page and all story items are English. I figure this must be an environmental Sitecore issue, since it shows in English on all lower environments. What could be causing this, and can I fix it without a code change?
multilingual
Have you checked the culture settings of the production server? I wonder if it's set to German.
– Dan Sinclair
Dec 21 '18 at 17:01
would that be settings in Sitecore, or on the server itself? I believe the server is located in Germany so that would make sense
– Erica Stockwell-Alpert
Dec 21 '18 at 17:03
add a comment |
I have a listing page for articles that includes the date, converted into a long date string ("Friday, December 21 2018"). On all of my lower environments it is showing the dates in English but on prod it is showing the date in German.
date.Text = item.Date.ToLongDateString();
The site doesn't even use German as a language, just English and French. The listing page and all story items are English. I figure this must be an environmental Sitecore issue, since it shows in English on all lower environments. What could be causing this, and can I fix it without a code change?
multilingual
I have a listing page for articles that includes the date, converted into a long date string ("Friday, December 21 2018"). On all of my lower environments it is showing the dates in English but on prod it is showing the date in German.
date.Text = item.Date.ToLongDateString();
The site doesn't even use German as a language, just English and French. The listing page and all story items are English. I figure this must be an environmental Sitecore issue, since it shows in English on all lower environments. What could be causing this, and can I fix it without a code change?
multilingual
multilingual
edited Dec 28 '18 at 9:28
Mark Cassidy♦
16.7k43280
16.7k43280
asked Dec 21 '18 at 16:45
Erica Stockwell-Alpert
29919
29919
Have you checked the culture settings of the production server? I wonder if it's set to German.
– Dan Sinclair
Dec 21 '18 at 17:01
would that be settings in Sitecore, or on the server itself? I believe the server is located in Germany so that would make sense
– Erica Stockwell-Alpert
Dec 21 '18 at 17:03
add a comment |
Have you checked the culture settings of the production server? I wonder if it's set to German.
– Dan Sinclair
Dec 21 '18 at 17:01
would that be settings in Sitecore, or on the server itself? I believe the server is located in Germany so that would make sense
– Erica Stockwell-Alpert
Dec 21 '18 at 17:03
Have you checked the culture settings of the production server? I wonder if it's set to German.
– Dan Sinclair
Dec 21 '18 at 17:01
Have you checked the culture settings of the production server? I wonder if it's set to German.
– Dan Sinclair
Dec 21 '18 at 17:01
would that be settings in Sitecore, or on the server itself? I believe the server is located in Germany so that would make sense
– Erica Stockwell-Alpert
Dec 21 '18 at 17:03
would that be settings in Sitecore, or on the server itself? I believe the server is located in Germany so that would make sense
– Erica Stockwell-Alpert
Dec 21 '18 at 17:03
add a comment |
2 Answers
2
active
oldest
votes
date.ToLongDateString()
executes in the background DateTimeFormat.Format(this, "D", DateTimeFormatInfo.CurrentInfo)
.
It means that the culture info is taken from the thread or from the server (you may want to double check if it's from both or from one of them only - I'm not sure anymore).
What you could do is passing the chosen culture to the Format
method like
DateTimeFormat.Format(this, "D", new CultureInfo("en-GB"));
But that requires code change.
It should be also enough to set the globalization in web.config like:
<globalization culture="en-GB" uiCulture="en-GB">
I didn't have an option to test it though
thanks! now, my site does have both English and French. would adding "<globalization culture="en-GB" uiCulture="en-GB" mess up the French version (i.e. make the culture context english when it should be French)?
– Erica Stockwell-Alpert
Dec 21 '18 at 17:21
I'm not sure if that would be possible to get the language automatically from the Sitecore context. You may try using "auto" instead of "en-GB" but I'm afraid you would need to change your code and pass the culture info.
– Marek Musielak
Dec 21 '18 at 17:25
ok. i'll just go wtih the code change then. thanks!
– Erica Stockwell-Alpert
Dec 21 '18 at 17:31
add a comment |
You can set language property to proper language code dor tour english anf french sites like this:
<site name="french" ... virtualFolder="/fr-FR" physicalFolder="/fr-FR" rootPath="/sitecore/content" startItem="/French/Home" language="fr-FR" ... />
<site name="english" ... virtualFolder="/en-GB" physicalFolder="/en-GB" rootPath="/sitecore/content" startItem="/English/Home" language="en-GB" ... />
Don't know your current setup of sites in config so take above configuration as example and especially mind the language
attribute.
Then you can access this within your code like this Sitecore.Context.Language
.
Therefore the code to format datetime field should be like:
DateTimeFormat.Format(this, "D", new CultureInfo(Sitecore.Context.Language));
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "664"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f15666%2fdate-tolongdatestring-returning-date-in-german-only-on-prod-environment-8-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
date.ToLongDateString()
executes in the background DateTimeFormat.Format(this, "D", DateTimeFormatInfo.CurrentInfo)
.
It means that the culture info is taken from the thread or from the server (you may want to double check if it's from both or from one of them only - I'm not sure anymore).
What you could do is passing the chosen culture to the Format
method like
DateTimeFormat.Format(this, "D", new CultureInfo("en-GB"));
But that requires code change.
It should be also enough to set the globalization in web.config like:
<globalization culture="en-GB" uiCulture="en-GB">
I didn't have an option to test it though
thanks! now, my site does have both English and French. would adding "<globalization culture="en-GB" uiCulture="en-GB" mess up the French version (i.e. make the culture context english when it should be French)?
– Erica Stockwell-Alpert
Dec 21 '18 at 17:21
I'm not sure if that would be possible to get the language automatically from the Sitecore context. You may try using "auto" instead of "en-GB" but I'm afraid you would need to change your code and pass the culture info.
– Marek Musielak
Dec 21 '18 at 17:25
ok. i'll just go wtih the code change then. thanks!
– Erica Stockwell-Alpert
Dec 21 '18 at 17:31
add a comment |
date.ToLongDateString()
executes in the background DateTimeFormat.Format(this, "D", DateTimeFormatInfo.CurrentInfo)
.
It means that the culture info is taken from the thread or from the server (you may want to double check if it's from both or from one of them only - I'm not sure anymore).
What you could do is passing the chosen culture to the Format
method like
DateTimeFormat.Format(this, "D", new CultureInfo("en-GB"));
But that requires code change.
It should be also enough to set the globalization in web.config like:
<globalization culture="en-GB" uiCulture="en-GB">
I didn't have an option to test it though
thanks! now, my site does have both English and French. would adding "<globalization culture="en-GB" uiCulture="en-GB" mess up the French version (i.e. make the culture context english when it should be French)?
– Erica Stockwell-Alpert
Dec 21 '18 at 17:21
I'm not sure if that would be possible to get the language automatically from the Sitecore context. You may try using "auto" instead of "en-GB" but I'm afraid you would need to change your code and pass the culture info.
– Marek Musielak
Dec 21 '18 at 17:25
ok. i'll just go wtih the code change then. thanks!
– Erica Stockwell-Alpert
Dec 21 '18 at 17:31
add a comment |
date.ToLongDateString()
executes in the background DateTimeFormat.Format(this, "D", DateTimeFormatInfo.CurrentInfo)
.
It means that the culture info is taken from the thread or from the server (you may want to double check if it's from both or from one of them only - I'm not sure anymore).
What you could do is passing the chosen culture to the Format
method like
DateTimeFormat.Format(this, "D", new CultureInfo("en-GB"));
But that requires code change.
It should be also enough to set the globalization in web.config like:
<globalization culture="en-GB" uiCulture="en-GB">
I didn't have an option to test it though
date.ToLongDateString()
executes in the background DateTimeFormat.Format(this, "D", DateTimeFormatInfo.CurrentInfo)
.
It means that the culture info is taken from the thread or from the server (you may want to double check if it's from both or from one of them only - I'm not sure anymore).
What you could do is passing the chosen culture to the Format
method like
DateTimeFormat.Format(this, "D", new CultureInfo("en-GB"));
But that requires code change.
It should be also enough to set the globalization in web.config like:
<globalization culture="en-GB" uiCulture="en-GB">
I didn't have an option to test it though
edited Dec 21 '18 at 17:40
Dan Sinclair
1,332525
1,332525
answered Dec 21 '18 at 17:18
Marek Musielak
9,63511035
9,63511035
thanks! now, my site does have both English and French. would adding "<globalization culture="en-GB" uiCulture="en-GB" mess up the French version (i.e. make the culture context english when it should be French)?
– Erica Stockwell-Alpert
Dec 21 '18 at 17:21
I'm not sure if that would be possible to get the language automatically from the Sitecore context. You may try using "auto" instead of "en-GB" but I'm afraid you would need to change your code and pass the culture info.
– Marek Musielak
Dec 21 '18 at 17:25
ok. i'll just go wtih the code change then. thanks!
– Erica Stockwell-Alpert
Dec 21 '18 at 17:31
add a comment |
thanks! now, my site does have both English and French. would adding "<globalization culture="en-GB" uiCulture="en-GB" mess up the French version (i.e. make the culture context english when it should be French)?
– Erica Stockwell-Alpert
Dec 21 '18 at 17:21
I'm not sure if that would be possible to get the language automatically from the Sitecore context. You may try using "auto" instead of "en-GB" but I'm afraid you would need to change your code and pass the culture info.
– Marek Musielak
Dec 21 '18 at 17:25
ok. i'll just go wtih the code change then. thanks!
– Erica Stockwell-Alpert
Dec 21 '18 at 17:31
thanks! now, my site does have both English and French. would adding "<globalization culture="en-GB" uiCulture="en-GB" mess up the French version (i.e. make the culture context english when it should be French)?
– Erica Stockwell-Alpert
Dec 21 '18 at 17:21
thanks! now, my site does have both English and French. would adding "<globalization culture="en-GB" uiCulture="en-GB" mess up the French version (i.e. make the culture context english when it should be French)?
– Erica Stockwell-Alpert
Dec 21 '18 at 17:21
I'm not sure if that would be possible to get the language automatically from the Sitecore context. You may try using "auto" instead of "en-GB" but I'm afraid you would need to change your code and pass the culture info.
– Marek Musielak
Dec 21 '18 at 17:25
I'm not sure if that would be possible to get the language automatically from the Sitecore context. You may try using "auto" instead of "en-GB" but I'm afraid you would need to change your code and pass the culture info.
– Marek Musielak
Dec 21 '18 at 17:25
ok. i'll just go wtih the code change then. thanks!
– Erica Stockwell-Alpert
Dec 21 '18 at 17:31
ok. i'll just go wtih the code change then. thanks!
– Erica Stockwell-Alpert
Dec 21 '18 at 17:31
add a comment |
You can set language property to proper language code dor tour english anf french sites like this:
<site name="french" ... virtualFolder="/fr-FR" physicalFolder="/fr-FR" rootPath="/sitecore/content" startItem="/French/Home" language="fr-FR" ... />
<site name="english" ... virtualFolder="/en-GB" physicalFolder="/en-GB" rootPath="/sitecore/content" startItem="/English/Home" language="en-GB" ... />
Don't know your current setup of sites in config so take above configuration as example and especially mind the language
attribute.
Then you can access this within your code like this Sitecore.Context.Language
.
Therefore the code to format datetime field should be like:
DateTimeFormat.Format(this, "D", new CultureInfo(Sitecore.Context.Language));
add a comment |
You can set language property to proper language code dor tour english anf french sites like this:
<site name="french" ... virtualFolder="/fr-FR" physicalFolder="/fr-FR" rootPath="/sitecore/content" startItem="/French/Home" language="fr-FR" ... />
<site name="english" ... virtualFolder="/en-GB" physicalFolder="/en-GB" rootPath="/sitecore/content" startItem="/English/Home" language="en-GB" ... />
Don't know your current setup of sites in config so take above configuration as example and especially mind the language
attribute.
Then you can access this within your code like this Sitecore.Context.Language
.
Therefore the code to format datetime field should be like:
DateTimeFormat.Format(this, "D", new CultureInfo(Sitecore.Context.Language));
add a comment |
You can set language property to proper language code dor tour english anf french sites like this:
<site name="french" ... virtualFolder="/fr-FR" physicalFolder="/fr-FR" rootPath="/sitecore/content" startItem="/French/Home" language="fr-FR" ... />
<site name="english" ... virtualFolder="/en-GB" physicalFolder="/en-GB" rootPath="/sitecore/content" startItem="/English/Home" language="en-GB" ... />
Don't know your current setup of sites in config so take above configuration as example and especially mind the language
attribute.
Then you can access this within your code like this Sitecore.Context.Language
.
Therefore the code to format datetime field should be like:
DateTimeFormat.Format(this, "D", new CultureInfo(Sitecore.Context.Language));
You can set language property to proper language code dor tour english anf french sites like this:
<site name="french" ... virtualFolder="/fr-FR" physicalFolder="/fr-FR" rootPath="/sitecore/content" startItem="/French/Home" language="fr-FR" ... />
<site name="english" ... virtualFolder="/en-GB" physicalFolder="/en-GB" rootPath="/sitecore/content" startItem="/English/Home" language="en-GB" ... />
Don't know your current setup of sites in config so take above configuration as example and especially mind the language
attribute.
Then you can access this within your code like this Sitecore.Context.Language
.
Therefore the code to format datetime field should be like:
DateTimeFormat.Format(this, "D", new CultureInfo(Sitecore.Context.Language));
answered Dec 22 '18 at 14:33
Peter Procházka
4,6241839
4,6241839
add a comment |
add a comment |
Thanks for contributing an answer to Sitecore Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f15666%2fdate-tolongdatestring-returning-date-in-german-only-on-prod-environment-8-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Have you checked the culture settings of the production server? I wonder if it's set to German.
– Dan Sinclair
Dec 21 '18 at 17:01
would that be settings in Sitecore, or on the server itself? I believe the server is located in Germany so that would make sense
– Erica Stockwell-Alpert
Dec 21 '18 at 17:03