Hurry! Save Up to 50% On Your Purchase | March 2021 X

How to make a script multilingual or add language file in PHP CodeIgniter?


Please follow the steps below:

  1. Open file manager in cPanel, and go to the installation folder.
  2. Navigate to the language folder, inside the application folder.
  3. Create a new folder english as english is the default language for this project.
  4. Under the new english folder, create a new file as message_lang.
  5. Write an array as line, and populate some data.
  6. Create a file LanguageLoader.php inside the hooks folder.
  7. Write the function given below. The function loads the language file stored in the cookie variable. If no cookie is found, the function will create a cookie and store the default file name.
  8. Click open the autoload.php file inside config.
  9. Make sure the cookie helper is enabled.
  10. Click open config.php, and make sure that hooks are enabled in your system.
  11. Edit hooks.php, inside the config folder, and add your newly created hooks class and function.
  12. Now you need to copy all existing text content from the code, and add it to the array of the language file.
  13. You can create multiple folders for different languages.
  14. The users can change the website language by selecting respective cookie variables.