• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 131 posts ]  Go to page Previous  1 ... 5, 6, 7, 8, 9
Author Message
 Post subject: Re: One more approach to build a multilingual site with the regular CMSMS
PostPosted: Mon Sep 21, 2009 8:25 pm 
Offline
New Member
New Member

Joined: Mon Sep 21, 2009 8:15 pm
Posts: 4
I've got this happening to me as well. I'm running it off a local server and using CMSMS 1.6.5 and Babel 0.3.2. Everything's set up using the default hierarchy method but when I change language the page is blank and the address is:

\$1:
http://localhost:8888/cmsold/modules/babel/redirect.php?newlang=en_US&newurl=http://localhost:8888/cmsold/index.php?page=english/eng-home


The 'newurl' part is the correct address but this link doesn't go anywhere. It's almost like you would want to drop the:

\$1:
http://localhost:8888/cmsold/modules/babel/redirect.php?newlang=en_US&newurl=


part. I've tried this on Firefox and Safari.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: One more approach to build a multilingual site with the regular CMSMS
PostPosted: Mon Sep 21, 2009 8:28 pm 
Offline
New Member
New Member

Joined: Mon Sep 21, 2009 8:15 pm
Posts: 4
I've got this happening to me as well. I'm running it off a local server and using CMSMS 1.6.5 and Babel 0.3.2. Everything's set up using the default hierarchy method but when I change language the page is blank and the address is:

\$1:
http://localhost:8888/cmsold/modules/babel/redirect.php?newlang=en_US&newurl=http://localhost:8888/cmsold/index.php?page=english/eng-home


The 'newurl' part is the correct address but this link doesn't go anywhere. It's almost like you would want to drop the:

\$1:
http://localhost:8888/cmsold/modules/babel/redirect.php?newlang=en_US&newurl=


part. I've tried this on Firefox and Safari.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: One more approach to build a multilingual site with the regular CMSMS
PostPosted: Mon Sep 21, 2009 8:59 pm 
Offline
New Member
New Member

Joined: Mon Sep 21, 2009 8:15 pm
Posts: 4
I have almost no knowledge of php but I changed line 30 in action.menu.php in the babel module folder from
\$1:
if($item->url && $use_cookies)      $item->url = $gCms->config['root_url'].'/modules/babel/redirect.php?newlang='.$item->code.'&newurl='.$item->url;


to

\$1:
if($item->url && $use_cookies)      $item->url = $item->url;


and now the address bar is just the page address

\$1:
http://localhost:8888/cmsold/index.php?page=english/eng-home


and that now shows the right page but are there any obvious effects from taking the rest of the code out that I'm missing?


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: One more approach to build a multilingual site with the regular CMSMS
PostPosted: Tue Sep 22, 2009 12:54 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Oct 15, 2008 10:38 am
Posts: 196
The effect is that when you click on a language link, your language preference is not saved in the cookie - hence when you come back you have to switch language once again.
The bug happens to be very, very dumb.  If you look at your redirect.php file, you will notice that the redirection code is simply not there.
The file should read :
\$1:
<?php
if(!isset($_GET["newurl"]) ){
   header("location: index.php");
}else{
   if(isset($_GET["newlang"]))   setcookie('usrlang',$_GET["newlang"],time()+86400*30,'/');
   header("location: ".$_GET["newurl"]);
}
?>

I don't know how I could release it with the missing line, and most of all how I managed not to notice it... I will upload a corrected release later today.

Pierre-Luc


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: One more approach to build a multilingual site with the regular CMSMS
PostPosted: Tue Sep 22, 2009 8:47 pm 
Offline
Forum Members
Forum Members

Joined: Tue Jun 12, 2007 1:29 pm
Posts: 247
thanx for that, I also had this bug... ;)


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: One more approach to build a multilingual site with the regular CMSMS
PostPosted: Tue Sep 29, 2009 11:00 pm 
Offline
New Member
New Member

Joined: Mon Sep 21, 2009 8:15 pm
Posts: 4
Thanks for that Pierre-Luc.

One other thing I noticed was that the generated links for the language switching were invalidating the html. Going to line 30 in the action.menu.php code and changing the & at the end of the line to & seemed to fix this.

\$1:
if($item->url && $use_cookies)      $item->url = $gCms->config['root_url'].'/modules/babel/redirect.php?newlang='.$item->code.'&newurl='.$item->url;


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: One more approach to build a multilingual site with the regular CMSMS
PostPosted: Wed Sep 30, 2009 11:12 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Oct 15, 2008 10:38 am
Posts: 196
Thank you, I'll change that.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: One more approach to build a multilingual site with the regular CMSMS
PostPosted: Mon Jun 14, 2010 10:26 am 
Patricia \Patricia:
plger, that module is simply one of the best thing that could happen to me :)



me to - I had another solution without mle - but this works very fine and I don't need the extrafields (change language only showed to headpage of lg)

But I felt in troubles with the last version (0.3.4):

*) I set two language (en, de) and had a third "headpage" for es without childs (not really used). for the german site the link allways was to the spanish - and -logically- he didn't find the "spanish" childs.
Changing the head-page to the german (then english and back to german) didn't solve the problem.

Befor I got a errormessage by uploading via xml - it only worked with ftp. 0.3.3 works very fine  8)


Top
   
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: One more approach to build a multilingual site with the regular CMSMS
PostPosted: Mon Sep 13, 2010 12:59 pm 
Offline
New Member
New Member

Joined: Sat Jul 24, 2010 1:53 pm
Posts: 7
Hello hello

i would love to use this multilanguage plugin...i installed it and it seems to work.
i'm still havind some problems...ater getting the pages sorted i dont see menu items anymore.


i setup the pages with root pages as the hierarchie solution.
1. english (alias en) 2. netherlands (alias nl)
same daughter pages...

chech the site yoursellf: http://doing.jmdr.nl/~jeffer/cmsms/index.php



here are some copy paste items wich could be totally wrong.

menu template:


to show menu correctly i used: {menu start_level="2"}


As i said, i dont see menu items anymore, except for the english wich is default you still see the menu items in right tab....

Please can someone give me some help with this.
i would not mind to give someone a login aswell to fix this.

ive asked some friends also...im a noob at this...i do get alott of things working but i just cannot get this fixed.
website is depending on multilanguage, for my own starting hosting company ;)

every suggestion is welcome!!!

cheers, jeffrey


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: One more approach to build a multilingual site with the regular CMSMS
PostPosted: Tue Dec 21, 2010 12:01 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Oct 15, 2008 10:38 am
Posts: 196
Just to let people know, it has been reported that Babel is not compatible with the latest version of CMSMS.
I will try to release an updated version as soon as I can (should have been these days but my health is playing tricks to me). I will try to make it before Christmas. Until then, chances are that you'll experience trouble.
Plger


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: One more approach to build a multilingual site with the
PostPosted: Thu Sep 20, 2012 2:43 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Wed Aug 01, 2007 5:36 pm
Posts: 506
Update "Language menu" to CMSMS 1.11.x

{assign_page_lang} UDT
\$1:
/*
Assign the Smarty variable $page_lang depending on the root parent of the current page.
The root parent alias must be the language code (two letters).

2008-02-02 Marcos Cruz (http://alinome.net)
2012-09-20 by blast2007 (blastg [at] gmail [dot] com)

New features in this version:
- Works with v. 1.11.x and Smarty3

Reference:
http://wiki.cmsmadesimple.org/index.php/Share_your_tags_here#Get_a_page.27s_root_parent.27s_alias
*/

$gCms = cmsms();
global $smarty;

$manager =& $gCms->GetHierarchyManager();

$result = '??';
$thisPage = $gCms->variables['content_id'];
$currentNode = &$manager->sureGetNodeById($thisPage);
while( isset($currentNode) && $currentNode->getLevel() >= 0 )
{
    $currentContent =& $currentNode->getContent();
    $result = $currentContent->Alias();
    $currentNode =& $currentNode->getParentNode();
}
$smarty->assign('page_lang',$result);


{language_menu} UDT
\$1:
/*
Create a language menu (version 6).

2008-02-06 Por/Far/By Marcos Cruz (http://alinome.net)
2012-09-20 by blast2007 (blastg [at] gmail [dot] com)

New features in this version 6:
- Works with v. 1.11.x and Smarty3

New features in this version 5:
- New parameter show_default.
- New parameter show_inactive.

Changes in the code in this version 5:
- Some forgotten doble quotes has been changed to single quotes for better perfomance.
- Doble and single quotes changed in the example HTML buttons.
- New constants DEFAULT_PAGE and BUTTON to make the code more readable without using keys in the language array.
- Language array and other variables renamed to make the code more readable.
- More comments to help beginners understand the code.

New features in version 4:
- Every language has a default page to be used when no translation has been specified for the current page,
  or when the specified page doesn't exist.
- The HTML attribute hreflang is added to the links.
- The UDT parameter show_title now works in inactive links to the current page too.

Changes in the code in version 4:
- The function smarty_cms_selflink has been factored to make it easier to reuse the code.
- The conditional operator "?:" used instead of several if-structures.
- Code revised according to the PHP coding guidelines (spaces, string quotes, braces...)
- Optional debug points homogenized and marked with the word "DEBUG". Delete them if you want.
- New comments for beginners.

Possible future improvements:
- Spaces allowed in the template variable $other_languages (syntactic sugar to make it error-proof).

*/


$gCms = cmsms();
$db = cmsms()->GetDb();
$smarty = cmsms()->GetSmarty();

// ----------------------------------------------------------------
// Parameters

// Show the page title in the links? (true/false)
// (if false, show the defined buttons)
$show_title = isset($params['show_title']) ? $params['show_title'] : false;

// Show an inactive link to the current page in the menu? (true/false)
// (if false, don't create a menu entry for the current page)
$show_current = isset($params['show_current']) ? $params['show_current'] : false;

// If there's no valid translation, then show a link to the default page? (true/false)
// (if false, don't create a menu entry for that language)
$show_default = isset($params['show_default']) ? $params['show_default'] : true;

// If  $show_default==false or there's no valid default page, then show an inactive link? (true/false)
// (if false, don't create a menu entry for that language)
$show_inactive = isset($params['show_inactive']) ? $params['show_inactive'] : true;


// ----------------------------------------------------------------
// Constants

define ("DEFAULT_PAGE",0);
define ("BUTTON",1);


// ----------------------------------------------------------------
// Language data common to all pages

/*
The array $languages keeps information about all languages of the site.
It is indexed by the language code.

Every item is an array that contains two items:
0) The optional default page for the language (used when there's no valid translation, if the parameter show_default is true). It can be empty (and then the parameter show_inactive will decide what to do).
1) The HTML code of the link button (used when the parameter show_title is false or unset).
To make the code more readable, these items are accessed with the constants DEFAULT_PAGE and BUTTON in the main loop.

*/

// Example data
$it='<img src="uploads/images/flags/it.png" alt="IT" />';
$en='<img src="uploads/images/flags/gb.png" alt="EN" />';
$fr='<img src="uploads/images/flags/fr.png" alt="FR" />' ;
$es='<img src="uploads/images/flags/es.png" alt="FR" />' ;

$languages = array(
//  'it' => array('Italiano', '<span xml:lang="it">' . $it . '</span>'),
  'it' => array('Italiano',  $it ),
//  'en' => array('English', '<span xml:lang="en">' . $en . '</span>'),
  'en' => array('English',  $en ),
//  'fr' => array('French', '<span xml:lang="fr">' . $fr . '</span>')
  'fr' => array('French',  $fr )
);


// ----------------------------------------------------------------
// Variables about the current page

$page_lang = $smarty->get_template_vars('page_lang'); // assigned in the template by the User Defined Tag {assign_page_lang}


// ----------------------------------------------------------------
// Language versions of the current page

/*
The template variable $other_languages is assigned with a content block in the template. eg.:
{content block='Other languages' oneline='true' assign=other_languages wysiwyg='false'}
For every page, it has to filled with a string in the following format:
"c1=page1;c2=page2;c3=page3" (no spaces allowed),
where c(n) are language codes (two letters);
any number of languages can be specified in any order.
That string is converted into the array $language_versions.
*/

$other_languages = $smarty->get_template_vars('other_languages');
foreach ( explode(';', $other_languages) as $other_language )
{
  $language_codes[]=substr($other_language, 0, 2);
  $language_pages[]=substr($other_language, 3);
}
if (!function_exists('array_combine')) {
    function array_combine($keys, $values)
    {
        if (!is_array($keys)) {
            user_error('array_combine() expects parameter 1 to be array, ' .
                gettype($keys) . ' given', E_USER_WARNING);
            return;
        }

        if (!is_array($values)) {
            user_error('array_combine() expects parameter 2 to be array, ' .
                gettype($values) . ' given', E_USER_WARNING);
            return;
        }

        $key_count = count($keys);
        $value_count = count($values);
        if ($key_count !== $value_count) {
            user_error('array_combine() Both parameters should have equal number of elements', E_USER_WARNING);
            return false;
        }

        if ($key_count === 0 || $value_count === 0) {
            user_error('array_combine() Both parameters should have number of elements at least 0', E_USER_WARNING);
            return false;
        }

        $keys    = array_values($keys);
        $values  = array_values($values);

        $combined = array();
        for ($i = 0; $i < $key_count; $i++) {
            $combined[$keys[$i]] = $values[$i];
        }

        return $combined;
    }
}


$language_versions = array_combine($language_codes, $language_pages);


/*
echo '<p><strong>DEBUG</strong>:';
echo "<br/>language_codes="; print_r($language_codes);
echo "<br/>language_pages="; print_r($language_pages);
echo "<br/>language_versions="; print_r($language_versions);
echo '</p>';
*/


// ----------------------------------------------------------------

function smarty_tag ($smarty_tag)
{

  // Call a smarty tag.
  // Reference:
  // http://wiki.cmsmadesimple.org/index.php/User_Handbook/Admin_Panel/Extensions/User_Defined_Tags#How_to_Execute_Smarty_Tags_from_A_User_Defined_Tag_.28UDT.29


$gCms = cmsms();
$db = cmsms()->GetDb();
$smarty = cmsms()->GetSmarty();

@ob_start();
$smarty->display('eval:'.$smarty_tag);
$_contents = @ob_get_contents();
@ob_end_clean();
echo $_contents;

}


// ----------------------------------------------------------------

function smarty_cms_selflink ($page, $text, $more)
{

  // Call the CMSMS tag {cms_selflink}.

/*
echo "<!--" ."\n"; 
  echo '<p><strong>smarty_self_link DEBUG</strong>:'."\n";
  echo "<br/>page=$page". "\n";
  echo "<br/>text=$text" . "\n";
  echo "<br/>more=$more" ."\n";
  echo '</p>' ."\n";
echo "-->"."\n";
*/

smarty_tag ("{cms_selflink page=\"$page\""  .( (empty($text)) ? '' : " text='$text'" ) . ' more="' . $more . '"}');

}


// ----------------------------------------------------------------

function valid_page($page_alias)
{

  // Is a page alias valid?

  // References:
  // http://forum.cmsmadesimple.org/index.php/topic,3778.msg20921.html#msg20921

$gCms = cmsms();


  $manager =& $gCms->GetHierarchyManager();
  $node =& $manager->getNodeByAlias($page_alias);
  return ( $node != null );

}


// ----------------------------------------------------------------

function current_page_title()
{

  // Return the title of the current page.
  // This is needed only to print and inactive link to the current page when $show_title==true.

  // References:
  // http://forum.cmsmadesimple.org/index.php/topic,3778.msg20921.html#msg20921
  // http://forum.cmsmadesimple.org/index.php/topic,3778.msg21051.html#msg21051

$gCms = cmsms();


  $this_page = $gCms->variables['content_id'];
  $manager =& $gCms->GetHierarchyManager();
  $node =& $manager->GetNodeById($this_page);
  $content =& $node->getContent();
  return $content->Name();

}


// ----------------------------------------------------------------
// Create the menu

/*
echo '<p><strong>DEBUG</strong>:';
echo "<br/>page_lang=$page_lang";
echo "<br/>show_title=$show_title";
echo "<br/>show_current=$show_current";
echo "<br/>page_title=$page_title";
echo "<br/>language_versions="; print_r($language_versions);
echo "<br/>language_buttons="; print_r($language_buttons);
echo '</p>';
*/

echo "\n" . '<ul>'."\n";

foreach ( $languages as $language_code => $language )  // explore all possible languages of the site
{

  // $language_code = code of the language to create a link for
  // $language[DEFAULT_PAGE] = the default page used when no alternative has been defined for the language
  // $language[BUTTON] = HTML used as button for the link, when $show_title==false.


  /*
  echo '<p><strong>menu DEBUG</strong>:';
  echo "<br/>language_code=$language_code";
  echo "<br/>language="; print_r($language);
  echo '</p>';

  */

  if ( $language_code != $page_lang )
  {
    $alternative_page = $language_versions[$language_code];
    // echo "alternative_page=$alternative_page"; // DEBUG
    if ( valid_page($alternative_page) )
    {
      echo '<li>'."\n";
      // echo "ALTERNATIVE: $alternative_page"; // DEBUG
     
      smarty_cms_selflink($alternative_page,($show_title == true ) ? "" : $language[BUTTON], "hreflang='".$language_code. "'");
      echo '</li>'."\n";
    }
    else // no alternative page is valid for this language
    {
      if ( $show_default == true and valid_page($language[DEFAULT_PAGE]) )
      {
        echo '<li>'."\n";
        // echo 'NO ALTERNATIVE! DEFAULT: '; // DEBUG
        smarty_cms_selflink($language[DEFAULT_PAGE],( ($show_title == true ) ? "" : $language[BUTTON] ) , "hreflang='".$language_code."'");
        echo '</li>'. "\n";
      }
      else
      {
        if ( $show_inactive == true )
        {
          echo '<li class="inactive">'."\n";
          // echo 'DEFAULT CAN NOT BE USED! INACTIVE BUTTON: '; // DEBUG
          echo $language[BUTTON] . '</li>'."\n";
        }
      }
    }
  }
  elseif ( $show_current == true )
  {
    // echo 'SHOW CURRENT'; // DEBUG
    echo '<li class="currentpage">' .'\n' . ( ($show_title == true) ? current_page_title() : $language[BUTTON] ) . '</li>'."\n";
  }
}
echo '</ul>'."\n";


Just my 2-cents.
Regards
blast


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 131 posts ]  Go to page Previous  1 ... 5, 6, 7, 8, 9

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting