<?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}
式エンジンをハッキングして、適切な言語変数を返しています。
言語コード (fr/en/etc...) を取得する方法が理想からかけ離れていることは承知しています。そのため、アドバイスが必要です:)
何が起こるのですか:
- host.com/products/item/_fr/ — フランス語を読み込みます
- host.com/products/item/_en/ — 英語を読み込みます
- host.com/products/item/ — 英語を読み込みます (if 条件が失敗した後)
本質的に、それは私が望むことを正確に行いますが、それを行うための最良の方法ではないと感じています.