PHP Simplicity Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

The latest version of Simplicity oF Upload is 1.3.2.

Author Topic: multilingual website  (Read 2566 times)

0 Members and 1 Guest are viewing this topic.

TheJoe

  • Newbie
  • *
  • Offline Offline
  • Posts: 2
    • View Profile
multilingual website
« on: November 02, 2009, 08:14:59 AM »

Hi there, i've just read your article titled "running a multilingual website", and it doesn't seem to be that hard. Sorry for the absolute beginner question..

I've ran your code, i can get values from the it.lng and en.lng, but i didn't understood how to let the user make the choice.. what should i link to switch from a language to the other one?

Thanks for an answer.
Logged

Saleh

  • Administrator
  • Full Member
  • *****
  • Offline Offline
  • Posts: 222
    • View Profile
    • PHP Simplicity
Re: multilingual website
« Reply #1 on: November 02, 2009, 10:15:17 AM »

You can pass it in the URL or even post it in a form.
Probably the easiest solution is passing it by URL. a typical link would be something like:
Code: [Select]
<?php
$page 
$_SERVER['PHP_SELF']. '?lang=it';

echo 
"<a href=\"{$page}\">Italian</a>";

Then change check_lang() function to make it like:
Code: [Select]
<?php
function check_lang() { 
  if (!isset(
$_SESSION['lang']) && !isset($_GET['lang'])) { 
    
$lang 'english'

// if something is passed, sanitize it and then save it to the session var.
  
} elseif (isset($_GET['lang'])) {
    
$lang ctype_alpha($_GET['lang']) ? $_GET['lang'] : 'english';
    
$_SESSION['lang'] = $lang;
  } else { 
    
$lang $_SESSION['lang']; 
  } 

//directory name 
  
$dir 'languages'

//no we return the langauge wanted ! 
//Returned String Format: dirname/filename.ext 
  
return "$dir/$lang.lng"
}
Logged

We don't need a reason to help people

TheJoe

  • Newbie
  • *
  • Offline Offline
  • Posts: 2
    • View Profile
Re: multilingual website
« Reply #2 on: November 02, 2009, 11:23:25 AM »

wow, it seems to work properly now.. XD

I have one more question.. i'll try to explain.. the site i'm working on has a news manager (fusionnews).

I need the site to show news in different languages. The files it.lng, en.lng, ecc. should contain only the navigation menus and little sentences, for the articles i need a news manager. FusionNews did the trick until few minutes ago. I have 4 categories (italian, english, ecc), i login, i write the article in italian, then in english, french, spanish and so on, then i publish it in the 4 different categories that go in 4 different pages. The following:

/it_index.php
/en_index.php
/es_index.php
ecc..

Each page contain a different php string:

it_index.php
<?php $fn_category = 2; include "data/upload/news.php"; ?>

en_index.php
<?php $fn_category = 3; include "data/upload/news.php"; ?>

es_index.php
<?php $fn_category = 4; include "data/upload/news.php"; ?>

Is it possible to keep on using fusionnews and your multilingual trick together?
Logged

Saleh

  • Administrator
  • Full Member
  • *****
  • Offline Offline
  • Posts: 222
    • View Profile
    • PHP Simplicity
Re: multilingual website
« Reply #3 on: November 03, 2009, 06:16:42 AM »

I haven't worked with FusionNews before so I can't tell you for sure. But technically, everything is possible it's just how complex doing so would be.

But if I understand you correct, the categories are virtually the same thing as my multilingual "trick" :)
Logged

We don't need a reason to help people

asbruff

  • Guest
Re: multilingual website
« Reply #4 on: November 05, 2009, 02:14:15 PM »

hem.. i really don't know how php works.. as far as i'm not a programmer..

i just understand the include.. and nothing else.. XD Is it a pain for you to help me understanding PHP? XD
Logged

Saleh

  • Administrator
  • Full Member
  • *****
  • Offline Offline
  • Posts: 222
    • View Profile
    • PHP Simplicity
Re: multilingual website
« Reply #5 on: November 18, 2009, 04:24:47 PM »

To what level do you want me to help you? :)
PHP as a language is easy. But understanding others' code can be difficult for any language.
Logged

We don't need a reason to help people
 

+ Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.
Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What is the answer to one plus one? (in numbers):