TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 05:50:59 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,106
  • Total Topics: 21,213
  • Online today: 358
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 315
  • Total: 316
  • @rjen

Creating a language file

Started by TimUSA, February 19, 2008, 04:15:23 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TimUSA

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?

Dragooon

Create a Menu.english.php and add
loadLanguage('Menu');
So it will be called according to Menu.UserLanguage.php

TimUSA

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.

IchBin

You need to put the loadLanguage in the template_init() function towards the top of your index.template.php file.

TimUSA

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:

IchBin

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.

TimUSA

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';
?>

Dragooon

Its $txt not $text and after this:
$text['menugallery']= 'GALLERY'
Add the " ; "
So it will be
$text['menugallery']= 'GALLERY';

TimUSA

damnit...i hate it when i do that