Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: How to switch languages?  (Read 284 times)

sibas

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 451
    • www.simply4all.net
How to switch languages?
« on: January 13, 2013, 08:21:20 AM »

Hello
I have two languages EN and GR I need a user to switch languages with one click.
Does anyone know how to make this switch?
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: How to switch languages?
« Reply #1 on: January 13, 2013, 09:03:00 AM »

Here's my take on it: http://snewscms.com/forum/index.php/topic,9881.0.html
(There are other mods that do multilanguage scenarios differently. Search the Mods section.)
Logged

sibas

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 451
    • www.simply4all.net
Re: How to switch languages?
« Reply #2 on: January 13, 2013, 10:13:18 AM »

Hi Fred K
I have see your Multi-lingual and other mods but is not what I need.
Although this language switch allready exist for admin I cant find the way to add it for users.
simply I want with one click to change only the language file and not all the html
 
« Last Edit: January 13, 2013, 10:15:04 AM by sibas »
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: How to switch languages?
« Reply #3 on: January 14, 2013, 12:16:13 AM »

simply I want with one click to change only the language file and not all the html

Then this older yet very simple Multi-language Simple Mod will do the job. Once you add it to your files, you can play with the template part to get it styled the way you want it to look. I've just given it a quick test and it works fine. Remember - before modding - back up your snews.php file to safe folder outside your project's root so you have it to refresh your modded file if you don't want to keep it.  :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

sibas

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 451
    • www.simply4all.net
Re: How to switch languages?
« Reply #4 on: January 17, 2013, 11:51:25 AM »

Hi key
Thanks for point me at this mod, seems like working except one small or big problem.
The switch working very smooth, but at the very first time have one notice and one Warning this appear until someone clicks to switch any language. after this no problem occurs!

Where is the notices/warnings
Quote
( ! ) Notice: Use of undefined constant _PRE - assumed '_PRE' in D:\xampp\htdocs\official_package\snews-ori.php on line 88
Call Stack
#   Time   Memory   Function   Location
1   0.0014   141728   {main}( )   ..\index.php:0
2   0.0112   1167168   include( 'D:\xampp\htdocs\official_package\snews-ori.php' )   ..\index.php:6
3   0.0121   1168624   lang( )   ..\snews-ori.php:36
4   0.0121   1168696   s( )   ..\snews-ori.php:32
Variables in local scope (#4)
$query = Undefined
$r = Undefined
$result = Undefined
$site_settings = &null
$value = Undefined
$var = string 'language' (length=8)

( ! ) Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\official_package\snews-ori.php on line 90
Call Stack
#   Time   Memory   Function   Location
1   0.0014   141728   {main}( )   ..\index.php:0
2   0.0112   1167168   include( 'D:\xampp\htdocs\official_package\snews-ori.php' )   ..\index.php:6
3   0.0121   1168624   lang( )   ..\snews-ori.php:36
4   0.0121   1168696   s( )   ..\snews-ori.php:32
5   1.1015   1175480   mysql_fetch_assoc ( )   ..\snews-ori.php:90
Variables in local scope (#4)
$query = string 'SELECT name,value FROM _PREsettings' (length=35)
$r = Undefined
$result = boolean false
$site_settings = &null
$value = Undefined
$var = string 'language' (length=8)

I added 2 isset in function lang()
Code: [Select]
<?php 
function lang(){
if(isset($_POST['language']) != ''){
$_SESSION['language'] = $_POST['language'];
$lang $_SESSION['language'];
}elseif(isset($_SESSION['language']) != ''){
$lang $_SESSION['language'];
}else{
$lang s('language');
}
return $lang;
}
lang();
?>


any idea?
Logged

sibas

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 451
    • www.simply4all.net
Re: How to switch languages?
« Reply #5 on: January 17, 2013, 12:10:06 PM »

I found the problem.. remove lang(); after the function lang()
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: How to switch languages?
« Reply #6 on: January 17, 2013, 05:51:51 PM »

I found the problem.. remove lang(); after the function lang()

Good work Sibas.  :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU