Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Bilingual Log in / Create Account

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

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:

<?php

$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 ?
galaxyweb
New php-forum User
New php-forum User
 
Posts: 1
Joined: Fri Jan 24, 2014 5:26 am

Return to PHP coding => General

Who is online

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

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron