Jump to content

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)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.