Jump to content

best way to translate a backoffice


jason213123

Recommended Posts

hi,

i looking for a best way to translate a backoffice content.

options:

 

A- i can use a separate file each for a lang with all vars.

B- use a table with all data

 

both of this solutions have a big time to implement and in all areas that i creat

i need add the vars.

there is some best solution for this?

something that can translate all content like google translator?

thanks for your help

:)

 

Link to comment
https://forums.phpfreaks.com/topic/219400-best-way-to-translate-a-backoffice/
Share on other sites

Personally i use an array in a file (which can be updated to be a database instead with minimum effort)

ie

uk.lang.php

$lang = array(
'welcome' => 'welcome',
'logout' => 'You have been logged out',
'login' => 'Welcome to back',
'etc' => 'etc'
);

 

//french

fr.lang.php

$lang = array(
'welcome' => 'Bienvenue',
'logout' => 'Vous avez été déconnecté',
'login' => 'Bienvenue à dos',
'etc' => 'etc'
);

 

 

example 1

<?php
$lang_code = 'uk';
require $lang_code'.lang.php';

echo $lang['welcome'];
?>

 

example 2

<?php
$lang_code = 'fr';
require $lang_code'.lang.php';

echo $lang['welcome'];
?>

 

 

EDIT: as for using a database

just query the database for the language and fetch the row as $lang (assuming all fields are the same as the keys)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.