registration language selection

Started by cellax, June 28, 2011, 01:22:09 PM

Previous topic - Next topic

cellax

hi,

is there an easy way to select language during user registration? my forum is in english and italian

when I was using smf 1.1 there was a mod to do that, I cant find an updated mod.

thx

cellax


Antechinus

Anyone on the Customise team want to do a 2.0 version? Shouldn't be hard as there's not much code to it.

This is the old one: http://custom.simplemachines.org/mods/index.php?mod=747

cellax

#3
hi,

I worked on it, I am using it on localhost right now.

Code (Install2.xml) Select
<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>cellax:lngregistrationraid</id>
<version>1.0</version>
<file name="$languagedir/Modifications.english.php">
<operation>
<search position="after"><![CDATA[?>]]></search>
<add><![CDATA[$txt['registration_language_admin_field'] = 'Show language selection on registration form?';
$txt['language_menu_select_language'] = 'Select your language';

]]></add>
</operation>
</file>

<file name="$languagedir/Modifications.italian.php">
<operation>
<search position="after"><![CDATA[?>]]></search>
<add><![CDATA[$txt['registration_language_admin_field'] = 'Mostra la selezione della lingua durante la registrazione?';
$txt['language_menu_select_language'] = 'Seleziona la tua lingua';

]]></add>
</operation>
</file>

<file name="$sourcedir/Subs-Members.php">
<operation>
<search position="replace"><![CDATA['lngfile' => '',]]></search>
<add><![CDATA['lngfile' => $regOptions['langfile'],]]></add>
</operation>
</file>


<file name="$sourcedir/ManageSettings.php">

<operation>
<search position="before"><![CDATA[ $config_vars = array(
// Mod authors, add any settings UNDER this line. Include a comma at the end of the line and don't remove this statement!!]]></search>
<add><![CDATA[
// Registration - Show Language mod
array('check', 'registration_language_admin_field'),
// Registration - Show Language mod]]></add>
</operation>

</file>

<file name="$sourcedir/Register.php">

<operation>
<search position="before"><![CDATA['extra_register_vars' => array(),]]></search>
<add><![CDATA[
'langfile' => !empty($_POST['languagemenu']) ? $_POST['languagemenu'] : '',]]></add>
</operation>

</file>

<file name="$themedir/Register.template.php">
<operation>
<search position="after"><![CDATA[ echo '
</fieldset>
<span class="botslice"><span></span></span>
</div>';]]></search>
<add><![CDATA[ // Registration - Show Language mod BEGIN
if (!empty($modSettings['registration_language_admin_field']) && $modSettings['registration_language_admin_field'] == 1 && !empty($context['languages']))
{
// Drop language menu
echo '<dl class="register_form" id="language_select"><dt>';
echo '<b>', $txt['language_menu_select_language'], ':</b></dt>
<dd><select id="language_select" name="languagemenu">';
foreach ($context['languages'] as $language)
{
$language_button = str_replace("-utf8","",$language['name']);
if (isset($custom_label[$language['filename']])) $language_button = $custom_label[$language['filename']];
echo '
<option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>' ,$language_button, '</option>';
}
echo'
</select></dd>
</dl>';
}
// Registration - Show Language mod END

]]></add>
</operation>
</file>

</modification>


Code (package-info.xml) Select
<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">

<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
        <id>cellax:lngregistrationraid</id>
        <name>Language on registration</name>
<type>modification</type>
<version>0.1</version>

<install for="2.0 - 2.0.99">
<modification type="file">Install2.xml</modification>
</install>

<uninstall for="2.0 - 2.0.99">
<modification type="file" reverse="true">Install2.xml</modification>
</uninstall>

</package-info>


I am not interested on mod making, my skill isn't so good, but I just post it to share, I hope a customizer will do a better work.

I know that I didn't added the condition check if users may select language

EDIT: I miss it, I already added !empty($context['languages']), so it is fully working on smf 2.0 gold

Advertisement: