Home > cakePHP, PHP, Zend > PHP – internationalization

PHP – internationalization

Internationalization cakePHP!:


*app/controllers/components/local.php > http://cakeforge.org/snippet/download.php?type=snippet&id=29

1. /dev/2/app/views/news/index.ctp

echo _(“Hello world”);

2. xgettext we need in linux/unix , windows !

$xgettext -a src/*.php

*/ or

xgettext –no-location -j -L PHP —from-code=ISO-88591 `find ~/dev/2/app/views/ | grep ctp` `find ~/dev/2/app/controllers/ | grep php` `find ~/dev/2/app/ -maxdepth 1 | grep php`

3. messages.po :

# SOME DESCRIPTIVE TITLE.

# Copyright (C) YEAR Free Software Foundation, Inc.

# FIRST AUTHOR , YEAR.

#

#, fuzzy

msgid “”

msgstr “”

“Project-Id-Version: PACKAGE VERSION\n”

“POT-Creation-Date: 2009-12-08 19:15-0300\n”

“PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n”

“Last-Translator: FULL NAME \n”

“Language-Team: LANGUAGE \n”

“MIME-Version: 1.0\n”

“Content-Type: text/plain; charset=CHARSET\n”

“Content-Transfer-Encoding: ENCODING\n”

msgid “Hello world”

msgstr “”

4. messages.po to messages.mo

$msgfmt messages.po -o messages.mo

/src

/locale/en/LC_MESSAGES/messages.mo

messages.po

es/LC_MESSAGES/messages.po

messages.mo

5. Now mention this

$locale = $language . ‘_BE’;

// default langauge

putenv(“LANG=$locale);

setlocale(LC_ALL, $locale);

// local/messages.mo

$domain = ‘messages’;

// bindtextdomain($domain, “/var/www/html/cake/app/locale”);

bindtextdomain($domain, $_SERVER[‘DOCUMENT_ROOT’] . ‘/locale’);

textdomain($domain);

6. On fly done.

Advertisements
Categories: cakePHP, PHP, Zend Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: