Multilingual. Links like /<lang>/<presenter>/<action>/{action method args devided by slash}

Notice: This thread is very old.
zalizko
Member | 7
+
0
-

Subj. Is abybody know how to do it? my patience is coming to an end :)

zalizko
Member | 7
+
0
-

one more thing. links on language should be in footer or header and user should stay on the same page after language switching

zalizko
Member | 7
+
0
-

usualliy I write the code after after understanding how it works.
, but with Nette it's not easy, because clean documentation is not enought..
I tried at random, working or not )) and it works:

app\router\RouterFactory.php:

<?php
class RouterFactory {

    /**
     * @return \Nette\Application\IRouter
     */
    public function createRouter() {
	$router = new RouteList();
	$router[] = new Route('<lang>/<presenter>/<action>[/<id>]', array('lang' => 'en', 'presenter' => 'Homepage', 'action' => 'default'));
	return $router;
    }

}
?>

app\templates\@layout.latte:

<?php
// ...
<body>
	{foreach $flashes as $flash}
	    <div class="flash {$flash->type}">{$flash->message}</div>
	{/foreach}

        {include content}

        <div id="footer">
            <a n:href="homepage:default">Home</a>
            <div id="languages">
                <div>Languages:</div>
                <ul>
                    <li n:foreach="$languages as $language">
			<a n:href="default lang => $language">{$language}</a>
		    </li>
                </ul>
            </div>
        </div>
    </body>
// ...
?>

now need to understand how to do a link on current presenter and current action. link on current presenter possible to do by omitting presenter in template <presenter>:<action>, but how to pass current action …

zalizko
Member | 7
+
0
-

greate! I have found solution!!!
it's:

<?php
<div>Languages:</div>
<ul>
    <li n:foreach="$languages as $language">
	<a n:href="this lang => $language">{$language}</a>
    </li>
</ul>
?>

‘magic’ word this halps!

however, WHERE IT'S IN DOCUMENTATION?!?!?!??!

topic closed.

echo
Member | 134
+
0
-

zalizko wrote:

‘magic’ word this halps!

however, WHERE IT'S IN DOCUMENTATION?!?!?!??!

topic closed.

It is mentioned in the text here (“Special case is linking to itself, when we'll write this as the target.”):
https://doc.nette.org/…4/presenters#…

… but it is easy to overlook and should be highlighted