Bilingual Log in / Create Account

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 2
Joined: Fri Jan 24, 2014 5:26 am

Bilingual Log in / Create Account

Postby galaxyweb » Fri Jan 24, 2014 5:32 am

I'm building a Drupal Website and I'm learning PHP.

I came up with this code:


$strings = array(
'en' => array(
'logout' => 'Logout',
'my-account' => 'My Account',
'login' => 'Log In',
'create-account' => 'Create Account'

'fr' => array(
'logout' => 'Deconnexion',
'my-account' => 'Mon Compte',
'login' => 'Connexion',
'create-account' => 'Creer un Compte'

$language = $user->language;

if ( $user->uid ) {
print '<a href="'.base_path().'user/logout">'.$strings[$language]['logout'].'</a>';
print '<a href="'.base_path().'user/">'.$strings[$language]['my-account'].'</a>';
}else {
print '<a href="'.base_path().'user/login">'.$strings[$language]['login'].'</a>';
print '<a href="'.base_path().'user/register">'.$strings[$language]['create-account'].'</a>';


But it doesn't work. I don't see the text on my website when logged out. However when I log in, I see the text Logout / my account and when switching to the French website, the text doesn't get translated.

Can anybody help me ?

Return to “PHP coding => General”

Who is online

Users browsing this forum: Yahoo [Bot] and 8 guests