Just curious on the best way to do this. I am working on a custom them for my site, and would like for the menu items to translate when languages are selected. What would be the best way to do this?
I am assuming that i would create say menu.english.php and then do an include on my index.template?
Create a Menu.english.php and add
loadLanguage('Menu');
So it will be called according to Menu.UserLanguage.php
OK I created a language file and named it menu.english.php and saved it in the theme's language directory Themes/New_AYC/languages:
<?php
// Main Menu Text File
$text['menuHome']= 'HOME';
$text['menuForum']= 'FORUM';
$text['menuAYCRacing']= 'AYC RACING';
$text['menuDownloads']= 'DOWNLOADS';
$text['menuCalendar']= 'CALENDAR';
$text['menuGallery']= 'GALLERY'
$text['menuLinks']= 'LINKS';
//Forum SubMenu
$text['subHelp']= 'Help';
$text['subSearch']= 'Search';
$text['subAdmin']= 'Admin';
$text['subProfile']= 'Profile';
$text['subMessage']= 'My Messages';
$text['subforumList']= 'Forum Memberlist';
$text['subracingList']= 'Racing Fleet Members';
$text['subLogin']= 'Login';
$text['subLogout']= 'Logout';
$text['subRegister']= 'Register';
//AYC Racing SubMenu
$text['subTournament']= 'Tournaments';
$text['subRules']= 'Sailing Instructions';
$text['subApplication']= 'Racing Fleet Application';
$text['subPassword']= 'Password';
$text['submLadder']= 'Match Race Ladder';
$text['subfLadder']= 'Fleet Race Ladder';
$text['subsResults']= 'Series Results';
$text['subeResults']= 'Enter Race Reults';
$text['subRecent']= 'Recent Races';
$text['subSeries']= 'Enter New Series';
//Downloads
$text['subTools']= 'Club Tools';
$text['subModels']= 'Boat Models';
$text['subCourses']= 'Courses';
$text['subSkins']= 'Skins';
$text['subLocators']= 'Locators';
$text['subTemplates']= 'Templates';
$text['subDocuments']= 'Documents';
//Calendar
$text['subPost']= 'Post Event';
//Gallery
$text['subMain']= 'Main Picture Gallery';
$text['subOfficial']= 'Official AYC Images';
$text['subScreentshots']= 'Screenshots';
//Links
$text['subGeneral']= 'General Links';
$text['subClubs']= 'Other VSK Clubs';
$text['subRules']= 'Racing Rules of Sailing';
$text['subSoftware']= 'Software';
//MiniCp
$text['subUser']= 'User';
$text['subStats']= 'Statistics';
$text['subRecent']= 'Recent Topics';
?>
then on my index.template just before the menu loads i put loadLanguage('Menu');
}
elseif(isset($_GET['board'])){
if($_GET['board']=='85.0')
$sitespot='-docs';
}
$context['sitespot']=$sitespot;
// setup menu
loadLanguage('Menu');
echo '
<div id="wrap">
<div id="menu">
<a id="home" ',$context['sitespot']=='' ? 'class="active_now" ' : '' ,'href="'.$scripturl.'">' . $text['menuHome'] . '</a>
Now I am getting a blank button.
You need to put the loadLanguage in the template_init() function towards the top of your index.template.php file.
Ok its here now:
function template_init()
{
global $context, $settings, $options, $txt, $boardurl;
loadLanguage('Menu');
/* Use images from default theme when using templates from the default theme?
if this is 'always', images from the default theme will be used.
if this is 'defaults', images from the default theme will only be used with default templates.
if this is 'never' or isn't set at all, images from the default theme will not be used. */
$settings['use_default_images'] = 'never';
/* What document type definition is being used? (for font size and other issues.)
'xhtml' for an XHTML 1.0 document type definition.
'html' for an HTML 4.01 document type definition. */
$settings['doctype'] = 'xhtml';
/* The version this template/theme is for.
This should probably be the version of SMF it was created for. */
$settings['theme_version'] = '1.1.2';
/* Set a setting that tells the theme that it can render the tabs. */
$settings['use_tabs'] = true;
/* Use plain buttons - as oppossed to text buttons? */
$settings['use_buttons'] = true;
/* Show sticky and lock status seperate from topic icons? */
$settings['seperate_sticky_lock'] = true;
}
and then my Text and link for the menu item is this:
<a id="home" ',$context['sitespot']=='' ? 'class="active_now" ' : '' ,'href="'.$scripturl.'">' , $text['menuHome'] , '</a>
and i am still getting a blank tab :uglystupid2:
if your file is named menu.english then you need to make sure the loadLanguage uses the same case sensitive word menu, and not Menu.
Ok changed this up a bit after some reading,
the top of my index looks like this:
function template_init()
{
global $context, $settings, $options, $txt, $boardurl;
/* Use images from default theme when using templates from the default theme?
if this is 'always', images from the default theme will be used.
if this is 'defaults', images from the default theme will only be used with default templates.
if this is 'never' or isn't set at all, images from the default theme will not be used. */
$settings['use_default_images'] = 'never';
/* What document type definition is being used? (for font size and other issues.)
'xhtml' for an XHTML 1.0 document type definition.
'html' for an HTML 4.01 document type definition. */
$settings['doctype'] = 'xhtml';
/* The version this template/theme is for.
This should probably be the version of SMF it was created for. */
$settings['theme_version'] = '1.1.2';
/* Set a setting that tells the theme that it can render the tabs. */
$settings['use_tabs'] = true;
/* Use plain buttons - as oppossed to text buttons? */
$settings['use_buttons'] = true;
/* Show sticky and lock status seperate from topic icons? */
$settings['seperate_sticky_lock'] = true;
/*Load Language File*/
loadLanguage('ThemeStrings');
}I am getting this error now:
QuoteTemplate Parse Error!
There was a problem loading the /Themes/New_AYC/languages/ThemeStrings.english.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.
You may want to try to refresh this page or use the default theme.
syntax error, unexpected T_VARIABLE
ThemeStrings looks exactly like this:
<?php
// Main Menu Text File
$text['menuhome']= 'HOME';
$text['menuforum']= 'FORUM';
$text['menuaycRacing']= 'AYC RACING';
$text['menudownloads']= 'DOWNLOADS';
$text['menucalendar']= 'CALENDAR';
$text['menugallery']= 'GALLERY'
$text['menulinks']= 'LINKS';
//Forum SubMenu
$text['subhelp']= 'Help';
$text['subsearch']= 'Search';
$text['subadmin']= 'Admin';
$text['subprofile']= 'Profile';
$text['submessage']= 'My Messages';
$text['subforumlist']= 'Forum Memberlist';
$text['subracinglist']= 'Racing Fleet Members';
$text['sublogin']= 'Login';
$text['sublogout']= 'Logout';
$text['subregister']= 'Register';
//AYC Racing SubMenu
$text['subtournament']= 'Tournaments';
$text['subrules']= 'Sailing Instructions';
$text['subapplication']= 'Racing Fleet Application';
$text['subpassword']= 'Password';
$text['submladder']= 'Match Race Ladder';
$text['subfladder']= 'Fleet Race Ladder';
$text['subsresults']= 'Series Results';
$text['suberesults']= 'Enter Race Reults';
$text['subrecent']= 'Recent Races';
$text['subseries']= 'Enter New Series';
//Downloads
$text['subtools']= 'Club Tools';
$text['submodels']= 'Boat Models';
$text['subcourses']= 'Courses';
$text['subskins']= 'Skins';
$text['sublocators']= 'Locators';
$text['subtemplates']= 'Templates';
$text['subdocuments']= 'Documents';
//Calendar
$text['subpost']= 'Post Event';
//Gallery
$text['submain']= 'Main Picture Gallery';
$text['subofficial']= 'Official AYC Images';
$text['subscreentshots']= 'Screenshots';
//Links
$text['subgeneral']= 'General Links';
$text['subclubs']= 'Other VSK Clubs';
$text['subrules']= 'Racing Rules of Sailing';
$text['subsoftware']= 'Software';
//MiniCp
$text['subuser']= 'User';
$text['substats']= 'Statistics';
$text['subrecent']= 'Recent Topics';
?>
Its $txt not $text and after this:
$text['menugallery']= 'GALLERY'
Add the " ; "
So it will be
$text['menugallery']= 'GALLERY';
damnit...i hate it when i do that