For multi-language PHP application assume labels/phrases is going to be converted into multiple languages. Individuals labels can be put in language specific files (e.g. one file per language) or could be loaded right into a database, to ensure that the application can access them if needed.

Now you ask ,, in the performance perspective, what's the better approach?

In my experience it seems when labels have been in the database it's less data to load (I'm able to only request labels required for just one page) and may easier built admin tools for translations. However, it seems that lots of applications and frameworks available use flat files for your purpose (e.g. phpMyAdmin, CakePHP, etc.)

Loading data from the file is way faster than loading from the database. You simply shave many layers of abstraction involving the data as well as your application. Should you profile the application for performance, you will find that database access is generally among the slowest operation.

If you won't want to load all of your localization string any time you display something, a person always has the choices to insert them in differents files. For instance, a "global" apply for string displayed everywhere, along with a localization file specific towards the page/section your on.

Nevertheless, just like anything concerning performance, do not take my word for this, but mesure it yourself. Maybe inside your particuliar context, together with your particuliar application, a database is going to do all right.

Database enables you to definitely choose just the record you are thinking about...
But :

  • You have to place /update the information towards the database every time you wish to change a translation -- it's harder compared to a set-file.
  • You will need a large amount of chooses, to construct a completely-converted page -- that is less than great for performances (and means you will need to put some caching mecanism in position)

From curiosity, why don't you have a look at another thing -- a thing that goal is translations ?

Here, I am considering Gettext, that is broadly used -- and there's a Gettext extension for PHP (I ought to add you will find other classes available -- in Zend Framework, for instance).