Multi Language Settings
Let's add the French language.
- Create a new file fr.json in the fr folder in the
assets/langfolder and copy theen.jsonfile code in this file. -
Now you need to add the language in the
assets/js/app.jsfile. In the function setLanguage, add the "Switch case" condition as below code and make sure to add the french.jpg file in theassets/images/flagsfolder.case "fr": document.getElementById("header-lang-img").src = "assets/images/flags/french.svg"; break; - You can simply use key attributes in the HTML tag to convert the language text. Example: <div data-key="t-title">This is title.</div>
-
Add the below dropdown in the
partials/topbar.phpfile in the language dropdown.<!-- item--> <a href="javascript:void(0);" class="dropdown-item notify-item language" data-lang="fr" title="French"> <img src="assets/images/flags/french.jpg" alt="user-image" class="me-2 rounded" height="18"> <span class="align-middle">French</span> </a>
Multi-Language Settings - Codeigniter
For official documentation of Codeigniter you can follow https://codeigniter4.github.io/userguide/outgoing/localization.html.
Please follow the below steps to add a new language.
-
Set default language from the
app/Config/App.php.
$defaultLocale= 'en';and in supported language$supportedLocales = ['en', 'es', 'de', 'it', 'ru'];
and setpublic $baseURL = 'https://yourdomain.com/'; -
All the files of each language are located in
app/Language. You can create a new language folder by referring to the English language. -
You need to add a new language in the topbar dropdown in the file
app/Views/partials/topbar.phpandapp/Views/partials/horizontal.phpfile. -
It is managed by the backend in the file
app/Controllers/Language.php.
You can use<?= lang('Files.Search') ?>to translate "Search" keyword in supported languages.
Multi-Language Settings - PHP
-
Let's add a new language Italy.
Create an it.php file in theassets/lang-phpfolder. And refer to the other languages to add or update the keys and values for translation. -
You need to add a new language in the topbar dropdown in the
file
partials/topbar.phpfile and fin the class "language-switch". You can add a new language flag so it will be able to render in the topbar. -
You can use
<?php echo $lang["Forms"]; ?>in the view.
Multi-Language Settings - Ajax
-
Let's add a new language Italy.
Create an it.json file in theassets/langfolder. And refer to the other languages to add or update the keys and values for translation. -
You need to add a new language in the topbar dropdown in the
file
index.htmlfile and fin the class "language-switch". You can add a new language flag so it will be able to render in the topbar. -
You can use
<a href="forms.html" key="t-crypto">Formsin the view.