Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6635709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:05:23+00:00 2026-05-25T23:05:23+00:00

I am using PHP , Zend Framework and Zend_Translate (gettext adapter). To edit translations

  • 0

I am using PHP, Zend Framework and Zend_Translate (gettext adapter). To edit translations I use POEdit which utilizes xgettext to fetch strings to be translated.

POEdit (xgettext) will search for keywords to find strings to translate. So, if searching for the keyword translate, POEdit will have no problem finding the 'Text to translate' string when the text is passed to the translate function directly like:

echo translate('Text to translate');

But, in ofther cases strings will be passed to Zend functions that will do the translation for me, calling the translate function with a variable as a parameter:

function SomeZendFunction( $array ) {
    return translate( $array['string'] );
}

...

echo SomeZendFunction( array('string'=>'Another text to translate') );
// translate('Another text to translate');

This will cause POEdit (xgettext) to fail finding the string to translate. In the above example the string I wanted POEdit to find is 'Another text to translate', but since it is not passed directly to the translate function, it will not be found.

So, how to solve the problem?

My current solution is to create a dummy file containing a long list of all the strings that was not found by POEdit:

<?php // Dummy file, only accessed by POEdit when scanning for strings to translate
translate('Text to translate');
translate('Another text to translate');
translate('A third text to translate');
....

But the downside of this solution is that when updating a string, I both need to change the dummy file and find the original string. This will make it more hard to maintain.

Another solution I thought of was adding the translation string to a comment after calling SomeZendFunction (See the above example), but I fail to make xgettext accept it as it ignores comments.

So, anyone knows how to make xgettext to accept strings within comments? Or anyone has any other solution that might be better?

Thanks for any help!

Edit:

I don’t know for what reason I was down voted. But I’ve tried to clarify the question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:05:24+00:00Added an answer on May 25, 2026 at 11:05 pm

    I just got it! By creating a dummy function

    function t($string) {
        return $string;
    }
    
    echo SomeZendFunction( t('Another text to translate') );
    

    I can add this t function to the translate keywords in POEdit. Then I can embed all strings that will later on be translated by Zend into this Dummy function.

    This way Zend will be allowed to translate it, and POEdit will recognize it as a string to translate.

    If anyone has a better solution, please post it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've built a search index using the PHP Zend Framework Search (based on Lucene).
I am trying to build a Connect app using PHP and the Zend Framework.
I'm trying to create a Zend Framework project using PHP 5.3.2 and Zend Framework
I have a PHP MVC application using Zend Framework. As presented in the quickstart,
All, I have a PHP Web application built using Zend Framework and MVC with
I want to write a php application using Zend Framework 2 (just the beta
Here's a scenario; I want to send email using PHP and Zend Framework. Here's
Using PHP 5.3 and Zend Framework 1.11.7 I've been trying to configure the AutoLoader
I am currently working on a big management system (in PHP using Zend Framework,
We are using PHP 5.3 and Zend Framework for a large project, and I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.