How to create a PHP application with support for several languages ​​(English, French, Chinese, etc.)

I am building a web application using LAMP and the Smarty framework. There will be a lot of static content on the website (a page about us, error warnings, confirmation emails, etc.).

The web application must support multiple languages. Is the following approach appropriate?

1) The entire static copy on the pages of the Smarty template (html-pages) will be replaced by calls to smarty plugins, such as {lang file = 'about.xml' getTerm = 'title'}, which returns the string for the title tag in the corresponding language

2) The about.xml file is an XML document on a web server that acts like a dictionary with several languages. This way it will have xml nodes like

<term value="title">
   <en>&lt;a href=&quot;http://stackoverflow.com&quot;&rt;Stackoverflow&lt;/a&rt; is a great site</en>
   <fr>&lt;a href=&quot;http://stackoverflow.com&quot;&rt;Stackoverflow&lt;/a&rt; c'est website magnifique</fr>
   <ch>&lt;a href=&quot;http://stackoverflow.com&quot;&rt;Stackoverflow&lt;/a&rt; complex looking chinese characters I don't udnerstand</ch>
</term>
<term value="signupmessage">
   <en>&lt;a href=&quot;http://stackoverflow.com&quot;&rt;Stackoverflow&lt;/a&rt; great deals!</en>
   <fr>&lt;a href=&quot;http://stackoverflow.com&quot;&rt;Stackoverflow&lt;/a&rt; magnifique deals!</fr>
   <ch>&lt;a href=&quot;http://stackoverflow.com&quot;&rt;Stackoverflow&lt;/a&rt; complex looking chinese characters I don't udnerstand</ch>
</term>

3) URL- http://mywebsite.com/language/index.php. - , ln -s ./en ./, http://mywebsite.com/en/index.php php http://mywebsite.com/fr/index.php, url . , Google .

? xml , htmlentity html-? ?

+2
2
+3

XML - , . , , HTML-. CDATA . XML , DTD , . , UTF-8 UTF-16, , , , . UTF-8.

, XML , "smarty", . , , , ( ).

, , , ch . zh. ISO . ch - .

+1

All Articles