How to name files using gettext translations with Zend Framework - zend-framework

I'm using gettext translation adapter in a Zend Framework projekt. But I'm wondering what's the best practise when naming and placing these translation files within my project?
At first I had APPLICATION_PATH/languages/sv_SE.po (and sv_SE.mo)
But then I read about the auto searching features of Zend Framework and started wondering if it would be better to have the languages in subfolders. But the structure APPLICATION_PATH/languages/sv_SE/sv_SE.po and APPLICATION_PATH/languages/en_US/en_US.po didn't feel quite natural. Using array adapters ect it have felt easier to come up with a good naming conventions... But what is the best practise when it comes to using gettext translations in Zend Framework? Is it most common to have all translations in a single file or should one use something like
APPLICATION_PATH/languages/en_US/admin.po
APPLICATION_PATH/languages/en_US/forms.po
APPLICATION_PATH/languages/en_US/othercrap.po
Feels like this apporach might make it tedious when scaning source for strings to translate since one would have to open several files etc.

I ended up using
APPLICATION_PATH/languages/en_US/admin.po
APPLICATION_PATH/languages/en_US/forms.po
APPLICATION_PATH/languages/en_US/othercrap.po
which has worked fine.

Related

Translate Zend Framework website like WPML in Wordpress

I want to know if it's possible to translate a Zend Framework 1 website in a manner similar with the one implemented by WPML for Wordpress.
What I want is to make an application that can scan the website source code for translation variables, then store them in a database or a .po file.
Also please note that I am not interested in switching to another framework or using only Wordpress for my website but in a method of simple and easy translation for someone without programming skills.
What you need is:
Zend_Translate with gettext adapter
Zend_Registry
Poedit
More info here.
PoEdit http://www.poedit.net/download.php
I have used this software to create .mo files for Zend_Translate gettext adapter in one of my ZF projects.

Zend Framework and fuelphp

I wanted to know if it was possible to use zend framework libraries from zend 1.11 in fuelphp? fuel looks nice and I started looking at it as I believe its the next logical step for any CI developer.
Is there any site or a howto for using zend library with fuel?
Thanks
It really depends on what portions of Zend Framework you want to use. Some parts, e.g. Zend_View are tied into the MVC-part of the framework, but components like Zend_Pdf or Zend_Service_* have only few dependencies and should work fine in other frameworks as well.
What you should do is check out the Reference Manual to see what other components are required by the component you are trying to use. And then put them in a library folder. Alternatively, just put the whole Zend Framework in a folder if you don't mind carrying the dead weight with you.
I've been using ZF-components standalone and found that it's useful to add it to include_path as you would when using ZF as MVC-framework, because some ZF-classes are instantiated dynamically, i.e. not via require_once and that won't work without the folder containing Zend/ being in the include_path.
Finally you have to add the folder to your autoloader, this should be as easy as:
Autoloader::add_namespace('Zend', __DIR__.'/path/to/Zend/library');

How can I keep just the required files in zend framework for my application?

I'm not sure where to ask this, but frankly I'm using some libraries from the zend framework but at this moment have the entire framework in my library folder. Is there any script or exe out there which go through the application and tell which files are not being used and which are. Theres loads of includes and easy loading going on there.
The files that are included via require_once in the Zend Framework code are mostly required only if they are used.
But if you want to be 100% sure that only the really used ones are loaded (on the fly), use the autoloader in combination with a script that strips all the require_once, as shown in the "Class Loading" part the official performance guide. There is a "How can I eliminate unnecessary require_once statements?" section. And this is a well know ZF optimisation technique, so it should be done anyway.

Zend_Layout and/or Smarty

I am new to Zend Framework, but planning to create quite a complex project using it.
I was looking at the view options for Zend Framework. There is one with Zend_View and Zend_Layout and also template engines like Smarty can be integrated with it.
Now I would like to know, do they serve the same purpose? Like I can either use Zend_Layout or Smarty or is it better to use both?
I've worked on two large scale Zend projects. We don't use a separate layout engine, we just use the built in Zend_View.
Layering Smarty on top of Zend wouldn't serve much purpose (imo, would like to see some alternative experiences though)
I have seen lots of benefits of using smarty for nearly 10 years. First of all, smarty restricts template designers to use small set of functions which are related to view only. This will make easier to manage template files and will create a layer of security. Using PHP on view layer allows quick solutions with PHP and can create great mess. Smarty is compiled and there is nearly no performance loss. Syntax is more concise than PHP views. With Smarty 3 "template inheritance" features saved lots of time, which cannot be easily implemented with PHP classes.

How to prune Zend Framework?

I wouldn't use most of the classes from Zend Framework, that's why I'm looking for the thinnest possible ZF configuration.
Is there a better way of finding what I really need other than deleting the whole library/Zend folder, then putting back files based on the error messages that I receive?
I have not used it myself, but http://blog.fedecarg.com/2009/02/01/zend-framework-automatic-dependency-tracking/ may be what you are looking for.
Hm...
There is a lot of information about Zend Framework on SO and with a little bit of reading you would have found the answers to your question
You would also find the answers to your question by just reading the introduction to Zend Framework on the Zend Framework website.
No, that's not how you'll do it. Zend Framework, unlike most/all other PHP frameworks, is rigidly loosely coupled. You can use every component stand-alone. You can only use the loader, or only Zend_Translate. Or you can just use the MVC modules, or Zend_Db, etc.
Of course if you use Zend_Form and want to validate or filter the input, you'll need Zend_Validate and Zend_Filter. But you'll know that because you'll instantiate objects. So just copy into your empty library folder the modules you need. Or even better, copy everything in! A) you won't regret it. B) disk space is not your problem.
What I would do is set up the plugin loader cache and then purge all files apart from the ones called within the automatically generated include file.
zend.loader.pluginloader.performance
I hope it makes sense... :o)