News:

Wondering if this will always be free?  See why free is better.

Main Menu

Language Drop Down

Started by Matthew K., January 02, 2007, 11:41:04 PM

Previous topic - Next topic

SleePy

You would add it to the style.css. You need to add your own.
Something such as this may work:

.smalltext #language_select
{
    font-size: x-large;
}
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Cheese Head

SleePy, thanks, worked perfect!

I switched mine to small as X-large was way too big for me.

Thanks again!

tidus93

Hello,

First thanks for this mod very useful  ;).
Then I just want to say (if that hadn't be said) that we must set up a default language to the forum before using this mod (Settings.php). If not, there is a lot of problem for user who come for the first time (who hasn't set up his language).

Privacy Blocked

Quote from: SleePy on November 23, 2008, 03:41:10 PM
Alright.
If you open the Themes index.template.php

Find:
  </div>

  <div id="mainarea">


Add Before:
', template_language_select(), '

Make sure you add the other edit to the index.template.php as well. This one works on all themes :)

hiii sleepy i got error in smf 1.1.8 in PSBlack Themes liker his



this iam attach my index.template.php and load.php

thanks

SleePy

Quote<b>Fatal error</b>:  Call to undefined function template_language_select() in <b>/home2/abghotco/public_html/smf/Sources/Load.php(1726) : eval()'d code</b> on line <b>213</b><br />

The index.template.php dosn't have the template function. Manually edit the index.template.php for your theme, and add in this function.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Privacy Blocked

Quote from: SleePy on April 25, 2009, 04:35:15 PM
Quote<b>Fatal error</b>:  Call to undefined function template_language_select() in <b>/home2/abghotco/public_html/smf/Sources/Load.php(1726) : eval()'d code</b> on line <b>213</b><br />

The index.template.php dosn't have the template function. Manually edit the index.template.php for your theme, and add in this function.

i don't know what u mean the code. can  u explain master ? sory i'm newbiez

SleePy

Add this the end of your custom themes index.template.php, just before the "?>".


// Generate the Language Drop Down..
function template_language_select()
{
    global $context, $txt, $scripturl;

    // Do the Function...
    languageDrop();

    // Hopefully We always have something to show for ourselves.
    if (!empty ($context['languages']))
    {
        echo '
            <form action="" method="post" class="smalltext" style="float: right;">
                <select id="language_select" name="language" onchange="this.form.submit()" class="smalltext">';
        foreach ($context['languages'] as $language)
            echo '
                    <option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', $language['name'], '</option>';
        echo '
                </select><input type="hidden" name="changelang" value="1" />&nbsp;<noscript><input type="submit" value="', $txt['quick_mod_go'], '" /></noscript></form>';
    }
    // No languages we can find!
    elseif (empty ($context['languages']))
        echo 'LanguageDrop: ' . $txt[398];
    // If this occurs we are in trouble.
    else
        echo 'LanguageDrop: ' . $txt[106];
}

Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Privacy Blocked

Quote from: SleePy on April 25, 2009, 09:43:00 PM
Add this the end of your custom themes index.template.php, just before the "?>".


// Generate the Language Drop Down..
function template_language_select()
{
    global $context, $txt, $scripturl;

    // Do the Function...
    languageDrop();

    // Hopefully We always have something to show for ourselves.
    if (!empty ($context['languages']))
    {
        echo '
            <form action="" method="post" class="smalltext" style="float: right;">
                <select id="language_select" name="language" onchange="this.form.submit()" class="smalltext">';
        foreach ($context['languages'] as $language)
            echo '
                    <option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', $language['name'], '</option>';
        echo '
                </select><input type="hidden" name="changelang" value="1" />&nbsp;<noscript><input type="submit" value="', $txt['quick_mod_go'], '" /></noscript></form>';
    }
    // No languages we can find!
    elseif (empty ($context['languages']))
        echo 'LanguageDrop: ' . $txt[398];
    // If this occurs we are in trouble.
    else
        echo 'LanguageDrop: ' . $txt[106];
}


./Themes/default/index.template.php

Find:

</td>';
echo '
<td class="titlebg2" align="right" nowrap="nowrap" valign="top">


Replace With:


</td>
<td class="titlebg2" nowrap="nowrap" valign="top">';
template_language_select();
echo '
</td>
<td class="titlebg2" align="right" nowrap="nowrap" valign="top">


in the top code i don't find the

</td>';
echo '
<td class="titlebg2" align="right" nowrap="nowrap" valign="top">



and i finish add the code

// Generate the Language Drop Down..
function template_language_select()
{
    global $context, $txt, $scripturl;

    // Do the Function...
    languageDrop();

    // Hopefully We always have something to show for ourselves.
    if (!empty ($context['languages']))
    {
        echo '
            <form action="" method="post" class="smalltext" style="float: right;">
                <select id="language_select" name="language" onchange="this.form.submit()" class="smalltext">';
        foreach ($context['languages'] as $language)
            echo '
                    <option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', $language['name'], '</option>';
        echo '
                </select><input type="hidden" name="changelang" value="1" />&nbsp;<noscript><input type="submit" value="', $txt['quick_mod_go'], '" /></noscript></form>';
    }
    // No languages we can find!
    elseif (empty ($context['languages']))
        echo 'LanguageDrop: ' . $txt[398];
    // If this occurs we are in trouble.
    else
        echo 'LanguageDrop: ' . $txt[106];
}


but the same image like this



please help and check my attachment


SleePy

Alright, you added it to the template and got rid of the error :)

Now you just need to pick the place in your theme and add in the call to the template.

Most likely you will just need to use:
', template_language_select(), '

That and add it in where you want it in your theme :)
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

MissyNL

I want to ask.. i am now installing a forum ... and i want to install youre  mod... :)

But... when it's uploaded, i get the text : There are no install actions defined..

it's for SMF 2... so i used version 3
Sorry for my poor English, but i think it's probably better then your Dutch :)

KensonPlays

Quote from: billchopher on January 12, 2007, 03:07:08 AM
Hi, this would be great for my ESL site if I could get it to work for me! I am new to SMF and site building so this could be a simple question.
I have managed to upload the mod through the admin panel and have "aplied" it. Everything says "success" but there is no dropdown showing on the site?

I have the funtion for users to change their language in the profile area but I what a dropdown like the one on this forum. Can you tell me how?

I am having same problem, I have a different theme than default, do you have YOUR OWN DIFFERENT theme than default?
Hey, mod owner, what is coding for Efsane theme?

Owner of Mesozoic Haven

Daveyo

Sleepy

I installed your mod on version 1.1.9 and all I have is English showing up and none of the other languages.  sigh

No errors show up and it shows green as installed on my packages.

Why only English show up??  Am I missing something here.??

I downloaded it, to my computer, then uploaded on the package manager, and it was installed.  I see it on my default theme of which I also want my other members to use instead of using different themes.  So what did I do wrong or do I have to edict this mod.  If so where to find this file in the Cpanel and where to edict it properly.

Just covering all the basics here because I have no idea why only English work.  I uploaded as a tar zip file in the package manager.

Hope you can respond as this mod is much needed for others world wide to read my forum etc.

I am a newbie in all this so hopefully you can be gentle with me on questions and answers here as I cannot understand chinese!!!!  hehehehehehe.

Thanks

Daveyo

tkoenings

This could be very helpful for what I need, would like to try it, but have the drop down appear in the same div as the search box (aligned left) since I have removed the other section of the header where the drop down would normally be placed.

I tried to parse the newest version on the mod site to get the code but this throws an error (other versions parse).

I also tried to upload the package to my test forum but applying it throws an error as well, but could be because it can't find the section in index.template.php.

Would it be difficult to enable this inserting the code, and what are the instructions for manually enabling this? Here is my index.template.php:


</head>
<body>';
}

function template_body_above()
{
   global $context, $settings, $options, $scripturl, $txt, $modSettings;

   echo '

      
      <div id="news_section" class="titlebg2 clearfix"', empty($options['collapse_header']) ? '' : ' style="display: none;"', '>
         <form class="floatright" id="search_form" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
            <a href="', $scripturl, '?action=search;advanced" title="', $txt['search_advanced'], '"><img id="advsearch" src="'.$settings['images_url'].'/filter.gif" align="middle" alt="', $txt['search_advanced'], '" /></a>
            <input type="text" name="search" value="" style="width: 190px;" />&nbsp;
            <input type="submit" name="submit" value="', $txt['search'], '" style="width: 11ex;" />
            <input type="hidden" name="advanced" value="0" />';

   // Search within current topic?
   if (!empty($context['current_topic']))
      echo '
            <input type="hidden" name="topic" value="', $context['current_topic'], '" />';
      // If we're on a certain board, limit it to this board ;).
   elseif (!empty($context['current_board']))
      echo '
            <input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';

   echo '
         </form>';

   // Show a random news item? (or you could pick one from news_lines...)
   if (!empty($settings['enable_news']))
      echo '
         <div id="random_news"><h3>', $txt['news'], ':</h3><p>', $context['random_news_line'], '</p></div>';

   echo '
      </div>
   </div>';


   // Show the menu here, according to the menu sub template.
   template_menu();

   // Show the navigation tree.
   theme_linktree();

   // The main content should go here.
   echo '
   <div id="bodyarea">';
}

function template_body_below()
{
   global $context, $settings, $options, $scripturl, $txt;

   echo '
   </div>';

   // Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
   echo '
   <div id="footerarea" class="headerpadding topmargin clearfix">
      <ul class="smalltext">
         <li class="copywrite">', !empty($settings['custom_copyright']) ? '<span class="smalltext">'. parse_bbc($settings['custom_copyright']). '</span>' : '', '<br />
                  ', theme_copyright(), '
</li>
         <li><a id="button_xhtml" href="http://validator.w3.org/check/referer [nofollow]" target="_blank" class="new_win" title="', $txt['valid_xhtml'], '"><span>XHTML</span></a></li>
         <li><a id="button_rss" href="', $scripturl , '?type=rss;action=.xml" class="new_win"><span>RSS</span></a></li>
         <li class="last"><a id="button_wap2" href="', $scripturl , '?wap2" class="new_win"><span>WAP2</span></a></li>
      </ul>';

   // Show the load time?
   if ($context['show_load_time'])
      echo '
      <p class="smalltext" id="show_loadtime">', $txt['page_created'], $context['load_time'], $txt['seconds_with'], $context['load_queries'], $txt['queries'], '</p>';

   echo '
   </div>
</div>';
}

function template_html_below()
{
   global $context, $settings, $options, $scripturl, $txt, $modSettings;

   echo '
</body></html>';
}

// Show a linktree. This is that thing that shows "My Community | General Category | General Discussion"..
function theme_linktree($force_show = false)
{
   global $context, $settings, $options, $shown_linktree;

   // If linktree is empty, just return - also allow an override.
   if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
      return;

   //!!! Temporarily don't do it twice.
   if (!empty($shown_linktree))
      return;
   $shown_linktree = true;

   echo '
   <ul id="linktree">';

   // Each tree item has a URL and name. Some may have extra_before and extra_after.
   foreach ($context['linktree'] as $link_num => $tree)
   {
      echo '
      <li', ($link_num == count($context['linktree']) - 1) ? ' class="last"' : '', '>';
      // Show something before the link?
      if (isset($tree['extra_before']))
         echo $tree['extra_before'];

      // Show the link, including a URL if it should have one.
      echo $settings['linktree_link'] && isset($tree['url']) ? '
         <a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>' : '<span>' . $tree['name'] .'</span>';

      // Show something after the link...?
      if (isset($tree['extra_after']))
         echo $tree['extra_after'];

      // Don't show a separator for the last one.
      if ($link_num != count($context['linktree']) - 1)
         echo '&nbsp;>';

      echo '
      </li>';
   }
   echo '
   </ul>';
}

// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
   global $context, $settings, $options, $scripturl, $txt;

   echo '
   <div id="main_menu">
      <ul class="clearfix">';

   foreach ($context['menu_buttons'] as $act => $button)
   {
      $classes = array();
      if (!empty($button['active_button']))
         $classes[] = 'active';
      if (!empty($button['is_last']))
         $classes[] = 'last';
      $classes = implode(' ', $classes);
      
      echo '
         <li id="button_', $act, '"', !empty($classes) ? ' class="' . $classes . '"' : '', '>
            <a title="', $act, '" href="', $button['href'], '">
               <span>', ($button['active_button'] ? '<em>' : ''), $button['title'], ($button['active_button'] ? '</em>' : ''), '</span>
            </a>
         </li>';
   }

   echo '
      </ul>
   </div>';
}

// Generate a strip of buttons.
function template_button_strip($button_strip, $direction = 'top', $custom_td = '')
{
   global $settings, $context, $txt, $scripturl;

   // Create the buttons...
   $buttons = array();
   foreach ($button_strip as $key => $value)
      if (!isset($value['test']) || !empty($context[$value['test']]))
         $buttons[] = '<a href="' . $value['url'] . '"' . (isset($value['active']) ? ' class="active"' : '') . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '><span>' . $txt[$value['text']] . '</span></a>';

   if (empty($buttons))
      return '';

   // Make the last one, as easy as possible.
   $buttons[count($buttons) - 1] = str_replace('<span>', '<span class="last">', $buttons[count($buttons) - 1]);

   echo '
      <div class="buttonlist', $direction != 'top' ? '_bottom' : '', '">
         <ul class="clearfix">
            <li>', implode('</li><li>', $buttons), '</li>
         </ul>
      </div>';
}

?>

Daveyo

Sleepy

Got a question to ask you.  Why doesn't the Slovenian Mod not work.  It is on the language drop down menu, but it does not do a thing to the forum to show the language being changed.

Is there something wrong with that mod or what.

I got all the others working fine. 

Also how to get the post pages or information to the specific languages so that people can read it in their language.  Is this possible or not.



Daveyo

Akyhne

This doesn't install in SMF1.1.10, although the code says:
<install for="1.1.2-1.1.99">
I tested it in several forums.

agridoc

I suggested the mod in a topic in Greek support board and the answer was that it doesn't install in SMF 1.1.10.

I searched a bit and found that

<install for="1.1.2-1.1.99">
Works with 1.1.9 not with 1.110

However
<install for="1.1.1-1.1.99">
as well as
<install for="1.1.2, 1.1.10">
work OK with SMF 1.1.10

So it's rather a small bug in SMF 1.1.10.
  For Greek aeromodellers and our friends around the world  - Greek Button sets for SMF - Greeklish to Greek mod
Δeν αφιερώνω χρόνο για μηνύματα σε greeklish.

kimnue

#236
hi i really wanna make my smf has 2 language
This is my web

i used theme ds-natural and i instll SMF version 1.1.10

this is my web
http://www.hms-agent.co.cc/


it cannot appy mod . Can anyone helpme ? DO i have to modified manually.?

Newbies on this

Thank

Akyhne

Quote from: kimnue on September 09, 2009, 12:42:57 PM
hi i really wanna make my smf has 2 language
This is my web

i used theme ds-natural and i instll SMF version 1.1.10

this is my web
http://www.hms-agent.co.cc/


it cannot appy mod . Can anyone helpme ? DO i have to modified manually.?

Newbies on this

Thank
Quote from: agridoc on August 07, 2009, 06:20:11 AM
I suggested the mod in a topic in Greek support board and the answer was that it doesn't install in SMF 1.1.10.

I searched a bit and found that

<install for="1.1.2-1.1.99">
Works with 1.1.9 not with 1.110

However
<install for="1.1.1-1.1.99">
as well as
<install for="1.1.2, 1.1.10">
work OK with SMF 1.1.10

So it's rather a small bug in SMF 1.1.10.

SleePy

Also adding ;version_emulate=1.1.9 to the end of the url, will make package manager think it is running a older version of SMF and allow you to install the mod.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

agridoc

If I remember well, I tried it and didn't work. The cause is that the bug in 1.1.10 interferes in version range parsing.
  For Greek aeromodellers and our friends around the world  - Greek Button sets for SMF - Greeklish to Greek mod
Δeν αφιερώνω χρόνο για μηνύματα σε greeklish.

Advertisement: