Hey,
I'm (finally) adding language support to my open-source PHP CMS and after much thinking I've decided to go with Gettext for translations/locale. I've got it working great, however I have to create the Pot manually!
The way I am doing Gettext is different to your normal:
Instead, as I using a custom-built MVC Framework - in my View files I have tags like the following:Code:echo _( 'Hello over there!' ); // Or echo gettext( 'Hello over there!' );
Then in my view class it simply uses reg-ex to get every language 'tag' - here is the code if you're interested:Code:<p>{L_[Hello over there!]}</p>
As my View files also allow for PHP code, I do in _some_ of them have:Code://--- // language_tags() provides the Zula framework with language support for // views. It finds all tags that are in the format of {L_[phrase]} and replaces // then with the correct translation // @param string $content // @return string //--- private function language_tags( $content ) { Registry::get( 'locale' )->update_text_domain( 'messages', Zula::get_dir( 'controllers' ).'/'.$this->module.'/locale' ); preg_match_all('@{L_\[(.[^\]]*)]}@', $content, $tags); #Zula::debug_print( $tags ); if ( !empty( $tags[0] ) ) { foreach( $tags[0] as $key=>$tag ) { $tag = trim( $tag, '{} ' ); $value = gettext( $tags[1][ $key ] ); $this->assign( array( $tag => $value ), false ); } } }
Now, I have to create the pot files manually because xgettext only looks for _() or gettext() for it to generate the pot files from, and this just wont work with how I am doing it.Code:<?php echo gettext( 'Hello over there!' ); ?>
I am wondering if there is a way to ... change how xgettext searches for the strings it needs, so I don't have to do the very painful process of creating my pot files manually!
Thanks!



Adv Reply

Bookmarks