\nWe would want to have this: example.com/bel/controller/action
\n\nIs it possible to work with 'dut', but show 'bel' in the url? Or is there a way to add a 'custom' language?
\n","author":{"@type":"Person","name":"Brieneke"},"upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"You need to use the standard code for the language, the Belgian language does not exist (there are three official languages, Dutch, French, German). But if you have localized content for a particular country, then you should use the country code.
\n\nThere are countries that have more than one official language (Belgium, Switzerland, Spain, Bosnia and Herzegovina, ..). In this case you should use a combination of language-country code as you can see here
\n\nYour URL should look like:
\n\nfor the German country and language
\n\n\n\n\nwww.example.com/de/
\n
for the Netherlands and the Dutch language
\n\n\n\n\nwww.example.com/nl/
\n
for Belgium and the official language
\n\n\n\n\nwww.example.com/nl-be/
\n
\n www.example.com/fr-be/
In your AppController beforefilter put a switch statement, where you specify the rules for the language and localized content
\n\nEDIT (add example)
\n\n AppControler.php\npublic function beforeFilter()\n{\n switch ($this->params['lang'])){\n // for nederland\n case: 'nl':\n Configure::write('Config.language', 'dut');\n $this->set('for_country','nl');\n break;\n // for germany\n case: 'de':\n Configure::write('Config.language', 'deu');\n $this->set('for_country','de');\n break;\n // for belgium / dutch speakers\n case: 'nl_be':\n Configure::write('Config.language', 'dut');\n $this->set('for_country','be');\n break;\n // for belgium / french speakers\n case: 'nl_fr':\n Configure::write('Config.language', 'fr');\n $this->set('for_country','be');\n break;\n // default english\n case: 'en':\n Configure::write('Config.language', 'eng');\n $this->set('for_country','us');\n break;\n }\n}\n\nPostsController.php\n\npublic function index ()\n{\n // find all posts for country, example only content for Belgium in french\n // example.com/nl_fr/posts\n $options = array(\n 'conditions' => array(\n 'Post.localized' => $for_country\n )\n );\n $posts = $this->Post->find('all',$options);\n .......\n}\n
\n","author":{"@type":"Person","name":"Salines"},"upvoteCount":1}}}Reputation: 45
We succesfully build a multiple language (NLD/DEU/ENG) cakephp website (cakephp 2.3.6). And now our client wants us to add the belgium language to his website. The code list doesn't contain a code for the Belgium language. it's either dut (Dutch; Flemish) or fre (French).
But instead of having this url: example.com/dut/controller/action
We would want to have this: example.com/bel/controller/action
Is it possible to work with 'dut', but show 'bel' in the url? Or is there a way to add a 'custom' language?
Upvotes: 1
Views: 217
Reputation: 5767
You need to use the standard code for the language, the Belgian language does not exist (there are three official languages, Dutch, French, German). But if you have localized content for a particular country, then you should use the country code.
There are countries that have more than one official language (Belgium, Switzerland, Spain, Bosnia and Herzegovina, ..). In this case you should use a combination of language-country code as you can see here
Your URL should look like:
for the German country and language
www.example.com/de/
for the Netherlands and the Dutch language
www.example.com/nl/
for Belgium and the official language
www.example.com/nl-be/
www.example.com/fr-be/
In your AppController beforefilter put a switch statement, where you specify the rules for the language and localized content
EDIT (add example)
AppControler.php
public function beforeFilter()
{
switch ($this->params['lang'])){
// for nederland
case: 'nl':
Configure::write('Config.language', 'dut');
$this->set('for_country','nl');
break;
// for germany
case: 'de':
Configure::write('Config.language', 'deu');
$this->set('for_country','de');
break;
// for belgium / dutch speakers
case: 'nl_be':
Configure::write('Config.language', 'dut');
$this->set('for_country','be');
break;
// for belgium / french speakers
case: 'nl_fr':
Configure::write('Config.language', 'fr');
$this->set('for_country','be');
break;
// default english
case: 'en':
Configure::write('Config.language', 'eng');
$this->set('for_country','us');
break;
}
}
PostsController.php
public function index ()
{
// find all posts for country, example only content for Belgium in french
// example.com/nl_fr/posts
$options = array(
'conditions' => array(
'Post.localized' => $for_country
)
);
$posts = $this->Post->find('all',$options);
.......
}
Upvotes: 1