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 6666699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:51:21+00:00 2026-05-26T02:51:21+00:00

I am working on a project build on the Zend Framework. I’m using Zend_Translate

  • 0

I am working on a project build on the Zend Framework. I’m using Zend_Translate to do my translations, but I want to keep the amount of extra code in the front of my application (views) as minimal as possible. Translation of a text should look like this:

echo __("Text to translate");

Using a view helper isn’t doing it, because then I get:

echo $this->__("Text to translate");

This would mean I have to declare a global function somewhere, that calls for Zend_Translate to do the rest of the magic. Because I want the project to stay as clean as possible I’d like some suggestions on where to put this function.

I have considered including a file with my global function inside of the _initLocale() in the bootstrap.

Basically my question is: am I now violating all the holy MVC principles, or is this the right way to go?

  • 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-26T02:51:22+00:00Added an answer on May 26, 2026 at 2:51 am

    This is actually not an easy question to answer. Of course you’re violating some principles of OOP because you’re basically punctuating your objects with hundreds of little wholes where there should be just one. You should be injecting the translation object into your controllers and views once and then call $this->__(). This is also easily done by creating an intermediate layer between Zend_Controller_Action and your own controllers. BUT… translation is a very specific case and I don’t see much potential harm coming from your solution. The Translation method is not likely to change its logics and if you need to rename it, finding and replacing two underscores followed by a bracket will most probably not yield anything else than translated strings… then again that use of ‘most probably’ is a smell already.

    Summary: It seems more or less ok but I still wouldn’t do it, especially if it’s a software of some meaning with an expected life span of some years.

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

Sidebar

Related Questions

I'm actually using Doctrine2 within a Zend Framework project. I'm build an API to
I am using PHP and the codeigniter framework for a project I am working
I'm currently working on a build system in Phing that takes a Zend Framework
I'm working on a class project to build a little Connect4 game in Java.
I'm working on an upgrade project and build management is done in Maven 1.0.2.
The project I'm currently working on generates 30+ warnings each time it gets build.
I'm working on a new project with a full ANT build. I use eclipse
I'm trying to automate the build of the project I'm working on. My ultimate
We're working on a project here in Visual Studio 2008. We're using the built-in
I am working on a Zend project and it has been well over 12

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.