1: I want to edit some details in it, where can i find index board stats file, I mean from where following variables are taken from ?
{$lang->stats_posts_threads}<br />
{$lang->stats_numusers}<br />
{$lang->stats_newestuser}<br />
{$lang->stats_mostonline}<br />
2: if I want to use a variable from xyz.php.lang language file then what is the syntax for it ?
xyz.lang.php
$l['hi_me_xyz'] = "you are xyz";
{$lang->xyz_hi_me_xyz}
or {$lang->hi_me_xyz}
For 2,
The example of language file should be:
<?php
/**
* Author: crazy4cs
* @copyright 2011
*/
$l['my_error'] = "Sorry, but administrator has disabled this page for your usergroup.";
?>
And you should name file in name of plugin, for example, name of your plugin is myplugin.php , you should keep it myplugin.lang.php (not necessary but convenient).
And to evaluate my_error statement from that language file in your plugin, you could do something like:
$lang->load("myplugin");
error($lang->my_error);
so it'd output statement associated with my_error variable. Also don't forget to declare $lang variable in global variables in your plugin.
You could check my
Showteam Disabled plugin as it uses language file and you could study it.
referred language variables are in index.lang.php
if the language variable available globally then we can directly use it like {$lang->variable}
however not sure of such global availability ...
I want to use my custom language file in index without plugin, Do I have to do $lang->load("myplugin");
before using its variable ?
(2011-12-02, 04:20 PM)sunjava1 Wrote: [ -> ]I want to use my custom language file in index without plugin, Do I have to do $lang->load("myplugin");
before using its variable ?
YES. You can use any file with extension ".lang.php" from "MYBB_ROOT/inc/languages/YOUR_LANGUAGE/" or "MYBB_ROOT/inc/languages/YOUR_LANGUAGE/admin" folder but first must to be loaded with
global $lang;
$lang->load("myplugin");
If you do not want to use your plugin language variables, but you want to use MyBB language variable, it's enough to use
global $lang;
If you want to use also language variables of your plugin, the code should be:
global $lang;
$lang->load("myplugin");
or (for example)
global $lang;
$lang->load("myplugin", false, true);
// LATER EDIT:
Check your MYBB_ADMIN_DIR/inc/class_language.php at line 118 (in MyBB 1.6.5):
/**
* Load the language variables for a section.
*
* @param string The section name.
* @param boolean Is this a datahandler?
* @param boolean supress the error if the file doesn't exist?
*/
function load($section, $isdatahandler=false, $supress_error=false)
what I was asking is can I do it in index template?
$lang->load("myplugin");
error($lang->my_error);
I don't want to use any plugin. If the my custom language file is located in languages directory, then can I use it on index template as {$lang->hi_me_xyz}
No.
If only can add at the end of index.lang.php file your desired variables like
$l['boardstats'] = "Board Statistics";
and call them in templates with
$lang->boardstats
You can use other language file in index forum only if you edit your index.php file and replace
// Load global language phrases
$lang->load("index");
but this method does not have any sense.
So... in a MyBB file like index.php or portal.php you can use only one language file defined (LOADED) by
$lang->load("index");