MyBB Community Forums

Full Version: Custom language file that is not overwritten during upgrade
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I posted this to the Ideas area, but thought I'd put it here to get more coverage as this issue is very important to me.

http://ideas.mybboard.net/idea/custom-la...ng-upgrade

Basically the suggestion is to have global.php read a custom language file that is not overwritten during an upgrade. In fact, the file will not be part of the provided files, but if it exists, it will be read during global.php so that the language variables are available in all parts of MyBB. This is not intended to be a replacement for plug-in specific language files, but for admin and global language changes that would otherwise be reverted during an upgrade.

A simple sample would be as follows:
// Load language
$lang->set_language($mybb->settings['bblanguage']);
$lang->load("global");
$lang->load("messages");
if(file_exists('./inc/langauges/'.$mybb->settings['bblanguage'].'/custom.lang.php')
{
     $lang->load("custom");
}

The same can be done for the admin pages so that it works


if(file_exists('./inc/langauges/'.$mybb->settings['bblanguage'].'/admin/custom.lang.php')
{
     $lang->load("custom");
}

I have done some additional looking into this and the $lang->load() function does already check if a file eixsts, so if the global.php fils just add a line like below, this will work. I just hope to avoid that having to edit core file after each upgrade.

$lang->load("custom");

I've submitted a plug-in for this feature in case anyone else is interested. I'll update this if/when it is validated.
Plug-in is validated and now available.

http://mods.mybboard.net/view/custom-lan...le-plug-in
I just tried this plugin, it's nice and simple, just what I need to make a tedious update process, well, less tedious. Thank you for releasing this.

However it does not work on every page. For example I try to replace the error_ messages from search.lang.php but they are not being replaced. So it seems that for the page that displays those error messages, the hooks that load the custom language file are not executed (at the right time) to override the official variables.
its not designed to overwrite contents of official variables within existing language files. it is designed to allow you to create a new custom language file that places language variables in a global scope. Since the custom.lang.php is not an official file, it is not overwritten during a MyBB upgrade so any additions you make to say index.lang.php are not removed with the next version.
Oh, okay.