MyBB Community Forums

Full Version: New Language value
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I want to create a another Navbar that all worked but i need german and english language values i also created a new file with this code in german and english folder:
<?php
/**
 * MyBB 1.8 English Language Pack
 * Copyright 2014 MyBB Group, All Rights Reserved
 *
 */

$l['navbar_home'] = "Home";
$l['navbar_forum'] = "Forum";
$l['navbar_contact'] = "Contact";
$l['navbar_more'] = "More";
$l['navbar_privacy_policy'] = "Privacy Policy";
$l['navbar_terms_of_use'] = "Terms of Use";
$l['navbar_team_members'] = "Team Members";

?>
And in the Template header i have this code with {$lang->navbar_home}
<a href="/">{$lang->navbar_home}</a>
<a class="active" href="{$mybb->settings['bburl']}">{$lang->navbar_forum}</a>
with normal text it works fine but i need a another text in another languages. The Forum run with Xampp on Windows local. And in The Admin CP config Lanuages is the file list and all variables. The element in the navbar (the text) is empty. When i run the Code:
<a href="/"></a>
<a class="active" href="http://127.0.0.1/forum"></a>
I seareched in the forum already but nothing i found worked :/ maybe anyone here can help me.


Sorry if my english is not the best but i'm from germany ^^



- DreamGamer
actually MyBB forum can use a different language set for the forum by installing & using required language pack

please see => Language Packs | installing a language pack

in general, language set of MyBB forum can be changed from the footer of the forum or from user control panel options
I mean a Language value not the language self. I want to add a new element to the page (another navbar) but i must make the navbar readable in all language that i will support. But if i add a Language value nothing happend for more ready the first mesage on this post.


- DreamGamer


EDIT:
Is it possible that this forum is not so active right now?


EDIT:
I think i never will get a answer Sad
I think i never will get a answer  Sad
----------------------------------------------------------
if i use another language variable example: "{$lang->online_online_plural}" nothing happend idk why ._. please help me


EDIT:
I created a plugin that should load the language file but i don't work nothing work with $lang only $mybb works but in $mybb are no language variables :/

Code:
<?php

if(!defined("IN_MYBB"))
{
    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$plugins->add_hook("index_start", "addlanguageplugin");

function addlanguageplugin_info()
{  
    return array(
        "name"                  => "addLanguagePlugin",
        "description"           => "A plugin that add Language values that you want!",
        "website"               => "",
        "author"                => "DreamGamer",
        "authorsite"            => "",
        "version"               => "2.4",
        "compatibility"     => "18*",
        "codename"          => "addlanguageplugin",
    );
}

function addlanguageplugin_is_installed()
{
    global $db;
}

function addlanguageplugin_install()
{
    global $db, $lang, $mybb;
}

function addlanguageplugin_uninstall()
{
    global $db;
    
    rebuild_settings();
}

function addlanguageplugin_admin_lang_load()
{
    global $lang;
} 

function addlanguageplugin()
{
    global $db, $lang, $mybb, $templates, $theme, $addlanguageplugin;
    $lang->load("navbar");
}

function addlanguageplugin_templatelist()
{
    global $mybb;
}
I have the same problem.
what happened for you Ms. @DreamGamer
The easiest solution that comes in mind is:
instead of creating a new language file you can just add those language var declarations in global.lang.php
Then you will be able to use those as you are doing now.

Problem is, the language file has to be loaded before using the variables in templates.
@DreamGamer regarding the plugin, I guess the hook is wrong, it should be global_start, and no need to declare global for every stage, once in perfect place is enough.
You need something to manage your custom language file. You can use your current system or a plugin for it (there is another for 1.6).

Then, the second part; to use variables in language strings the way you want to, the easiest way for you would probably to just globalize variable within the language file. Like so:

<?php
/**
* MyBB 1.8 English Language Pack
* Copyright 2014 MyBB Group, All Rights Reserved
*
*/

global $mybb;

$username = htmlspecialchars_uni($mybb->user['username']);

$l['navbar_welcome'] = "Welcome {$username}!";