Is there somewhere a good tutorial on how to build a multi-language site (in cakephp 3.x) ?
There are several questions about this topic but no real answer.
Thank you for helping.
Is there somewhere a good tutorial on how to build a multi-language site (in cakephp 3.x) ?
There are several questions about this topic but no real answer.
Thank you for helping.
Can we help you with some specific problem?
Well, I do not have a specific problem.
I have been building web apps / sites with cakephp since 1.2.x but only single language (french).
A new client is asking for several languages in a new website.
What I would like to know is what are the best practices ?
Should I create everything 2, 3 or more times ? Should I use a joining table ?
How to localize things that are customized ?
I just don’t know where to begin ?
not sure if this is what you looking for, here’s CakePHP3 translation and localization official documentation.
https://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html
https://book.cakephp.org/3.0/en/orm/behaviors/translate.html
hope it might help for you to start
try this: https://github.com/ADmad/cakephp-i18n
Thank you for replying.
donnidani : the first link is about translating strings and I already read this page. It’s not about methods and organization. The second link seems interesting and I missed it. I’ll take a look.
Thanks again all.
Hello!
There is my example simple multilanguage system (full source).
Define native language in config/app.conf <- ‘defaultLocale’ => env(‘APP_DEFAULT_LOCALE’, ‘pl_PL’), (polish is nativa lang of app).
In Template->Laypout->Default place switches with flags, for example:
<?php //if (isset($lang) && ($lang == 'pl_PL')) { echo 'In src/locale (create if not exist), place localisations folders, for example: en_US, de_DE, pl_PL
create single file named: default.po
in Controllers, Views: __(‘Środowisko serwera’) <- this can be translate to “Environment”.
in src/Controller/AppController.php create 2 functions:
public function changeLang($lang = ‘pl_PL’)
{
$this->Cookie->write(‘lang’, $lang);
return $this->redirect($this->request->referer());
}
public function getLang($lang = ‘pl_PL’)
{
$lang = $this->Cookie->read(‘lang’);
if (empty($lang)) { return ‘pl_PL’; } else return $lang;
}
Regards
Leszek
i did some multilanguage sites before and there are few tips i can give you:
__x()
and __dx()
__()
- ie. ToS_en_GB.ctp
SKyer, Graziel
Thank you very much for sharing.
This is very helpful.