How to save and retrieve language specific text in PHP?

I am currently creating a web application that will be used by people from different countries.

Currently, all the messages that I printed (i.e. errors, etc.) are in English.

What is the best way to store language constants and get them?

It is very likely that messages may need a bit of information entered into them, as well as data entered by the user, etc.,

For example, we may have an error:

The email address 'test@test.co' was not a valid email address.
+3
source share
4 answers

GNU gettext provides tools and framework for this. This is a decent article on using gettext in PHP.

+4

printf(), % s:

The email address '%s' was not a valid email address.

, :

, , . , :

  • /
+4

. ,

SELECT FROM WHERE key = 'error_email' AND lang = 'de';

, .

0

XLIFF? , .

0
source

Source: https://habr.com/ru/post/1736351/


All Articles