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 ?
CodePudding user response:
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.