i am using Joomla using the JoomFish translation component. This site has german and chinese translations. What i am trying to puzzle out is how you can obtain the .p domain to default towards the german language translation ( which may load if visited as domain.com/p or domain.com/cn ).
Does anybody know a method to do that with maybe .htaccess ( some type of redirect )? Or even PHP? Maybe set some type of session variable in line with the domain (PHP_URL_HOST) ?
At this time i've apache2 setup using the wwww.domain.com because the primary virtual host, and also the .p and .cn as aliases.
Thanks for visiting SO!
Provided, your Apache has
mod_setenvif enabled, add this for your
# Site utilized via "example.p" or "example.cn" SetEnvIf Host ".p$" SITE_LANGUAGE=p SetEnvIf Host ".cn$" SITE_LANGUAGE=zh # URL dependent SetEnvIf Request_URI "^/p/" SITE_LANGUAGE=p SetEnvIf Request_URI "^/cn/" SITE_LANGUAGE=zh
Then, inside your PHP script you are able to query
switch($_SERVER['SITE_LANGUAGE']) situation 'de': // german stuff situation 'zh': // chinese stuff
What should you have had a choose situation in php with different get request?
Something similar to
domain.com/?lang=p along with
$lang = "default" if (isset($_GET['lang'])) if ($lang != "default") p") inside your code.
....could be in which you load your translator or language resource.
Thanks! After adding the htaccess code, all i needed to do is edit /plug ins/system/jfrouter.php at about around 145:
if (isset($_SERVER['SITE_LANGUAGE'])) situation 'de': $client_lang = 'de' $lang_known = true JRequest::setVar('lang', 'de' ) break situation 'zh': $client_lang = 'zh' $lang_known = true JRequest::setVar('lang', 'zh' ) break