Advertisement:

Author Topic: Language Drop Down  (Read 156282 times)

Offline Matthew K.

  • SMF Super Hero
  • *******
  • Posts: 12,430
  • Gender: Male
    • matthew.kerle on Facebook
    • @matthew_kerle on Twitter
Language Drop Down
« on: January 02, 2007, 11:41:04 PM »
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
« Last Edit: February 23, 2011, 04:04:49 PM by Masterd »

Offline husmen73 (Gulhin)

  • SMF Hero
  • ******
  • Posts: 3,687
  • Gender: Male
  • Bana ulaşmak için lütfen e-posta gönderin.
    • Gülhin İnternet
Re: Language Drop Down
« Reply #1 on: January 03, 2007, 07:41:25 AM »
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?

Offline sawz

  • SMF Hero
  • ******
  • Posts: 3,362
  • Gender: Male
  • i'm....controversial
Re: Language Drop Down
« Reply #2 on: January 04, 2007, 05:35:20 PM »
its about time someone made this mod. nice work outa you. :)

Offline edi67

  • SMF Hero
  • ******
  • Posts: 1,532
  • Gender: Male
  • Italian Supporter
    • CrazyZone
Re: Language Drop Down
« Reply #3 on: January 10, 2007, 03:59:44 AM »
i have always this error:

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

Line 2376 this:
Code: [Select]
</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

Offline SleePy

  • Site Team Lead
  • SMF Master
  • *
  • Posts: 29,880
  • Gender: Male
  • Thats his happy face.
    • jdarwood007 on GitHub
    • @jdarwood on Twitter
    • SleePy Code - My personal site
Re: Language Drop Down
« Reply #4 on: January 10, 2007, 10:22:46 PM »
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
Support the SMF Support team!
Profiles:
GitHub
G+

Offline edi67

  • SMF Hero
  • ******
  • Posts: 1,532
  • Gender: Male
  • Italian Supporter
    • CrazyZone
Re: Language Drop Down
« Reply #5 on: January 12, 2007, 01:01:49 AM »
perfectly work now thx  ;)
CrazyZone - My SMF Forum


From the difficult the hardening of the man you can see

Offline billchopher

  • Semi-Newbie
  • *
  • Posts: 15
    • ESLPAL English as a Second Language, Practice And Learn
Re: Language Drop Down
« Reply #6 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?

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

Offline chrishead168

  • Newbie
  • *
  • Posts: 1
Re: Language Drop Down
« Reply #7 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?

Offline japanlinked

  • Newbie
  • *
  • Posts: 7
Re: Language Drop Down
« Reply #8 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 hxxp:www.japanlinked.com/forum [nonactive]

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

Offline Xarcell

  • SMF Hero
  • ******
  • Posts: 1,684
  • Gender: Male
  • SMF-DP Supporter
Re: Language Drop Down
« Reply #9 on: January 12, 2007, 12:38:25 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.

Offline japanlinked

  • Newbie
  • *
  • Posts: 7
Re: Language Drop Down
« Reply #10 on: January 12, 2007, 12:41:00 PM »
Would you happen to have a sample of where to insert the code

Offline edi67

  • SMF Hero
  • ******
  • Posts: 1,532
  • Gender: Male
  • Italian Supporter
    • CrazyZone
Re: Language Drop Down
« Reply #11 on: January 13, 2007, 12:45:51 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

Offline SleePy

  • Site Team Lead
  • SMF Master
  • *
  • Posts: 29,880
  • Gender: Male
  • Thats his happy face.
    • jdarwood007 on GitHub
    • @jdarwood on Twitter
    • SleePy Code - My personal site
Re: Language Drop Down
« Reply #12 on: January 13, 2007, 01:01:16 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

Code: [Select]
// 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>';
}

}



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
Code: [Select]
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:
Code: [Select]
echo '
<td class="titlebg2" align="right" nowrap="nowrap" valign="top">', languageDrop(), '</td>';

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
Support the SMF Support team!
Profiles:
GitHub
G+

Offline billchopher

  • Semi-Newbie
  • *
  • Posts: 15
    • ESLPAL English as a Second Language, Practice And Learn
Re: Language Drop Down
« Reply #13 on: January 16, 2007, 01:56:43 AM »
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

  • Guest
Re: Language Drop Down
« Reply #14 on: January 16, 2007, 02:06:14 AM »
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

Offline Elegant John

  • Jr. Member
  • **
  • Posts: 120
Re: Language Drop Down
« Reply #15 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

babjusi

  • Guest
Re: Language Drop Down
« Reply #16 on: January 17, 2007, 11:53:33 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.

Offline Elegant John

  • Jr. Member
  • **
  • Posts: 120
Re: Language Drop Down
« Reply #17 on: January 17, 2007, 11:57:42 AM »
Sorry, Always the newest....1.1.1 with TP .97

Offline SleePy

  • Site Team Lead
  • SMF Master
  • *
  • Posts: 29,880
  • Gender: Male
  • Thats his happy face.
    • jdarwood007 on GitHub
    • @jdarwood on Twitter
    • SleePy Code - My personal site
Re: Language Drop Down
« Reply #18 on: January 18, 2007, 12:43:47 AM »
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
Support the SMF Support team!
Profiles:
GitHub
G+

Offline Elegant John

  • Jr. Member
  • **
  • Posts: 120
Re: Language Drop Down
« Reply #19 on: January 18, 2007, 05:24:24 AM »
Actually, this is the default theme. The only thing different is the color.  Where can I find these edits you refer to?