How could i include a langauge on whole site

Discussion forum for MOD Writers regarding MOD Development.
Locked
arrow816
Registered User
Posts: 78
Joined: Fri Dec 05, 2008 7:14 pm
Name: Steven Costello
Contact:

How could i include a langauge on whole site

Post by arrow816 »

I have a mod that is displayed on every page on the front end, and i cant find a way to add the language file to every page, short of actually adding it, Is there an easier 1 or 2 line piece of code that i can put some where that will let me do this?

Thanks,
Steve C
User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: How could i include a langauge on whole site

Post by Erik Frèrejean »

Either add it to common.php or use an hook file so that you don't have to edit any phpBB core files.
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)
arrow816
Registered User
Posts: 78
Joined: Fri Dec 05, 2008 7:14 pm
Name: Steven Costello
Contact:

Re: How could i include a langauge on whole site

Post by arrow816 »

Where and how would i add it in common.php, iv been trying both:

Code: Select all

$user->setup('mods/jqdropdown');
and

Code: Select all

$user->add_lang('mods/jqdropdown');
but neither are working.

Thanks,
Steve C
User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: How could i include a langauge on whole site

Post by Erik Frèrejean »

Sorry, common.php wont work. I'd suggest to use an hook for this. Upload this file to includes/hooks/ and purge the cache. That will be loaded on every page.
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)
arrow816
Registered User
Posts: 78
Joined: Fri Dec 05, 2008 7:14 pm
Name: Steven Costello
Contact:

Re: How could i include a langauge on whole site

Post by arrow816 »

Ok that worked, now i got one more question. Im trying to get the mod, to say in the welcome part, Welcome to {SITE_NAME}, is there a way to add {SITE_NAME} to the language file?

Right now its not working. Right now it shows up as "Welcome to {SITE_NAME}" but what it should show up as is "Welcome to Phpbb3 Test" .

Here is the code for the language file

Code: Select all

<?php
/**
*
* example [English]
*
* @package language
* @version $Id$
* @copyright (c) 2007 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
 
/**
* DO NOT CHANGE
*/
if (empty($lang) || !is_array($lang))
{
    $lang = array();
	
}
 
// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
 
$lang = array_merge($lang, array(
//Here are the ones for when a user is not logged in
	'JQ_NL_WELCOME'			=> '<h1>Welcome to {SITENAME}</h1>
                				<h2>Hello Guests</h2>      
                				<p class="grey">Dear Guests, If you have enjoyed your time here on {SITENAME}, please feel free to <a href="ucp.php?mode=register">Register</a>, and further your enjoyment here.<br />
                    			Thanks,<br />
                    			&nbsp;&nbsp;&nbsp;Steve C - Site Admin</p>',
	'JQ_NL_WHY_REG'			=> '<p class="grey">Dear Guest if you would like to join our community, please feel free to head over to our <a href="ucp.php?mode=register">Registration Page</a> and create an account. The process will take no longer then 3 min, and you will be ready to continue your enjoyment here at {SITENAME}<br />
                Thanks,<br />
                &nbsp;&nbsp;&nbsp;Steve C - Site Admin</p>',
	'JQ_NL_HELLO'			=> 'Hello Guest!',
	'JQ_NL_LOGIN_LINK'		=> 'Log In | Register',
								
//Here are the ones for when the user is logged in

	'JQ_L_WELCOME'			=> '<h1>Welcome to {SITENAME}</h1>
                				<h2>Your {LAST_VISIT_DATE}</h2>   
                				<p class="grey">Welcome {S_USERNAME} to {SITENAME}. Hope you enjoy your time here.<br />
                    			Thanks,<br />
                    			&nbsp;&nbsp;&nbsp;Steve C - Site Admin</p>',
	'JQ_L_MEM_INFO'			=> 'Member Info',
	'JQ_L_QUICKLLINKS'		=> 'Quick Links',
	'JQ_L_PM'				=> 'You have<!-- IF S_DISPLAY_PM --> <a href="{U_PRIVATEMSGS}">{PRIVATE_MESSAGE_INFO}</a><!-- ENDIF --><br />',
	'JQ_L_SEARCHLINKS'		=> 'Search Links',
	'JQ_L_HELLO'			=> 'Hello {S_USERNAME}!',

//Here are the ones that are common and dont change
	'JQ_MEMLOGIN'			=> 'Member Login',
	'JQ_LOSTPASS'			=> 'Lost your password?',
	'JQ_NOTMEM'				=> 'Not a Member?',
	'JQ_CREATEACC'			=> 'Create an Account',
	'JQ_CLOSE_PANEL'		=> 'Close Panel',


));
?>
Thanks,
Steve C
Ather
Registered User
Posts: 1032
Joined: Fri May 08, 2009 9:42 am
Location: Kingdom of Bahrain
Name: Ather Akber

Re: How could i include a langauge on whole site

Post by Ather »

if its a custom phpBB page, do this $user->setup('common'); and then you can just use {SITENAME} in the template files, it should work
CPL Syed Ather Akbar
Regional Command Southwest
Camp Leatherneck, Afghanistan

My Mods/Snippets
User avatar
3Di
Former Team Member
Posts: 16156
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano 🇮🇹 Frankfurt 🇩🇪
Name: Marco
Contact:

Re: How could i include a langauge on whole site

Post by 3Di »

yes, that's related to the function page_header .. located into includes/functions.php
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
imkingdavid
Former Team Member
Posts: 2673
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: How could i include a langauge on whole site

Post by imkingdavid »

You could use sprintf() in the PHP file that you are using to display your page...

So the Language variable would be something like:

Code: Select all

'SITENAME'    => 'Welcome to %1$s', 
(shortened for example)
And in the PHP you could do:

Code: Select all

$template->assign_var('L_SITENAME', sprintf($user->lang('SITENAME'), 'My Website')); 
To have it show more than once just use the %1$s multiple times. To add another placeholder to be replaced, do %2$s and add another argument to the sprintf() after 'My Website'.
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
Locked

Return to “[3.0.x] MOD Writers Discussion”