Yii Framework Forum: GetText and Yii - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

GetText and Yii Rate Topic: -----

#1 User is offline   superuser 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 27-December 10

Posted 27 December 2010 - 03:45 PM

Hello :)

Did anybody use gettext in Yii applications?

Is it possible to use:
_("MessageID")

instead of:
Yii::t("Category", "MessageID")

?

And where I can find tutorial about setting up and using gettext with Yii applications?
0

#2 User is offline   mohamadaliakbari 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 14-July 11

Posted 18 July 2011 - 11:16 AM

View Postsuperuser, on 27 December 2010 - 03:45 PM, said:

Hello :)

Did anybody use gettext in Yii applications?

Is it possible to use:
_("MessageID")

instead of:
Yii::t("Category", "MessageID")

?

And where I can find tutorial about setting up and using gettext with Yii applications?


how can i configure yii to use gettext for translation?
0

#3 User is offline   cientistamaluco 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 04-April 12

Posted 07 April 2012 - 01:31 PM

I'm no Yii-ninja (yet :lol:) and like you I had a hole lot of trouble to find help on this, but here's my solution:

I'm using a __() wrapper function (note the double underscore) which makes calls to Yii::t(). I'm using Poedit to generate and edit my .po files. I still haven't managed to get the .mo files to work with Yii, so I'm setting the useMoFile flag FALSE.

I'm storing my .po in protected/messages/pt/messages.po (pt is for Portuguese language)

Hope that helps ;)

protected/config/main.php
// Custom Includes
require_once(dirname(__FILE__).'/../includes/localization.php');

return array(

	'language' => 'pt',

	'components' =>array(
		"messages" => array(
			"class" => "CGettextMessageSource",
			"useMoFile" => FALSE,
		),
        )

        (...)
)


protected/includes/localization.php
/**
 * Wrapper function for Yii::t()
 */
function __($string, $params = array(), $category = "") {
	return Yii::t($category, $string, $params);
}

0

#4 User is offline   acerix 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 22-April 12

Posted 22 April 2012 - 04:45 PM

I just created an experimental component which prepares php's gettext extension (it doesn't use Yii's translation mechanisms or messages at all)

git it here: github.com/acerix/yii-gettext

An example translation file is included which can be used as a template (use poedit to create/edit translations)

Any feedback is welcome, and I am quite new to Yii and git, so use this at your own risk and let me know if I did something wrong.

Cheers
0

#5 User is offline   intel352 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 196
  • Joined: 05-February 10
  • Location:Southport, NC

Posted 13 June 2012 - 11:41 AM

View Postacerix, on 22 April 2012 - 04:45 PM, said:

I just created an experimental component which prepares php's gettext extension (it doesn't use Yii's translation mechanisms or messages at all)

git it here: github.com/acerix/yii-gettext

An example translation file is included which can be used as a template (use poedit to create/edit translations)

Any feedback is welcome, and I am quite new to Yii and git, so use this at your own risk and let me know if I did something wrong.

Cheers



Why not just use this existing extension? http://www.yiiframew...n/pophpcommand/
Need live Yii support? - Join the #yii IRC channel on Freenode!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users