使用MySQL的PHP​​应用程序中的语言支持

I want to provide language support in several different languages in a php web application. There are obviously several different ways to do this. In the past I used to store a variable in a php file for every language such as en.php for english support and fr.php for french support. For example, for the words Good Morning I would store it in a key $goodmorning then define it in both files and point to one or the other file with an if statement depending on user input.

It worked great but it was a lot of work. Is there a more efficient way to do this? I thought about storing the words in a database table called language_support. The table would look as follow

id | en    | fr   | es   |last_update
1  | hello | allo | hola | 04/12/2018

But my question is, how would I teach my program to recognize the words?

Look into PHP's _() and __() functions. This is for multi-language support of internal strings, not content. In other words, it's for the "Press any key to continue" or "Enter customer name" prompts, not for the blog articles. The general way it works is that you have a text file for each language, each text file with all the internal strings in the source and target languages.

You would use, for example, _("Good Morning!"), and assuming you had set the language to German, the output would be "Guten Tag!"

I'm at work, so I can't show you any PHP code right now, but that should be enough to Google. :)