<?php
$pageurl = "http://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
$pageurl_noslashes = str_replace("/","",$pageurl);
$lang = substr($pageurl_noslashes,-3);
echo $lang;
?>
{exp:channel:entries channel="products" limit="10"}
<p>Product title: <span>{if title<?php echo $lang; ?>} {title<?php echo $lang; ?>} {if:else} {title} {/if}</span></p>
{/exp:channel:entries}
I am hacking expression engine to return the appropriate language variables.
I am aware that the way I am getting the language code (fr/en/etc...) is far from ideal, which is why I need advice on it :)
What happens:
- host.com/products/item/_fr/ — loads French
- host.com/products/item/_en/ — loads English
- host.com/products/item/ — loads English (after failing the if condition)
So in essence, it does exactly what I want, however I feel that it is not the best way to do it.