Closed ursulnegrul closed 5 years ago
Hi!
What about the following configuration?
[MULTILANG.languages]
fr = fr-FR,fr
fr-CH = fr-CH,fr
fr-FR = fr-FR,fr
Is that what you mean?
wow, thought it would be more difficult than that :) while(true) { Thank you }
Glad to help :)
Back and ugly .. so my configuration to force en-WW as default is
[MULTILANG.languages]
en-WW = en
en-FR = en
en-IT = en
en-DE = en
en-AT = en
en-CH = en
fr-WW = fr
fr-FR = fr
fr-IT = fr
fr-DE = fr
fr-AT = fr
fr-CH = fr
...plus 'de' and 'it'
Problem now is with the rewrite rules, obviously I have to write [MULTILANG.rules.fr-*]
for each language and alis .. no quick solution for this ? like a default
[MULTILANG.rules.default.fr]
home = /bienvenue
What are you trying to achieve? What's the meaning behind en-DE
and fr-AT
?
The guests can select language and region, en-WW is the default (global), behind the scenes only the language is important 'en' for the appropriate templates.
What does the choice of "region" bring to the user?
Just a flag near his username, no other role, it matters ? :)
It does :)
I don't think you should include the region in the URL if it doesn't bring anything new to the user.
Different URLs indicate different contents. If /en-DE
and /en-AT
display the same content, apart from a flag, then you shouldn't use different URLs. Just call it /en
and handle the region flag with a cookie or a browser Storage.
If you care about SEO, you'd also avoid duplicate content issues.
The project may extend and different content may be provided, a "default" fallback rule would have been useful.
Ok then a solution for you would be to generate language-region combinations using PHP:
[MULTILANG.languages]
en = en-GB,en-US,en
fr = fr-FR,fr
de = de-DE,de
it = it-IT,it
[MULTILANG.rules.fr]
home = /bienvenue
$languages = &$f3->ref('MULTILANG.languages');
$rules = &$f3->ref('MULTILANG.rules');
$langs = array_keys($languages);
$regions = ['WW','FR','IT','DE','AT','CH'];
foreach ($langs as $lang)
foreach ($regions as $region) {
$languages[$lang.'-'.$region] = $languages[$lang];
$rules[$lang.'-'.$region] = $rules[$lang];
}
OK thank you, It works flawlessly.
Big fan of your work guys, thank you. My issue, I was wondering if I could do it in the f3 "way" without a custom route controller I wish to have an optional selected region added in the url For example Is possible to implement ?
/fr/* as /fr-CH/* or /fr-FR/*
where $CH or $FR could be a default $WW (for world wide)