How to make a script multilingual or add language file in PHP CodeIgniter?
Please follow the steps below:
- Open file manager in cPanel, and go to the installation folder.
- Navigate to the language folder, inside the application folder.
- Create a new folder english as english is the default language for this project.
- Under the new english folder, create a new file as message_lang.
- Write an array as line, and populate some data.
- Create a file LanguageLoader.php inside the hooks folder.
- 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.
- Click open the autoload.php file inside config.
- Make sure the cookie helper is enabled.
- Click open config.php, and make sure that hooks are enabled in your system.
- Edit hooks.php, inside the config folder, and add your newly created hooks class and function.
- Now you need to copy all existing text content from the code, and add it to the array of the language file.
- You can create multiple folders for different languages.
- The users can change the website language by selecting respective cookie variables.