Question

I have a question concerning the design of my project's Code. In most cases, it is important to separate content from code (HTML mixed with PHP in bigger apps=No good idea, etc.) but how should I handle things like the text of error messages?

Assuming this one message will be only used in one case/PHP file:

MessageBox( 'Something gone wrong, probably your fault' );

or

MessageBox( Lang::error_usersfault );

(Where Lang is a class located in some config file, full of consts)

  • If you have any experiences (I think every PHP programmer will come across something like this) with things like in the example above - What are they? How do you solve it?

  • What is the better solution?

Was it helpful?

Solution

May be you'll find php extension gettext useful?

MessageBox(_("Have a nice day"));

PHP Manual of Gettext::gettext

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top