jason213123 Posted November 21, 2010 Share Posted November 21, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/219400-best-way-to-translate-a-backoffice/ Share on other sites More sharing options...
MadTechie Posted November 21, 2010 Share Posted November 21, 2010 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) Quote Link to comment https://forums.phpfreaks.com/topic/219400-best-way-to-translate-a-backoffice/#findComment-1137696 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.