Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 4

Author Topic: Multi Languages  (Read 24877 times)

The Bear

  • Newbie
  • *
  • Karma: 0
  • Posts: 12
Multi Languages
« on: January 08, 2007, 12:51:44 AM »

Hi

Can someone please describe the logic for this process and what is required, I want to add six language files.

After reading the documentation I am almost as confused as when I started..grin.

It appears if I wanted to make my system languge french for example I have two ways of doing this, one is to copy the translated language information and paste it into snew.php, make a few minor changes and then go into the admin/settings and change the tag to FR. Or I can create a snews_FR.php now this is where it gets clouldy, the code looks like it should pick up this file if again I go into admin/settings and change the EN to FR.

The only example I can find with several languages is the History site but after reviewing that site I come back with the feeling that he is running several copies of the program to achive this result, is this the only method to add several language or am I missing something here, the boat - the ship - etc etc.

Thanks in advance.
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Multi Languages
« Reply #1 on: January 08, 2007, 02:33:58 AM »

Bear - the logic as far as I can see is: one snews file, one language. You can change the language of the one file in the admin area, you can even have multiple language variable files and switch between these multiple languages, *but* (and as the saying goes, that is one big but :lol:) you can't run more than one language with that one file. As far as I know.

For a mutlilingual site you'll need a copy of snews.php for each language, yes.
Logged

Bob Marley

  • Newbie
  • *
  • Karma: 0
  • Posts: 4
Multi Languages
« Reply #2 on: January 08, 2007, 12:10:11 PM »

Just my two cents :

you can modify snews by creating a function language with a variable (i.e : lng) and you include just the language you need.

Sorry for my english i'm french so....

it's not really difficult to make this working and you need only one snews.php. As i have no much time i can't give you all the way to do this but try to create each file of the language you need and save them in a directory of your choice, then in the snews.php you replace all the the part of the language variable by the function that will include the language you need.
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Multi Languages
« Reply #3 on: January 08, 2007, 03:35:14 PM »

Adding more Language Files is Easy.
The English language (default) definitions in snews.php are already contained in a function... and the function already starts with an If... include... string. This basically says that "if another language file exists in the site's root directory, then use the language definitions within it. If not, then use the language definitions that follow..." which are the default English definitions in snews.php.

So... you do not need to duplicate the whole snews.php file. Here is what you do. Let's say we want to use the French language for the sNews engine.

Step One - Make the French language file: We start by going to the Translations Forum here at Solucija.com and look for the French Language File contributed by Edsil. Open your good code editor and open a new, blank php file. Copy and paste the contents of Edsil's file into your new file and save it as - snews_FR.php.

Step Two - Change Language Setting in Admin: After logging into your site as the Admin,  Scroll down to the SITE Panel and click SETTINGS >> TIME and LOCALE SETTINGS... and change the sNews language setting from EN to FR. Scroll down and click the SAVE button. After refreshing your browser window, your site's interface should now display in french. Also ensure that you have included (and translated), in your new language file, any definitions you may have added to the default English definitions in snews.php.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Multi Languages
« Reply #4 on: January 08, 2007, 04:49:08 PM »

Quote from: keyrocks
Step Two - Include the new file
hm, interesting. What I've done so far is simply step one, and take care to save the language file in the same folder as snews.php, then step three. Haven't had to do step two, so I haven't even thought about it. Strange, huh?

To clarify:
Step 1: Translate the language variables in a new php file. Save in same folder as snews.php with namestring snews_XX.php

Step 3: Change language setting in Admin panel, to XX. Save changes.
And there's your nice new language.

This doesn't change things for Bear though, he still needs to make six copies of snews.php and six language files for his multilingual site. Right?
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Multi Languages
« Reply #5 on: January 08, 2007, 05:36:12 PM »

No - not that I can see. I do not use multiple language files on any of my sites yet so I just did the above exercise as a "test run" on one of my locahost installs this morning, and it only took 5 minutes or less.

I simply copied the content of the french language translation file that Edsil posted in the Translations Forum... and that is all I pasted into the snews_FR.php file. There are no functions of any sort in it. And there is no opening strings for the language function itself - just the language variables - all by themselves. So my FR file is only 238 lines long (including some extra variables I had added in for some of my mods). So this FR language file is only 12.7 KB in size - a whole bunch smaller than the almost 100 KB size required for a full (replicated) snews.php file.

About Step two: You are right - don't need it (just my habit of ensuring a file gets included)... the If... statement at the beginning of the language function already does this... so step 2 is redundant - I have removed from the above post.

And it works. I did it this way because that is how I interpreted Mika's notes in his snews_commented.php (developer's snews.php) file. :)

BUG NOTE: - Just noticed that - once the French language file is active - the link to open the Locale and Time Settings Admin Panel no longer functions. I don't know why yet - perhaps there is something missing from the french language variables that is required to make function toggle(div) (javascript) work.  This bug also affects the three toggle panels under the New Articles, New Extra and New Pages textarea panels.

For anyone willing to experiment with this method of including language files - the easiest way to get the English language variables (and panel toggle) working again is as follows. With the language setting as FR in the Time and Locale Settings Panel... replacing EN with FR in the if... string (see below) returns the site to English language variables and the toggle function works again.
Quote
if (s('language') != 'FR' && file_exists ...
This gets you back into the Times & Locale Settings Panel to change the language setting back to EN. After refreshing the page, the site continues to function in English and all panels continue to toggle - as if no changes had been made in the first place.

The reason for this, of course, is that we've changed the "if" statement to interpret itself as... "If the language setting (in the Admin Panel) is set to "FR"... and the file exists... include the FR file... else continue with the english array that follows."

(I am testing this in a default installation of sNews 1.5.29.)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Multi Languages
« Reply #6 on: January 08, 2007, 06:16:51 PM »

The problem you ran into with the French translation is the reason I posted this bugaboo in the Translations forum (I had the same problem with my own Swedish version before adding the php tags).

About the multilingual thing -- would adding a language switch do the trick I wonder? Like the main switch in center(). Maybe as an addon?

/* mumbles to self ...
lang=language_file
if lang !=EN {
   switch lang
   case lang1 (include lang1.php);
   case lang2 (include lang2.php);
etc.

... quits mumbling, trots off to leaf through Very Big Book of PHP */
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Multi Languages
« Reply #7 on: January 08, 2007, 06:42:29 PM »

Quote from: agentsmith
The problem you ran into with the French translation is the reason I posted this bugaboo in the Translations forum (I had the same problem with my own Swedish version before adding the php tags).
"Check 1 - tags in place".

Quote from: agentsmith
About the multilingual thing -- would adding a language switch do the trick I wonder? Like the main switch in center(). Maybe as an addon?
   /* mumbles to self ...
   lang=language_file
   if lang !=EN {
      switch lang
      case lang1 (include lang1.php);
      case lang2 (include lang2.php);
  etc.
... quits mumbling, trots off to leaf through Very Big Book of PHP */
Of couse... we have this statement following the opening string of the language function (in snews.php) and I would have thought it was already doing the job.

Here, we have the function starting... then the statement to choose whatever file is set in the Admin Panel (for language settings) if it exists... or else... continue to parse the array provided below.
Quote
// LANGUAGE VARIABLES
function l($variable) {
   if (s('language') != 'EN' && file_exists('snews_'.s('language').'.php')) {include('snews_'.s('language').'.php');} else {
   $l = array();
   
   #SITE LANGUAGE VARIABLES
   $l['home'] = 'Home';
........ // (followed by the rest of the english variables...)
Now... I did not include the opening and closing of the array itself (in the snews_FR.php file)... which may be the problem. But, if that were the case, I would not expect any of the french variables to take precedent over the english variables... as they are doing. (...more thinking required...)

(... taking rest of the afternoon off to shovel snow out of the driveway...)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Multi Languages
« Reply #8 on: January 09, 2007, 05:23:36 AM »

Snow? I've heard old people speak of it but I ain't never seen any ... :lol: (it's a green winter in my parts of Sweden)

Quote from: keyrocks the Snowman
... we have this statement following the opening string of the language function (in snews.php) and I would have thought it was already doing the job
yes, for one language, and I guess the way that snews is currently built many-languages-at-once hasn't been considered (or maybe it has been considered and dropped/moved forward). When looking at it more in depth it's pretty obvious: there is no option in the admin panel to set a language per Page or Category or something like that. You can set a language for the site (= the one snews.php file), that's it. So to build a multilingual site we'd need to extend the admin area for one thing. Sounds like mucho trabajo to me... ;)
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Multi Languages
« Reply #9 on: January 09, 2007, 03:26:18 PM »

Quote from: agentsmith
Snow? I've heard old people speak of it but I ain't never seen any ... :lol: (it's a green winter in my parts of Sweden)
When looking at it more in depth it's pretty obvious: there is no option in the admin panel to set a language per Page or Category or something like that. You can set a language for the site (= the one snews.php file), that's it. So to build a multilingual site we'd need to extend the admin area for one thing. Sounds like mucho trabajo to me... ;)
On the Snow - Global climate change is seriously affecting our winters but that's another topic for the General section.
On Multilanguage capability - It is "mucho trabajo". I am somewhat familiar with the method used by/in phpNuke - user clicks an icon or link to switch languages no matter where you are in the site and the interface language switches while keeping you on the page you were on. All language files are simple and stored in a language file. I think it comes with 35 (or more) language files (and flag icons) included. And, each module contains its own language file system as well. It's an excellent method.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

The Bear

  • Newbie
  • *
  • Karma: 0
  • Posts: 12
Multi Languages
« Reply #10 on: January 10, 2007, 05:25:09 AM »

Hi

Thanks keyrocks for the information and everyone one that submitted a reply.

I was looking at this piece of code I found and it looks interesting.

Code: [Select]
 // Load the language files
 $lang = (isset($_GET['language'])) ? $_GET['language'] : 'english';
 $lang = "lang-files/$lang.php";
 if (file_exists($lang))
 {
require $lang;
echo '' . LAN_001 . '' . "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . LAN_002 . ' ' . LAN_003 . "
\n";
echo '
' . LAN_004 . '
';
 } else {
echo '' . "\n";
echo '' . "\n";
echo 'Language file NOT FOUND' . "\n";
 }
?>
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Multi Languages
« Reply #11 on: January 10, 2007, 08:19:31 PM »

And what about content language? For example, simple three language site ;) with content as well in three languages?
« Last Edit: September 24, 2007, 04:34:56 PM by codetwist »
Logged

mininovax

  • Newbie
  • *
  • Karma: 1
  • Posts: 44
    • http://www.ondapc.net
Multi Languages
« Reply #12 on: January 31, 2007, 05:58:05 PM »

Probably the biggest problem i see with the language files is a lack of standards. Perhaps the developers and administrators have been changing variables.

I speak Spanish, so I downloaded the Spanish translation...

however, the array value for    

Code: [Select]
$l['archives'] = 'Archive';in English file was

Code: [Select]
$l['archive'] = 'Archivo';in Spanish site

archives to archive ??? Why?

This of course broke the Archive link. A standard should be adopted when making snews translation files. And if the values are being modified by the Snews team, than perhaps they should refrain from making such small changes.

just my 2 cents
Logged

Manuel Pancorbo

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 72
Multi Languages
« Reply #13 on: January 31, 2007, 06:40:10 PM »

Quote from: mininovax
Probably the biggest problem i see with the language files is a lack of standards. Perhaps the developers and administrators have been changing variables.

I speak Spanish, so I downloaded the Spanish translation...

however, the array value for    

Code: [Select]
$l['archives'] = 'Archive';in English file was

Code: [Select]
$l['archive'] = 'Archivo';in Spanish site

archives to archive ??? Why?
I think it is a typo of the spanish translator. I also suffered it!
Logged

Leonardo

  • Newbie
  • *
  • Karma: 2
  • Posts: 22
    • http://leonardoprosperi.com
Multi Languages
« Reply #14 on: March 09, 2007, 10:22:36 PM »

I'm trying to add a second language in my website, both contents and pages.
Which is the easiest way to do that?
I was thinking to add in the database "text_xx" and "title_xx" for articles, and everything that needs a traslation.
After that, modify snews_xx in order to call  "text_xx", instaed of  "text", and so on.
After added a new content in the first language, change language, and edit in order to write in the second language.
Then  change index.php in order to make the switch available for the user and admin.
I hope I was clear...
Is that possible or not?
Logged
Pages: [1] 2 3 4