Bypassing culture's default language for dates to display months in english

Blake Young asked on January 11, 2017 02:34

Hi there,

We have a multi-region website with each region set-up based on culture. In creating a new region/culture (India), the dates included within our blog display the default language for this new culture (Hindi), whereas we would like for this element to remain in English.

Any ideas how we can enforce a language for a portion of code without affecting Google's ability to detect this localised version of the site OR set-up the dates in Kentico so that they display in English despite the culture's default language?

Link: http://tinyurl.com/zhlljhm

Regards,

Blake

Recent Answers


Peter Mogilnitski answered on January 11, 2017 03:20

You can do it with asp.net here is a good example

// Creates a CultureInfo for German in Germany.
CultureInfo ci = new CultureInfo("de-DE");
// Displays dt, formatted using the ShortDatePattern
// and the CultureInfo.
 Console.WriteLine(dt.ToString("d", ci));
0 votesVote for this answer Mark as a Correct answer

Blake Young answered on January 11, 2017 04:15

Thanks Peter. Interesting solution. This may work but design-wise may look a bit off-balance with a shorter number-based date format. Any idea of how to display the date (month) in English while keeping the DD MONTH YYYY format???

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on January 11, 2017 05:23

you can put any format you like:

Console.WriteLine(dt.ToString("dd MMMM YYYY", ci));

It is all in Custom Date and Time Format Strings

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.