News:

SMF 2.1.6 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

st1905

I`ve installed it at my forum but when i want to change the language nothing happens.I`m using mirage theme with smf+tinyportal latest.

Here it is www.dijitaldunyaforum.info/Forum [nofollow]

SleePy

It appears to be working for me.
It only changes the language strings in SMF.
It wont change posts and such into other languages. It is the equivalent of going to your profile and changing your language.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

lonrot

I neeed the index.template code to edit my custom theme.
Pretty please!

SleePy

It is simple

Add this function before the end of the script (before ?>)

// 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="', $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><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];
}


Now where you want it to appear use template_language_select();

like
echo template_language_select();
or
echo 'HTML', template_language_select(), 'More HTML';

If you post the snippet of code of where you want it added (with a clear marker of exactly where I can help you get it into there.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

bodygraber

I installed and everything seems to work but.... it displays language name funny like it needs to be bigger? see attachments

SleePy

It is displaying them fine.
I don't remember the cause of that but I think it is a bug with the files name itself.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

bodygraber

Yes it displays the selection fine. what I meant was you can choose English or fpanish (not an f really but closest i could get). where would I look?

SleePy

The name is gathered from the file names.
look in /Themes/default/languages
the language files there is where it gathers its name from based on the format index.<language>.php.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

ahmadovetch

SleePy, thanks for the efforts ... I wonder why dont you put the function body in a separate file and just include it in the php pages. I think this is better than copying the code for every theme. wont upgrades be easier ? im originally a java developer so i dont know much about php, execuse my ignorance :)

SleePy

besides the index.template.php there is no theme file that is included on every page. but I am thinking of new ways to do it. Hopefully can figure it out.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

FreeSporePrints

Hello SleePy,
i haven' installed any language except the default in English, however i've installed your mod because i think that in future i'll add Italian on "my" SMF but appareantly doesn't appear nothing..is normal?

Thanks :)
Fabio

SleePy

Are you using a non default theme?
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

kissboy


mhf

Can anyone help me add Language Drop Down to the Oxygen theme?
I put the code in and it really messed up the theme - didn't look much like Oxygen anymore - even though the drop-down box was there - so that worked !
I would like the drop-down box to be on the same line as the search box...
Thanks.
As the King of Hearts said to the White Rabbit : "begin at the beginning, go on to the end, then stop"

SleePy

Can you tell me what changes you made?
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

mhf

Thanks Sleepy,
I added the code as in your message of the 28th June at the end of the page as instructed but don't understand the bit about where to place it.
Thanks again !
As the King of Hearts said to the White Rabbit : "begin at the beginning, go on to the end, then stop"

SleePy

Which part of the code?
The one I used in code tags goes near the end just before the ?> part. It is another function.

Then the second part is the part that calls the function, which you place where you want it to appear.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

mhf

I'm talking about :
Quote from: SleePy on November 18, 2007, 07:14:48 PM
Which part of the code?
The one I used in code tags goes near the end just before the ?> part. It is another function.

Again : Sorry about my ignorance (I can hear everyone here laughing) but are we talking about adding the two bits of code to the default theme index.template.php or the Oxygen theme boardindex.template.php ? Or both ?
Thanks again.
As the King of Hearts said to the White Rabbit : "begin at the beginning, go on to the end, then stop"

L'AltroWeb

Hi thank'you for this nice mod!
I have babylon theme on smf 1.1.4.
And i have put code here:
find:
// If the user is logged in, display stuff like their name, new messages, etc.
Replace with:
echo template_language_select();

// If the user is logged in, display stuff like their name, new messages, etc.
and all work fine but i have two small questions:
1) How i can enlarge form Language (like this forum)?
2) How i can insert text "Select language:" (like this forum)?
Thanks in advance, DarkWolf
PS sorry for my bad english  :-[

SleePy

To add some text simply just add it to the echo

echo 'Select Language:', template_language_select();

As for the size, this is a bit tricker.

I don't know the code off the top of my head, but this would require you adding some css to your style.css file that designs the select box.
Not all browsers will accept changes though.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Advertisement: