Logo name

Ipb 2.1:Lang global.php

From IpbWiki

  • Currently0.00/5
Jump to: navigation, search

This tutorial is to cover a common question I have to deal with when supporting modifications; different language file structures. Mod instructions are written using the default structure of the language files as they come with the IPB download. This structure looks like this (IPB 2.1.5's lang_global.php file):

CODE
<?php

$lang = array (

//2.1.4 - for IDM when released
'idm_header'   => "Downloads",


//2.1.3
'ajax_topicstate'  => "Altered topic state (opened/closed) from forum view",
'ajax_topicdesc'  => "Edited topic description from forum view",
'ajax_topictitle'  => "Edited topic title from '%s' to '%s' from forum view",

Etc., etc. So most mod instructions will tell you to look for the very top part of the file ,$lang = array (, and add additional lines below that. This works fine for when users have the default language structure. But there is a second potential structure for language files.

How does this second structure show itself? Well, there are a couple of ways. One is through non-English language packs. A second is if you edit the entries for the language files via the ACP. And the third way is if you happen to install some mod or script that uses the new language API. So what does this alternate language structure look like? Here's a sample:

CODE
<?php


$lang['admin:splash']  = "Splash Page";
$lang['admin:splash:splash']  = "Allow to view the splash page";
$lang['admin:adminlog']  = "Admin Logs";
$lang['admin:adminlog:remove']  = "";
$lang['admin:components']  = "Components System";
$lang['admin:components:add']  = "";
$lang['admin:components:edit']  = "";
$lang['admin:components:export']  = "";
$lang['admin:components:import']  = "";

Those familar with PHP will note that these two structures are doing the exact same thing, they just do it differently. See, language files are simply files to hold arrays of keys and corresponding values; the keys are the text on the left of the equals sign, the values are on the right. IPB refers to the keys of the arrays to pull the value in order to display the text somewhere on the board.

So say you're installing a mod and see that your files are in this second structure, what can you do? All you have to do is reformat the lines the mod tell you to add. Let's take my Members Online Today mod for an example. It has you add these lines to your lang_boards file:

CODE
// (FSY21) Members Online Today v3.1 mod by FuSoYa
'online_today'  => "Members Online Today:",
'online_today_none' => "No members have been online yet today",
'online_most_ever' => "Most members ever online in one day was <b><#COUNT#></b>, last accomplished on <b><#DATE#></b>",
'online_today_list' => "The following members have visited today:",
'last_active'  => "Last Active",
'mot_expand'  => "Expand",
'mot_collapse'  => "Collapse",

The first line is just a comment, it's not needed and can safely be deleted. The other lines just need to have a few punctuation changes. Compare the two structures above. You'll see that for the second structure, each line is constructed exactly the same:

CODE
$lang['key']  = "value";

So to make the lines for this mod work in this language file structure, just plug the keys and values into this structure:

CODE
$lang['online_today']  = "Members Online Today:";
$lang['online_today_none']  = "No members have been online yet today";
$lang['online_most_ever']  = "Most members ever online in one day was <b><#COUNT#></b>, last accomplished on <b><#DATE#></b>";
$lang['online_today_list']  = "The following members have visited today:";
$lang['last_active']  = "Last Active";
$lang['mot_expand']  = "Expand";
$lang['mot_collapse']  = "Collapse";

These lines would then go anywhere in the file, underneath the very top <?php line. By convention, there will be two blank lines beloe this line, followed by the individual $lang lines.

So hopefully this will help you to deal with these differing language file structures should you ever come across them in your mod installing. Good luck!

Original Article Author: Fusoya.

This page was last modified on 11 November 2006, at 15:12.  This page has been accessed 3,894 times.  Content is available under GNU Free Documentation License 1.2Disclaimers