Skip to content

Language

Hossein Pira edited this page Sep 8, 2023 · 3 revisions

Language

To define a language file to folder routes/lang Go ahead and create a php file with an array inside. Your sample file should be like en.php

<?php

return [
    "welcome" => "Welcome",
    "home_title" => "Home",
    "app_info" => "fast chatbot webApp"
];

And call the model as follows:

$lang = new Lang(); // default en
echo $lang->get('welcome');

To display a variable in the language, start it with : ( Defining its variables is optional and it will be displayed in the same way until you define it. )

<?php

return [
    "hello" => "Hello :name"
];

and assign value to the variable as follows:

$lang = new Lang("fa");
echo $lang->get('hello', ["name" => "Hossein"]);
Clone this wiki locally