News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Language Drop Down

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

Previous topic - Next topic

Matthew K.

Link to Mod
Rate this Mod

                 
Language Drop Down 1.5.3
                       
Author:
                   
SleePy
                       
Developer:
                   
Masterd

This Mod allows you to have a Language Drop down menu on your Site.
Language checking courtesy of JayBachatero aka Jay the Code Monkey

Version 1.5.2 (Not Released)
! Updated for SMF 1.1.13 and SMF 2.0 RC5

Version 1.5.2 (Not Released)
! Updated for SMF 2.0 RC4

Version 1.5.1
! Updated for SMF 2.0 RC3

Version 1.5
! Many changes to work with 2.0 RC2

Version 1.4.4
! We where not stripping slashes after we got it from the database.
! Added a Function check to prevent duplicate functions. (SMF 2.0 Only)
! Updated Support for of only SMF 2.0 Beta 4
! Use the default SMF Caching system for caching languages (SMF 2.0 Only)

Version 1.4.3
! Added Support for 2.0 Beta 3 Public
! Dropped Support for older 2.0 Betas

Version 1.4.2
! Added 2.0 Beta 2.1 Support

Version 1.4.1
! Added 2.0 Beta 2 Support

Version 1.4
! Sort the unique languages out
! Reworked for 2.0 Beta 1.1 to handle caching correctly.
! Actually read from cache.

Version 1.3.0
! Removed String from action. Blank action means refreshing on any page.
! Works with SMF 2.0 Beta 1
! (SMF 2.0 Beta 1) Fixed Possible reoccurring database updates.
- (SMF 2.0 Beta 1) Removed Cache Checks. We use modSettings that already has Cache work done.

Version 1.2.1
! Missed $scripturl in template

Version 1.2
! Don't use Empty Requests.
+ Non-Existing Directories prevention
! Don't Update If your MEMBER ID is 0
! Fixed possible bad languages Directory
+ Sorting of Languages
! Fixed Cache Problems
+ New Template for mod for easy addition.
! Follows Mod Guideline better
+ Other Minor Typos and changes

Version 1.0.1
! Globalize txt
! Removed Testing Install code.

Version 1.0
! Release

husmen73 (Gulhin)

Thanks Sleepy and Jay the Code Monkey ;)
-Kurumsal Kimlik Web Tasarım Hizmeti.
Gülhin Portal Sistemi hakkında yorumlarınızı bekliyorum.
SMF
Referanslar --> http://www.gulhin.com/referanslar-portfoy/
-Web Tasarımı ve Tema Tasarımı Sitesi www.gulhin.com
-TOPLU MAİL GÖNDERİMİ --> http://www.toplumailsms.com
E-Ticaret Sistemi yaptırmak mı istiyorsunuz?

sawz

its about time someone made this mod. nice work outa you. :)
keep smiling, they'll always wonder what your up too.....

edi67

i have always this error:

8: Undefined variable: txt
File: /home2/crazyzonews/www/Sources/Load.php
Linea: 2376


Line 2376 this:
</select>&nbsp;<noscript><input type="submit" value="', $txt['quick_mod_go'], '" /></noscript></form>';

so i must add in modifications variable $TXT ???
CrazyZone - My SMF Forum


From the difficult the hardening of the man you can see

SleePy

No,

Go ahead and either Upload the new package and upgrade it or uninstall the old one and install this one. I uploaded 1.0.1 which fixed this.
The changes for 1.0.1 include:

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

edi67

CrazyZone - My SMF Forum


From the difficult the hardening of the man you can see

billchopher

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?

Bill Boyd
http://eslpal.com [nofollow]

chrishead168

i have a problem with installing the new version.

Fatal error: Cannot redeclare languagedrop() (previously declared in /home/acodersp/public_html/smf/Sources/Load.php:2233) in /home/acodersp/public_html/smf/Sources/Load.php on line 2321

althought i should be able 2 fix that why did it happen?

japanlinked

I really want this mod. I installed it on the newest version 1.1.1 with the theme levithan. But I do not see the modification anywhere? Will it work with the theme do I need to activate it in one of the admin options?  forum is here hxxp:www.japanlinked.com/forum [nonactive]

Your help will be awsome I run a Japan information site. hxxp:www.japanlinked.com [nonactive]

Xarcell

Quote from: japanlinked on January 12, 2007, 12:32:07 PM
I really want this mod. I installed it on the newest version 1.1.1 with the theme levithan. But I do not see the modification anywhere? Will it work with the theme do I need to activate it in one of the admin options?  forum is here http://www.japanlinked.com/forum

Your help will be awsome I run a Japan information site. www.japanlinked.com

I'm guessing you need to insert the code manually for your custom themes.

japanlinked

Would you happen to have a sample of where to insert the code

edi67

Quote from: chrishead168 on January 12, 2007, 10:58:14 AM
i have a problem with installing the new version.

Fatal error: Cannot redeclare languagedrop() (previously declared in /home/acodersp/public_html/smf/Sources/Load.php:2233) in /home/acodersp/public_html/smf/Sources/Load.php on line 2321

althought i should be able 2 fix that why did it happen?


in load.php you have for 2 time double code installed, open that file with client FTP edit it go near line 2321 check and delete the double part of code, all will work correctly
CrazyZone - My SMF Forum


From the difficult the hardening of the man you can see

SleePy

Quote from: chrishead168 on January 12, 2007, 10:58:14 AM
i have a problem with installing the new version.

Fatal error: Cannot redeclare languagedrop() (previously declared in /home/acodersp/public_html/smf/Sources/Load.php:2233) in /home/acodersp/public_html/smf/Sources/Load.php on line 2321

althought i should be able 2 fix that why did it happen?


The mod for some reason duplicated itself when installing. This may mean code is in there twice.

You can send me your Load.php and I can fix it or you can try it youself by looking for this set of code twice and removing one of them


// Do the languageDrop...
function languageDrop($check = 0, $languagecheck = null)
{
global $modSettings, $func, $context, $scripturl, $settings, $txt;

// Jay didn't think of it already being set.. bad monkey...
if(empty($context['languages']))
{
// Do this the old fashion way if cache is old or not set
if (empty($modSettings['cache_enable']) && empty($modSettings['selectLanguage']) || (isset($modSettings['selectLanguageTime']) && time() - $modSettings['selectLanguageTime'] < 86400))
{
// Are languages user selectable?  If so, get a list.
$context['languages'] = array();

$language_directories = array(
$settings['default_theme_dir'] . '/languages',
$settings['actual_theme_dir'] . '/languages',
);
if (!empty($settings['base_theme_dir']))
$language_directories[] = $settings['base_theme_dir'] . '/languages';
$language_directories = array_unique($language_directories);

foreach ($language_directories as $language_dir)
{
if (!file_exists($language_dir))
continue;

$dir = dir($language_dir);
while ($entry = $dir->read())
{
// Each language file must *at least* have a 'index.LANGUAGENAME.php' file.
if (preg_match('~^index\.(.+)\.php$~', $entry, $matches) == 0)
continue;

$context['languages'][$matches[1]] = array(
'name' => $func['ucwords'](strtr($matches[1], array('_' => ' ', '-utf8' => ''))),
'filename' => $matches[1],
);
}
$dir->close();
}

$selectLanguage = serialize($context['languages']);
}

if (($modSettings['selectLanguage'] = cache_get_data('selectLanguage', 86400)) == null)
{
if (!empty($modSettings['cache_enable']))
cache_put_data('selectLanguage', $modSettings['selectLanguage'], 86400);
elseif (empty($modSettings['selectLanguage']) || (isset($modSettings['selectLanguageTime']) && time() - $modSettings['selectLanguageTime'] < 86400))
updateSettings(array(
'selectLanguage' => addslashes($selectLanguage),
'selectLanguageTime' => time(),
));
}
}

// hmm.. If this is true we are validating the language selection..
if($check == 1 && $languagecheck != null)
{
$context['languagescheck'] = array();
$i = 0;
foreach($context['languages'] as $language)
$context['languagescheck'][$i++] = $language['filename'];

// Not a valid Language? Forget it...
if(!in_array($languagecheck, $context['languagescheck']))
return $languagecheck;

return $languagecheck;
}


// No Reason to Show it if nothing exists..
elseif(!empty($context['languages']))
{
echo '
<form action="', $scripturl , !empty($_REQUEST['action']) ? '?action=' . $_REQUEST['action'] . (!empty($_REQUEST['sa']) ? ';sa=' . $_REQUEST['sa'] : '' ) : '', '" 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>&nbsp;<noscript><input type="submit" value="', $txt['quick_mod_go'], '" /></noscript></form>';
}

}




Quote from: japanlinked on January 12, 2007, 12:32:07 PM
I really want this mod. I installed it on the newest version 1.1.1 with the theme levithan. But I do not see the modification anywhere? Will it work with the theme do I need to activate it in one of the admin options?  forum is here http://www.japanlinked.com/forum

Your help will be awsome I run a Japan information site. www.japanlinked.com

This mod will work with your custom theme. Just put this where ever you want it to appear
languageDrop();

If you are in a echo such as
echo '
<td class="titlebg2" align="right" nowrap="nowrap" valign="top"></td>

And want to insert it use , around it and don't use the ;
So it will look like:

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


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?



billchopher, Read my above reply to japanlinked's problem. This should help you.
If you find a good play for it on the forum feel free to send me what you changed so I can include it in future updates of my mod.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

billchopher

Hi I got it working fine now!

Here's what I did:

1. I went into my cpanal and deleted all files accociated with prevoius intallations.

2. Starting with a clean sheet, I then made sure I had permisions set to 777, in: themes/default/index.template.php--- sources/load.php ---- and of course packages/......

3. I then made a new folder called "temp" in the packages directory.

4. then I installed it through the forum interface no problems.

5. then deleated all the temp files (themes/default/index.template.php~ and sources/load.php~ and the temp folder, so now it all works fine.

Also  When I was first intalling and unistalling over and over I also got the error about "can't call in line.... already called etc...   I simply opened the file concerned in dreamweaver to find the error on the line mentioned and removed it because it was just a duplicate.

I hope this helps someone because this thread has helped me heaps :D
Bill Boyd
http://eslpal.com [nofollow]

babjusi

I have installed this mod recently in my forum, and gotta say, it''s very useful and handy. Thank u SleePy and JayBachatero for creating and sharing this mod with us

Elegant John

I would love to use this on my forum but I am stuck!

The mod installed perfectly without problems, now the question is, How do I get the drop down to appear?

Is there supposed to be some function in the ACP to enable this?

I tried moding the display template index resulting in a pare error.

I am using the default theme with colors modified.

http://www.ladiesofnuevolaredo.com

Thanks in advance

babjusi

Quote from: Elegant John on January 17, 2007, 11:45:13 AM
I would love to use this on my forum but I am stuck!

The mod installed perfectly without problems, now the question is, How do I get the drop down to appear?

Is there supposed to be some function in the ACP to enable this?

I tried moding the display template index resulting in a pare error.

I am using the default theme with colors modified.

http://www.ladiesofnuevolaredo.com

Thanks in advance

Which SMF version r u running? Cause the mod is compatible With: 1.1, 1.1.1.

Elegant John

Sorry, Always the newest....1.1.1 with TP .97

SleePy

This mod only installs for the Default theme at the moment.
If you use another theme you will have to manually add in the appropriate code into the theme.

This is very simple if you follow the Edits I did to the default theme and apply those to your custom theme.
If you would like to submit your changes to your custom theme so it appears in future updates of this mod you can feel free to do so by sending them to me.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Elegant John

Actually, this is the default theme. The only thing different is the color.  Where can I find these edits you refer to?

Advertisement: