multi lang php

Solutions on MaxInterview for multi lang php by the best coders in the world

showing results for - "multi lang php"
Anna
29 May 2019
1<?php
2$trans = [
3    'en' => [
4        'user_where_are_you_text' => 'Where are You, %s? It is me, %s! I am waiting here for %s hours!',
5        //...
6    ],
7    'fr' => [
8        'user_where_are_you_text' => 'Où es-tu, %s? C\'est moi, %s! J\'attends ici depuis %s heures!'
9        //...
10    ],
11    //...
12];
13
14$name = 'Loz';
15$name1 = 'Rasmus';
16$time = 3;
17
18function __($key, ...$arguments) {
19    global $trans, $lang;
20    return sprintf($trans[$lang][$key], ...$arguments);
21}
22
23//
24$lang = 'en';
25echo __('user_where_are_you_text', $name, $name1, $time).PHP_EOL;
26
27//
28$lang = 'fr';
29echo __('user_where_are_you_text', $name, $name1, $time).PHP_EOL;