Internationalization and Localization in CakePHP 2.1 - cakephp

I am building a dual language app in CakePHP 2.1.x because of the great reviews of Cake's "built-in" localization features. However, I am wrestling with getting this powerful feature to work.
I know that this topic has been tackled for previous versions of Cake (here, here, here, and here), but it hasn't been solved for Cake 2.x. I am also referencing these articles in the cookbook (yes, I've read the manual):
http://book.cakephp.org/2.0/en/core-libraries/internationalization-and-localization.html
http://book.cakephp.org/2.0/en/core-libraries/behaviors/translate.html
Couple of things -- I do not want to do separate subdomains for each language. Instead, I prefer URL based language switching with the click of a button (in this case, a flag icon). The site will be actively maintained, so the content needs to update dynamically. Asking the client to maintain two separate sites/databases is out of the question.
I have Translate behavior set up for my PostModel, but I can't tell if it's working. I also initialized I18n by running I18n in the console, have confirmed the database tables exist, have set up my .po files, and have wrapped all my content in __(). However, when I change the default language in my browser to French, the site remains in English.
I've tried the P28n Component, but I think it's outdated for Cake 2.x. I also tried URL-based language switching based on this nuts-and-bolts-of-cakephp article, but apparently it's incompatible with the new CakePHP API.
Can anyone point me in the direction of a tutorial or instructions that work with CakePHP 2.x? One not already referenced here?
Update: I found this article: http://www.localizingjapan.com/blog/2011/11/10/localizing-a-cakephp-application/comment-page-1/#comment-7467. Does anyone know where you place the code for CakeSession::write('Config.language', 'fre'); and setlocale("LC_ALL", "fr_FR.utf8");?

Simply put the code in AppController::beforeFilter() and set the values based on however you retrieve the language, from a post request or a part of the URL.

Related

Show posts for default language if switched to language that has no posts added yet

I have a site that uses Polylang plugin for languages. I have two languages, one default and another. All posts currently are added using default language, but when I switch to another language, nothing has been showing up. I would like in this case show content from default language instead and use another language when it will be added. Is it possible to make this happen?
No, it is not possible to fallback to the default language using the Wordpress Polylang plugin. From https://wordpress.org/support/topic/fallback-to-default-language/ :
This is not possible. There is no feature like this.
The only way to do this is to “translate” the post and page but to add the default language content instead of the translated content. So technically the post and page is “translated” but the content is still the same.
However, there seems to be a Wordpress plugin that does offer this functionality. The project is not very active, however. Perhaps you could pick up a clue on how to approach this problem from its source code.

In Drupal should I use content-types or database abstraction layer?

I posted a question on the Drupal forum about whether I should build my database in Drupal using content-types or the database abstraction layer and schema module: [here][1]
Any advice would be greatly appreciated.
[1]: https://drupal.stackexchange.com/questions/98020/should-i-use-content-types-or-database-abstraction-layer
I'd recommend using content types.
For a PHP coder, sometimes using the Drupal User Interface to build things feels non-intuitive, but in the long run you're going to benefit a lot from doing things "the drupal way.
Once you reverse engineer your need into a content type and all it's associated fields, install the modules that provide those field types and set things up, you'll start to see the benefits.
Validation on all the data-entry froms will already be done for you.
Multiple display modes are available for your data (email addresses can be shown with or without mailto: links, images can be shown using any of Drupal's image styles)
Integration with other Drupal modules already exists, and will be supported (almost anything built with fields is available to views)
By writing your own schema you'll need to handle all these things yourself (and more), and not just once, but you'll need to maintain all that custom code over time.
Learn to leverage the community and all the great work that's been done already, you'll save yourself time in the long run :)
What i see you are going to have shop site.
You may tray this:
https://drupal.org/project/commerce_kickstart
, i've found it usefull once. It's drupal distribution with nice themed shop rady to use straight forward.
And of course do it with content type + views + entity reference modules.
Here is a link to a comment that answers the question I asked. It backs up what arpitr outlined in their answer on the orignal post on the drupal forum, whose answer is also in agreement with jenlampton's suggestion above.
https://drupal.org/comment/7848011#comment-7848011
I will implement my system using node entities until the need arises to build a custom entity (if it ever does).
The top answer in this forum give a good way to evaluate whether to use nodes or custom build an entity:
https://drupal.stackexchange.com/questions/22586/when-is-it-appropriate-to-create-an-entity-versus-just-adding-a-new-content-type

how to add multiple languages to an English website

I am trying to add two additional languages to my website - Chinese, Japanese. User inputs could be in native language, in English or be mixed. E.g. search by product name. Likewise output can be all-English or be in mixed languages, depending on a user's preferences. I already have applicable translations so that is not a problem. It is a data intensive site. It uses web APIs to fetch JSON data objects, and uses angular and backbone, and jquery.
I will appreciate if you possibly refer me to some good books or pages that provide guidance for building multilingual sites. Are there any particular web standards that must be followed by websites and by browsers?
Googling yields a ton of links, but the discussion appears centered around specific packages such as wordpress, joomla, .net, drupal, etc. and appears more around automated translations. It still left me confused about the basics requirements of multilingual sites as I do not use any of these packages.
Thanks a lot.
ps: if you need to leave me a -1, np. But I would very much appreciate a comment as to why - so that it doesn't appear as if you just vented and offered me no opportunity for improvement.
Wells... when i need to build a bilingual website i just use a language selector menu and build the whole website in 2 languages (i think this way its more professional) cause usually translators doesnt 100% translate correctly and at the end you just get a bunch of stuff making no sense.
Maybe you could use Google Website Translator gadget for what you trying to do?? its paid service tho, you could use also the plugin for Wordpress http://wordpress.org/plugins/google-language-translator/
Or use the Google Ajax Language API https://code.google.com/p/jquery-translate/

CakePHP: Internationalizing a web application - Design and Examples?

I have a web application built using CakePHP framework and now I am in the process of internationalizing it. I started with the base set-up as outlined in the below article -
http://puskin.in/blog/2010/08/cakephp-manage-multiple-language-in-application/
and also add little bit of customization based on my previous question -
CakePHP: Internationalizing Web Application
To completely internationalize my web app, I would need to translate my drop-down/look-up content as well, like - categories, favorites, countries, bucket list etc.
What is the best way to design my tables and CakePHP samples? Can someone explain with a simple example and classes? Links or articles?
Lets say we have something like -
A user can create multiple posts, and each post has a category [science article, match article] etc in the drop-down and same we need to internationalize drop-down as well.
Two hints:
Read the manual of cakephp.
Look into the code of a available application (maybe croogo)
My open source project is translated.
It call CandyCane. A port of Redmine into CakePHP.
I also imported translation files from Redmine, so CandyCane supports numbers of languages from the beginning.
https://github.com/yandod/candycane
It might be helpful for you.

Expressionengine multi language

my final job on my current site is trying to add multi language capability to my EE site.
The steps I followed on the wiki here: http://expressionengine.com/wiki/Multi_language_site_alternative
were straight forward enough and despite having to search around for a bit of help when the htaccess didn’t work, I now have (I believe) a working subfolder on my site: /en . If i point my browser at http://mysite.com/en/template_group/view/title a page comes up fine.
The next step however of using en_custom_field doesn’t seem to work.
I have the feeling that the /en folder is an exact mirror image of the normal site.
For example in my embedded header template I have lang=”{country_code}” but when I view source in my /en subfolder it shows as “fr” (which is the default language)
Also, other curious things are happening - in the /en subfolder, my current dropdown menu (a navee menu) has been replaced by my old menu which is no longer in my template (!) I have literally no idea how this is happening…
Would appreciate any help from anyone who's seen something familiar thanks!
Are you using ExpressionEngine 1.x or 2.x ? The instructions in the wiki really only work for 1.x (and not even very well for that).
There are several free and paid addons that can help you do this. For EE1, I'd recommend Transcribe: http://eeharbor.com/transcribe
For EE2, you might try Berkol's MultiLanguage addon, found here: http://devot-ee.com/add-ons/multi-language-support -- it requires you to create custom fields, but handles all the URL nonsense pretty nicely as far as I can tell.

Resources