OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.38k stars 1.12k forks source link

in new version 1.10.2 , culture picker does not work in front end! #7848

Open mtugnoli opened 7 years ago

mtugnoli commented 7 years ago

in new version 1.10.2 , culture picker does not work in front end!

I would like to add Multilanguage.

I follow this tutorial https://youtu.be/t6Tt8vjlOVw

In version 1.10.2 Culture Picker (Sergey Ermakovich version) seem not available, is replaced with one already in 1.10.2 version,

this show a language picker, in admin page, but is not available to add in Header Widget (like video)

sebastienros commented 7 years ago

It's a gallery module, we can't fix it. But I think there is something out of the box in Orchard for that as someone asked how to hide it not later than this week. @MatteoPiovanelli-Laser do you know?

MatteoPiovanelli-Laser commented 7 years ago

I think that out of the box you only get to have links to the other localizations of the ContentItem being displayed (if any). That is what they were asking to hide recently on gitter. It's the default "Detail" display type for LocalizationPart.

DannyT commented 7 years ago

Just to add +1 to this issue.

I am setting up a localized site for the first time but there is no means of allowing a user to set their locale for the site. I can translate content items which shows the language options for just that content item however it doesn't set the locale rather just switches to the alternate content item.

If I have a layer rule set up to show me French culturecode("fr-FR") the only way I can get the front-end of the website to actually display this layer is to set the default culture for the entire site to French. There is no module or widget that I can place on the front-end to allow the user to set the culture.

Unless I'm missing something?

MatteoPiovanelli-Laser commented 7 years ago

As @mtugnoli mentioned, there used to be the CulturePicker module off the gallery to do just that. We use a (heavily) customized version of it.

Note that there is ICultureSelector: roughly speaking, implementations of this interface are used to determine the WorkContext.CurrentCulture. If I remember correctly, once you navigate to a ContentItem whose culture is "fr-FR", CurrentCulture should be set to "fr-FR" by the default ICultureSelector implementations. At that point, in theory, you should see the correct layers. The main thing the CulturePicker did was provide a Controller with a ChangeCulture/{culture} Action that would look for localizations of the current content in the given culture, and redirect to that if found. A widget would add for each existing culture a link to the same action, with a different parameter. The ICultureSelectors should be taking care of pretty much everything after that.

You can see all that in action on http://www.anfiteatromorenicoivrea.it/

MatteoPiovanelli-Laser commented 7 years ago

On ther other hand, you can use an alternate for the DIsplay view of LocalizationPart. I think that shows llinks to the localized versions. As long as those are all in place, it will work like a less automated version of CulturePicker. Depending on how you are organizing contents, you could play with the alternates there to get the links sort of working also for Contents that are not translated (e.g. by linking to their section).

DannyT commented 7 years ago

Thanks for the response @MatteoPiovanelli-Laser

If I remember correctly, once you navigate to a ContentItem whose culture is "fr-FR", CurrentCulture should be set to "fr-FR" by the default ICultureSelector implementations. At that point, in theory, you should see the correct layers.

I think this is the problem area, in my example (1.10.2) clicking the fr-FR translation shows me the content item translation but does not reveal the layer with the rule culturecode("fr-FR"). The only way I can get that to show is by setting the site default culture to fr-FR in the admin which is obviously not the behaviour I'm expecting.

To be clear, the ideal is a solution like in your example where the user can just set their culture and we essentially show them different menus based on the layer rule which all link to the translated versions of the content. I looked at the CulturePicker module off the gallery but seemingly that's no longer supported. I was hoping for an admin UI driven solution but will take a deeper look.

MatteoPiovanelli-Laser commented 7 years ago

@DannyT try this for a layer rule:

Lang('fr-FR')
DannyT commented 7 years ago

@MatteoPiovanelli-Laser interestingly, this defaults it back to culturecode("fr-FR"). Weirdly, however, it now seems to be working as I would expect...

Would a website restart be required after adding a new culture? Alternatively I wonder if caching was making me think this wasn't working...

Seems to be okay now though so thanks for your help.

MatteoPiovanelli-Laser commented 7 years ago

I would blame caching. I never had to restart a website after adding cultures.

You are welcome.