Comments (2)
Hey Thibault, glad you like it =)
As for looping through the URLs of the current page translations, you can use the plugin alias function, which is a superset of the framework's own alias function, taking one extra $lang
parameter.
In the demo, it is basically achieved like this:
$f3=Base::instance();
$ml=Multilang::instance();
foreach($ml->languages as $lang)
echo $ml->alias($f3->ALIAS,NULL,$lang);//<-- translated page path
As you can see, the 2nd parameter is null, because the demo routes don't hold any dynamic token.
If you have dynamic tokens, you need to fill in the 2nd parameter. And the way to go depends on your app's architecture:
- If routes parameters are identical for each language (e.g:
/en/area/web
and/fr/zone/web
share a common language-independantweb
token), then just use$f3->PARAMS
as a 2nd parameter, as it holds the current language parameters. - If routes contain a translatable slug but are anyway identified by a numerical index (e.g:
/en/blog/8/hey-dude
and/fr/blog/8/salut-gros
are translations of the same page identified by the tokenid=8
), then you can also use$f3->PARAMS
as your app will naturally performs appropriate redirections (/fr/blog/8/hey-dude
=>/fr/blog/8/salut-gros
). - If routes contain translatable slugs with no common index, then each controller has to generate its own translated URLs, because only it knows the values of the translated slugs.
Hope it makes sense ^^
from f3-multilang.
Hey Florent,
Thank you for your very clear answer. It works like a charm ! 👍
Your work is very appreciated.
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
- Generate equivalent URL in other languages when tokens are present HOT 2
- 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
- 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.