Comments (2)
That's because you're calling the alias()
method with the 2nd parameter not set, which is the same as passing the current route parameters.
You need somehow to pass the localized parameters to the function.
One way of doing it is to create a template filter which localizes the parameter before calling the alias()
method.
E.g:
// index.php or bootstrap file or controller hook method
$tpl = Template::instance();
$tpl->filter('url', function($name, $params=NULL, $lang=NULL) use($f3, $ml, $db) {
$params += $f3->PARAMS;
// your custom params localization here:
switch ($name) {
case 'gamessection':
// localize the term contained in $params['section'] from $ml->current to $lang
// e.g:
$sql = 'SELECT target.slug FROM sections source LEFT JOIN sections target
ON source.id=target.id WHERE source.slug=?
AND source.lang=? AND target.lang=?';
if ($res=$db->exec($sql, [1=>$params['section'], $ml->current, $lang])
$params['section'] = $res[0]['slug'];
break;
// etc.
}
// end of custom localization
return $f3->BASE . $ml->alias($name, $params, $lang);
});
<!-- template file -->
<a title="GamesSite - English" href="{{ @ALIAS, null, 'en' | url }}">English</a>
from f3-multilang.
Thanks for your detailed answer. I'd left the 2nd parameter as null because I had no way to fill it in correctly as yet. I'll look into making a custom filter as you suggest.
Cheers
from f3-multilang.
Related Issues (20)
- Can't add both /admin and /login to either global ignore list or exclusion for a lang HOT 3
- Manually set language is ignored? HOT 3
- Default language hidden from url HOT 7
- Lang selector as not a part of the URL HOT 4
- Where i have to define @dict HOT 13
- Rerouting for obsolete pages HOT 2
- alias with params HOT 1
- How can I add the region ? HOT 12
- Usage with f3-middleware HOT 2
- Migrate issue with latest F3 changes HOT 2
- OnReroute doesn't work with newest F3 update HOT 3
- Skip $global routes when $migrate is false. HOT 2
- Can't handle two different aliases with same route endpoint HOT 2
- Reroute bug? HOT 4
- Option for turn off rewriting in primary language HOT 3
- Detecting language not working properly HOT 5
- Will multilang be update to be used with Fatfree v3.5? HOT 4
- Dynamically change the language HOT 2
- I can't seem to make multilang to work with the backend of fabulog HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from f3-multilang.