The Basic Case of Localization in 1.8.1...

Topics: Localization
Nov 20, 2014 at 10:29 AM
Edited Nov 20, 2014 at 12:12 PM
... and I can't get it to work!

I'm trying to set the current culture for the entire website based on the URL. For example, mysite.com/en/blablabla... has to set the culture to "en" and so on... To clarify a bit: this is extremely useful for search engines. I don't get any other approaches (cookie/browser/selectors/...): how can Google index all cultures if the culture can only be switched by, say, cookie? Moreover, I just can't find any single major site that is localized in a way that differs from /lang/... in URL.

To achieve the required behavior in my Theme I've implemented CultureSelector that is ICultureSelector. And just check if the relative path begins with "en". If so, I return "new CultureSelectorResult { Priority = 5, CultureName = culture }".

The default culture for my website is set to "de" and I have a Query that displays its items "for current culture". When I visit /en/myquery it still shows "de" results.

Can you please explain, what am I missing?
Nov 20, 2014 at 5:39 PM
You can try this module:

https://bitbucket.org/csurieux/datwendo.localization

I´m using it for a project i´m developing now for a client, a it works really well.
Nov 24, 2014 at 12:59 PM
Sure, I can try this. But I can't understand why ICultureSelector doesn't work in my case.
Nov 28, 2014 at 1:55 PM
Edited Nov 28, 2014 at 1:55 PM
Ok, tried Datwendo.Localization. First of all, it crashes immediately after installation on 1.8.1:

None of the constructors found with 'Orchard.Environment.AutofacUtil.DynamicProxy2.ConstructorFinderWrapper' on type 'Datwendo.Localization.Services.AdminCultureService' can be invoked with the available services and parameters:
Cannot resolve parameter 'Datwendo.Localization.Services.IUserCultureService userCultureService' of constructor 'Void .ctor(Orchard.IWorkContextAccessor, Orchard.Caching.ICacheManager, Datwendo.Localization.Services.IUserCultureService, Orchard.Caching.ISignals)'.
Nov 28, 2014 at 3:29 PM
Ok, just downloaded the latest sources from the project's repository and it works now.