0

I'm trying to find a way to use gettext and friends without depending on the official gettext module, which I've found to not be installed everywhere and sometimes yields different results depending on the OS and server configuration.

Kendall Hopkins
  • 43,213
  • 17
  • 66
  • 89

3 Answers3

3

I just make a library which can auto load the po file, change languages and translate all text between {t} and {/t} in the view, I posted here in case some one want to use it instead calling the gettext function in the view:

http://www.chuongduong.net/page/15/codeigniter-gettext-with-smarty-or-parser-template-without-php-code-in-view.html

The view code might be:

<html>
<head>
<title>{blog_title}</title>
</head>
<body>

<h3>{blog_heading}</h3>
{blog_entries}

<h5>{t}Title is{/t}  {title}</h5>

<p>{t 1="<b>" 2="</b>"}Click here %1to see%2 me{/t}{body}</p>

<p>{t 1="{id}" 2="author"}The id is: %1 wrote by %2{/t}</p>

<p>{t 1="<a href=\"link here\">" 2="</a>"}Please lick on me%2{/t}</p>

{/blog_entries}

</body>

</html>
user1442894
  • 170
  • 1
  • 8
1

There are a few userland php implementations of the gettext functions.

  • One is gettext.php (I wrote that, PD, but not very well tested)
  • And the other one php-gettext (GNU GPL, quite widespread)
  • The Zend Framework also provides an adapter for gettext. Not sure if it relies on the native PHP functions; but it might very well come with its own reimplementation.
mario
  • 144,265
  • 20
  • 237
  • 291
  • I'm getting an error from upgrade.php download link: `unicorn Could Not Connect to Database:` – Kendall Hopkins Apr 12 '11 at 02:15
  • Oh, interesting; BerliOS is down. Here's an alternative link: http://include-once.org/upgradephp-17.tgz – mario Apr 12 '11 at 02:21
  • Unicorn could not connect to database? – Pekka Apr 24 '11 at 10:30
  • 1
    @Pekka: Well it's apparently not cloud-based. It runs on good old Unicorn blood. Seeminlgy that's out, so that explains the downtime (TWO WEEKS! time for github) – mario Apr 24 '11 at 11:24
0

I ended up forked PHP-gettext (not the GNU GPL one) and modifying it to work as a transparent drop in. It creates a very simple one line fix for a missing gettext module.

require( "PHP-Gettext/Autoload.php" );
Kendall Hopkins
  • 43,213
  • 17
  • 66
  • 89