the current language is stored in Configure::read('Config.language');, so
for spanish, do this Configure::write('Config.language', 'ro');actually...read this... http://book.cakephp.org/view/1230/Localization-in-CakePHP -- Lep pozdrav, Tilen Majerle http://majerle.eu 2011/2/4 Joffin Joy <[email protected]> > Sir, > > I followed this tutorial below to implement Multilingual Support in > cakePHP: > > I want to get english to spanish translation. > > As i can see it is using i18n but i have no table for i18n in my > website. > ======================================================= > We all know that developing a website in CakePHP is very easy and also > fast. Here’s how to create a multilingual website fast. > > First open app/config/bootstrap.php and set the languages you want > available for your website: > > > Configure::write('Config.languages', array( > 'ro' => array( > 'language' => 'Romanian', > 'locale' => 'rum', > 'localeFallback' => 'rum', > 'charset' => 'utf-8' > ), > 'en' => array( > 'language' => 'English', > 'locale' => 'eng', > 'localeFallback' => 'eng', > 'charset' => 'utf-8' > ), > ) > ); > > I chose english and romanian for this example. > > Now open your app controller (app/app_controller.php – create one if > you don’t have it) and put this function in it: > > > function setLanguage() { > if(!isset($this->params['lang'])) $this->params['lang'] = 'ro'; > $lang = $this->params['lang']; > App::import('Core', 'i18n'); > $I18n =& I18n::getInstance(); > $I18n->l10n->get($lang); > foreach (Configure::read('Config.languages') as $lang => $locale) { > if($lang == $this->params['lang']) > $this->params['locale'] = $locale['locale']; > } > } > > All you have to modify in this function is the first line (that sets > the default language). Change the default language to your chosen one. > > It’s now time to create a route depending on the language. Open app/ > config/routes.php and add this route to it: > > > Router::connect('/:lang/:controller/:action/*', array('lang' => 'ro'), > array('lang' => 'ro|en')); > > Of course that this can change depending on the languages you are > using and their number. You’re a smart boy so you’ll figure it out. > > Now all you have left is to create the language files. Go to app/ > locale and create 2 folders: rum and en. In each of these folders > create another folder called LC_MESSAGES. In the LC_MESSAGES folders > you will now store the language files. Language files can be divided > so it’s easier for you to store the translations ( .po files ). > > For example, you can create a login.po, register.po, account.po and > default.po. > > In the language files you have to set the message id and message > string. > > English > > msgid "hello" > msgstr "Hello" > > Romanian > > msgid "hello" > msgstr "Buna ziua" > > And now to echo these strings on your website you have to remember the > string id and the name of the language file (.po) it is stored in. > Example: > > > <? > __d('default', 'hello', true); > ?> > > This will take the string with the id “hello” from the default.po file > and echo it. And true means that it will echo the string. > Good luck > > ========================================================= > > But i am not able to get the translation for spanish working.... > > any help would be very helpful. > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > [email protected]<cake-php%[email protected]>For > more options, visit this group at > http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
