Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

what is the most efficient way to add multiple languages to a PHP website

I wanted to ask what would be the best way to add multiple language support to my php website ? will be translated manually so i thought about having multiple page files in different languages and all connected to a SQL table that has records in that language. Or is there a more efficient way for example somehow without making multiple php files ?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I am a CakePHP developer. All the strings are inside the translate function __(‘some expression’).

https://book.cakephp.org/4/en/core-libraries/internationalization-and-localization.html

Using a console command all the strings are parsed from PHP/view files and a .po file is generated. Using a PO Editor I translate the expressions.

For the strings stored in the database, for example books in a library, you should have a separate column for each language: book_name_en, book_name_fr.
After checking $_GET[‘lang’] for example, you select the column for that language. The .po files should be only for static strings.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading