Please login or register.

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

Author Topic: Multi Languages  (Read 24936 times)

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Multi Languages
« Reply #15 on: March 09, 2007, 10:43:44 PM »

Well... my first answer is... no.
First of all, when you enter content into the sNews Admin panel (a new category, article, page, or extra), you are doing it in one language. All of this content gets saved to the database tables as data. There are only 3 tables for this data (the 4th table is for site settings only). Since it is only entered in one language... it will only display in that one language. If you wanted it to display in another language, you would need to create another category, article, page or "extra", and it would display as another article, etc.
One way to do it would be to have two snews installations, both using the exact same template but with the different languages. You could have the tables for each language in the same database. You would start by creating 2 sets of tables in one sql dump file... one for each language... and prefix the table names in there with a language prefix... like en_articles and fr_articles for english and french language tables. Then you run the dump file in phpMyAdmin (with "Import") and you'll get 8 tables in the database... 4 for the french install and 4 for the english install. And when you do your config settings in each of the snews.php files... the settings are the same except for the prefix variables... which you set according to the prefixes you attached to your tables. Then, in your index.php file, you would need a switch somewhere so viewers can choose language they want the site in... which really switches from one installation to the other.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Leonardo

  • Newbie
  • *
  • Karma: 2
  • Posts: 22
    • http://leonardoprosperi.com
Multi Languages
« Reply #16 on: March 10, 2007, 12:07:23 PM »

You're right, it doesn't work...
But what I meant is similat to what you said.
I didn't create a second set of tables, I just added fields to the tables I had, for example:

ALTER TABLE categories ADD name_XX varchar(100) NOT NULL;

I create a copy of snew.php, called snews_XX.php, with XX language inside.
Then I modified several 'name' to 'name_XX', and mainly I changed:
mysql_query("UPDATE ".db('prefix')."categories SET name_XX = '$name', ......

I included snews_XX.php in index.php, I edited the categories that were empty in the second language.
Now when I switch 'manually' from EN to XX, I have everything in the same order.
I don't need two database, just a copy of the fields that I need to traslate. A new article will be published in both languages with the same date and order, using these steps:
1-insert article1 in EN (as admin)
2-switch to XX
3-edit (only missing part) article1 in XX (as admin)
I think it is easier than to use prefix on tables.
What I need now it's a switch for the reader in the index.php fiel  to include the right snew.php file.
Sorry again for my english.

Leonardo
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Multi Languages
« Reply #17 on: March 10, 2007, 03:59:12 PM »

This approach sounds like it would work as well.
Have you tested this approach yet?
If so, then... the only thing left to do would be to have a way of changing which snews.php (engine) file is being "included" during session start, in the index.php file. Ideally, the site viewer should be able to make the choice from a little GUI panel on the home page.
A solution anyone? :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Leonardo

  • Newbie
  • *
  • Karma: 2
  • Posts: 22
    • http://leonardoprosperi.com
Multi Languages
« Reply #18 on: March 10, 2007, 06:43:34 PM »

I tested only for category name. It will be quite hard to do in all snews.php.
But if I can do that, it will be possible switch  easily between 2 languages, all the articles will have the same publishing days, and the same structure.
I was thinking of using a cookie for the choice, but I don't know how to do that.
I add this at the beginning of index.php:

if (isset($languagex)):
 include('snews_'.$_COOKIE[$languagex].'.php');
else:
 setcookie('languagex', 'EN');
 include('snews_EN.php');
endif;
 ?>

It creates a cookie (EN) if it is not available.
How can I execute php code (), clicking on a link?
If I do that, I can have a 2 language snews page.
Logged

Joost

  • Guest
Multi Languages
« Reply #19 on: March 11, 2007, 12:16:43 AM »

Hello,

I follow this thread with interest., The idea, to install a snews. php for every language, is very apealing. But I am concened about two things:
1) Would every language have its own uploaddirectory (for images)?
2) Would every language have its own password ?

If so, is there a workaround for these issues?

Regards,

Joost
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Multi Languages
« Reply #20 on: March 11, 2007, 02:15:53 AM »

I do not think the approaches we are tossing around right now are the ideal way to go. sNews is not designed to run with more than one language at a time, and even then only the site's language variables are interchangable at this time. As it is, you can post articles in any language as long as the charset being used in the site will display the language properly. Remember, sNews is designed to remain simple in its current form.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Joost

  • Guest
Multi Languages
« Reply #21 on: March 11, 2007, 03:49:56 AM »

@keyrocks

I do agree on keeping sNews design simple, that's why I like it.  All I do is exploring the the possiblity to convert it in a simple way to a multi-language site. My first thougth was, like others have mentioned, to use a multiple install. But brainstorming along that line, made me realize that it would be difficult for endusers (editors) to show the same image in different installs. The second problem is that they would login seperately into every install for every language.

Maybe I have to try a different approach. This is what I am thinking about:
- rename 'categories' to 'language'
- Implement the philmoz mod which shows all the artcles of the current language-category
- Delete 'new_comments' and 'menu_articles(0,3);' from the template (less information = less confusion)
-  Redescribe a lot of features (buttons) in the admin-section, to prevent the end-user from getting confused.

I think this is worth trying. I will let you know the result.

So far, thanks for replying
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Multi Languages
« Reply #22 on: March 11, 2007, 04:50:15 AM »

Quote from: Joost
@keyrocks

I do agree on keeping sNews design simple, that's why I like it.  All I do is exploring the the possiblity to convert it in a simple way to a multi-language site. My first thougth was, like others have mentioned, to use a multiple install. But brainstorming along that line, made me realize that it would be difficult for endusers (editors) to show the same image in different installs. The second problem is that they would login seperately into every install for every language.

Maybe I have to try a different approach. This is what I am thinking about:
- rename 'categories' to 'language'
- Implement the philmoz mod which shows all the artcles of the current language-category
- Delete 'new_comments' and 'menu_articles(0,3);' from the template (less information = less confusion)
-  Redescribe a lot of features (buttons) in the admin-section, to prevent the end-user from getting confused.

I think this is worth trying. I will let you know the result.

So far, thanks for replying
Something to toy with, if you are going down the mod path..
Use one snews.php for each language, and include it from site root index.php depending on language selection. It is to be setup using prefix for article table, category table, and comments table. Which means you just need to work out how to make each snews copy use the common password(easy enough) and settings table (that is, the one without the prefix).
Then, modify admin to have links to languge admin's. Should (I think) then be single login for all languages.

Now, I'm just going off to play ;)


[edit] actually, you just need to get login to access the one settings table, so that would be the one 'major change. Although removal of that option from the admin of the 'child' snews.php foles would be advisable.

back to playing with this[/edit]
Logged
Of all the things I have lost, it is my mind that I miss the most.

Joost

  • Guest
Multi Languages
« Reply #23 on: March 11, 2007, 05:40:13 AM »

Thanks Philmoz,

I will try that approach later on, I am already started with my semantic-mod approach ( renaming).  To see where that leeds to. I wil finish that first.
Any ideas for the file-upload issue? The image/file directory always seems to be in the same directory as index.php. For me it is no problem to link to a file in any directory, I am thinking about endusers.

Regards,

Joost
Logged

Leonardo

  • Newbie
  • *
  • Karma: 2
  • Posts: 22
    • http://leonardoprosperi.com
Multi Languages
« Reply #24 on: March 11, 2007, 12:08:15 PM »

I had a different approach. I don't wat to have any double information in the database.
I want one setting table, and on article table. In the article table I added only what I want to traslate.
Then I have 2 snews: snews_EN.php (original one) and snews_XX.php (where I made changes to use traslated fields of the db).
With this approch I'll have one password and one image folder.

I did that with category names, it works as I want only in the home page.
In index.php:


As switch I used:
XX Eng

I tried with cookies also, but without any results.
I'm new in PHP,  I chose sNews for its design is simple.
I'm just trying to improve my website as I like.
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Multi Languages
« Reply #25 on: March 11, 2007, 01:37:29 PM »

I have some progress.
I have the one login.
I have the admin changing over to a second snews.php
--I have removed password change from this snews.php and from the settings db for this snews.
-I can create new categories in this second snews separate from the root snews. Am having troubles getting articles to save :(

It should be possible to remove all settings, except language from the (prefix_)settings table and have all the rest of seetings drawn from main table.

I am using a form to switch between languages.. currently only in admin.
Logged
Of all the things I have lost, it is my mind that I miss the most.

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Multi Languages
« Reply #26 on: March 11, 2007, 03:54:31 PM »

Quote from: philmoz
Am having troubles getting articles to save
Have got that sorted, now to get site to switch on lang selection.
Have also filtered xx/snews.php to select only certain parts from xx_settings table, and rest from settings table
Logged
Of all the things I have lost, it is my mind that I miss the most.

Joost

  • Guest
Multi Languages
« Reply #27 on: March 11, 2007, 04:30:13 PM »

Nice to see this work in progress.  I am moving much slower. I can hand-code xhtml and css, but I never done real programming, only outcomment lines and cut and paste. So here I am sittin with my php and database-tutorial on my lap.

 Both leo1981 and philmoz approach look promising. My attempt to change the categories to language-categories might work at the frontend, but I think major problems wil occur while working on the backend, the admin pages. I don't think I can make it  foolproof.

 :cool: (I don't recall adding this cool emoticon, It should have been :/  )
Logged

Leonardo

  • Newbie
  • *
  • Karma: 2
  • Posts: 22
    • http://leonardoprosperi.com
Multi Languages
« Reply #28 on: March 11, 2007, 06:12:28 PM »

I did it... almost.
I'm making my site double language.
Why almost?
I did only for category names and changing language brings back to the home page.
Those are my steps:
MySQL> ALTER TABLE categories ADD name_XX varchar(100) NOT NULL;

rename snews.php snews_EN.php
copy snews_EN.php snews_XX.php

adding XX language variable to snews_XX.php
editing snews_XX.php, changing several "name" into "name_XX".

starting index.php with:

if (!isset($_SESSION['langx']) && !$_GET['lang'])
{$_SESSION['langx']="EN";
include('snews_EN.php');}
else{ if($_GET['lang'])
$_SESSION['langx']=$_GET['lang'];
include('snews_'.$_SESSION['langx'].'.php');}?>

and adding:
xxx Eng


You can see here: http://prosperi.ath.cx (it's often offline)
The only things that change are the language variable (already provided by snews) and the category names (that I inserted in the right side).
I'm going to complete my work in few days, writing a guide.

Leonardo

UPDATE:
I ended to update my web site (often offline because it is in my laptop that I switch off during the night GMT + 1). Those are all the mysql query to update the db:
ALTER TABLE categories ADD name_xx varchar(100) NOT NULL;
ALTER TABLE categories ADD description_xx varchar(255) NOT NULL;
ALTER TABLE articles  ADD title_xx varchar(100) default NULL;
ALTER TABLE articles  ADD text_xx longtext;

I'll publish a guide as soon as possible.
Logged

Joost

  • Guest
Multi Languages
« Reply #29 on: March 11, 2007, 06:29:31 PM »

I see what you mean Leonardo. But you made a lot of progress so far.

Regards,

Joost
Logged
Pages: 1 [2] 3 4