get contents according to current culture?

Muhammad Kaleem asked on May 28, 2019 12:40

i'm using kentico12 mvc, and also i have enabled multiple cultures, i'm retrieving contents from my home page as given in query,

Home homeNode = HomeProvider.GetHome("/Home", "en-us", SiteContext.CurrentSiteName)
                .Columns("DocumentName", "DocumentID", "HomeHeader", "HomeTextHeading", "HomeText");

here by default he is using "en-Us" i have replace it with CMS.Localization.LocalizationContext.CurrentCulture.CultureCode so, when i come with different culture i.e("es-ES") then query should get contents of "es-ES" but its not working,

please suggest any help will be highly appreciated

thanks

Recent Answers


David te Kloese answered on May 28, 2019 14:19

Again, can you verify using debug or aditional logging that CMS.Localization.LocalizationContext.CurrentCulture.CultureCode actually changes if you change your url.

0 votesVote for this answer Mark as a Correct answer

Muhammad Kaleem answered on May 28, 2019 14:54

Thanks David, on changing culture code in url CMS.Localization.LocalizationContext.CurrentCulture.CultureCode this still returning en-US that is selected culture in CMS, when i give es-ES hard coded then my query gets data accordingly, now problem is that i have to update my query, please suggest how can i get culture code from current request, dynamically, also i have implement MultiCultureMvcRouteHandler

please suggest

thanks

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on May 28, 2019 15:16

see my comment on your other question devnet.kentico.com/questions/how-to-get-culture-code-of-current-request , I think you miss the setting of the culture into the current context!

0 votesVote for this answer Mark as a Correct answer

Muhammad Kaleem answered on May 28, 2019 18:16

Hi David,

i already have implement culture settings as it is as provided in documentation

0 votesVote for this answer Mark as a Correct answer

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