CakePhp localization

cakephp 2 multi language example
i18n
i18n po mo
gettext translations
linux i18n
po file
gnu i18n
gettext c++

I'm setting the localization on a website, but I've some trouble.

I've found a tutorial, which does exactly what I need: http://nuts-and-bolts-of-cakephp.com/2008/11/28/cakephp-url-based-language-switching-for-i18n-and-l10n-internationalization-and-localization/ (having directly the language after the hostname).

So I've done everything which is written on this website:

  1. I've generated a pot file, with this pot file, I create three po files(eng, ger and fre) with PoEdit, I translated two tests fields.
  2. I've put those files into app/locale/eng|fre|ger
  3. I've added the route Router::connect('/:language/:controller/:action/*', array(),array('language' => '[a-z]{3}')); in the correct file
  4. I've set the default language: Configure::write('Config.language', 'fre');
  5. I've created three links to change the language: link('Français', array('language'=>'fre')); ?>
  6. I've set the _setLanguage method in my appController(and calling it in the beforeFilter())
  7. I've created an appHelper to don't have to specify everytime the current language

My links are well generated, I don't have any exception/errors, my locals files are readable, but when I go on the template where I try to use variable( ) I just see "testTranslation" as text, no translated text.

Why this isn't working? Looks like it can't find my files but I don't know why :(

Any help would be really appreciated!

Edit: I did some debugging with cakePhp, and it appears that when the method translate of the i18n.php file is called, I receive a $domain = default_ger var. My translations are all in default.po files, and I suppose that he is searching into default_ger.po? why this? how can i force it to read in the default.po file?

Edit: I found something: I had a problem with my controller, I forgot to declare the parent::beforeFilter() in my children controller, then the method in the controller wasn't called and the language was always the german one. After I fixed this, the french and the english are working fine, but the german is still only displaying key and not values that I've in the translation file. This is really weird, I've deleted all files in the cache, deleted my /app/locale/ger folder and copied my /app/locale/fre to /app/locale/ger(without changing anything in files) and this still doesn't work. What can be different?

Try this file layout:

***\app\locale>tree /F
├───eng
│   └───LC_MESSAGES
│           default.po
│
└───spa
    └───LC_MESSAGES
            default.po

Internationalization & Localization - 2.x, First, it's important to understand some terminology. Internationalization refers to the ability of an application to be localized. The term localization  The CakePHP book provides sufficient information on this, I think. If you choose to use just one .po file, you'll wrap your strings with the __() helper. I chose multiple .po files in order to avoid one massive file, so I used the __d() helper so that I could specify which domain (domain == name of the .po file without the .po extension).

I finally found the problem:

My App controller wasn't called, so the German language was always used(because it worked once when changing the language to german, and register it through cookies).

All other languages than german were displaying correctly my values.

So I searched about this problem, and I tried to use "deu" instead of "ger", and it worked!

The locale folder has to be "deu", the language value can be deu or ger.

This is very strange, because for the french, I've a "fre"(FREnch) and not a "fra"(FRAnçais), and this is working.

Anyway, this work with this change

Internationalization & Localization - 1.3, The term localization refers to the adaptation of an application to meet specific language (or culture) requirements (i.e., a “locale”). Internationalization and  CakePHP has one of the coolest features to make application Internationalization & Localization. It’s really easy to translate your application or website into multiple languages with CakePHP 3. Let’s see it. First of all, create a directory Locale inside PROJECT_ROOT/src

cakephp/localized: I18n and L10n related CakePHP code, This plugin contains various localized validation classes for specific countries. Requirements. The master branch has the following requirements: CakePHP 4.0​+. Localizing a CakePHP Application If you build a PHP application using the CakePHP framework, it is easy to localize the application into multiple languages, provided you have the proper translations for those languages.

cakephp/i18n: [READ-ONLY] Provides support for message , for message translation and localization for dates and numbers. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp  This can often prove to be a daunting task, but the internationalization and localization features in CakePHP make it much easier and better one of the advantages of CakePHP is Internationalization and Localization with static translations in gettext style or dynamic translations of model data and It’s a good idea to serve up public content available in multiple languages from a unique url – this makes it easy for users (and search engines) to find what they’re looking for in the

using localization in cakephp, There are a couple of steps: First, set the locale to be used; Create one or more .​po files for that language; Wrap all of your l10n-able strings  Contributing to Localized. If you find that your country is not part of the Localized plugin, please fork the project on Github. Once you have forked the project you can commit your validator class (and any test cases). As soon as you have pushed your changes back to Github you can send a pull request and your changes will be reviewed and merged in,

CakePHP localization, CakePHP: The Rapid Development Framework for PHP http://cakephp.org/. This project uses Transifex to localize their content and reach thousands of people. If you look into the i18n table, are there entries for the other languages? Did you save the values for all the different languages? Also, CakePHP has another method for 'localization', namely the __() function, I think you mean Translation – Katai Jun 7 '12 at 11:47

Comments
  • Did you put the .po files in the LC_MESSAGES directory (/app/locale/eng/LC_MESSAGES/)?
  • Yes I've: /app/locale/eng/LC_MESSAGES/default.po, /app/locale/fre/LC_MESSAGES/default.po and /app/locale/ger/LC_MESSAGES/default.po
  • Same response as Juhana, I've those files in the correct place. :(
  • Strange... your default is French. Why ger is another? I think some cache wasn`t deleted completely. Try to debug in core more.
  • Great to find this, I had trouble with the German locale too. And yes, renaming the folder to 'deu' worked.