basz / SlmLocale

Auto detection of locale through different strategies for Zend Framework 2
Other
68 stars 34 forks source link

Mixing host and URI path strategies #47

Open glen-84 opened 10 years ago

glen-84 commented 10 years ago

Is it possible to not alter the URI path if a host is matched?

f.e. If you have the following domains:

domain.com domain.de

I need two things:

  1. Don't add "/de/" to domain.de (as the locale is based on the TLD)
  2. Any non-de locales on domain.de should redirect to domain.com/locale

I think that there needs to be some way of indicating the "primary" domain when using the URI path strategy. The path segment will then only be added if you're on that primary domain (.com in this case).

juriansluiman commented 10 years ago

I think this is the best implemented as "filters". Just thinking out loud, but you might want to have a callback which can be used to check during detect/found/assemble which returns true or false depending on your specific situation.

In that case, you could attach a filter callback to the uri uri path (found) which returns false when the domain is domain.de. In that case, the /de is not prepended to the path. What are your thoughts?