Language file checker

Tools by the phpBBModders team and Community contributed tools.
Forum rules
Only post tools related to modding in here, simple.
User avatar
igorw
Past Contributor
Past Contributor
Posts: 1967
Joined: 01 Jun 2006, 20:48
Real name: Igor

Language file checker

Postby igorw » 05 Jun 2008, 15:57

Something that can lead to headaches is that you sometimes just recieve a blank page. One of the causes for this can be a parse error in a language file. This is because phpBB suppresses the errors for the inclusion. So it doesn't give you any errors.

I've created a script that will help you with this. It will loop through your language files and simply include them one-by-one. If there is a parse error, the script ends and the error is displayed. If everything goes fine, you get a confirmation message.

Save this file as "include_lang.php" and put it into the root of the board. Then run it by visiting the file in your webbrowser. Note: use it at your own risk!

Code: Select all

<?php
/**
*
* @package phpbbmodders
* @version $Id$
* @copyright (c) 2008 phpbbmodders.net
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

/**
 * this script will include all your language files
 * this makes it easier to discover parse errors
 */
if ($files = scandir($phpbb_root_path . 'language/'))
{
   foreach ($files as $file)
   {
      if (in_array($file, array('.', '..', '.svn'), true) || is_file($phpbb_root_path . 'language/' . $file))
      {
         continue;
      }
      
      include_lang($phpbb_root_path . 'language/' . $file . '/');
   }
}

trigger_error('All language files seem to be intact.');

/**
 * recursive function to include language files
 */
function include_lang($folder)
{
   global $phpEx;

   if ($files = scandir($folder))
   {
      foreach ($files as $file)
      {
         if (in_array($file, array('.', '..', '.svn'), true))
         {
            continue;
         }
         
         if (is_file($folder . $file) && substr(strrchr($file, '.'), 1) === $phpEx)
         {
            include($folder . $file);
         }
         else if (is_dir($folder . $file))
         {
            include_lang($folder . $file . '/');
         }
      }
   }
}

?>
Last edited by bonelifer on 11 Apr 2016, 15:15, edited 1 time in total.
Reason: Made fix suggested by Papicx92 - http://phpbbmodders.net/board/viewtopic.php?p=52872

harmlessgoat22
Supporter
Supporter
Posts: 316
Joined: 18 Sep 2007, 14:35
Real name: David

Re: Language file checker

Postby harmlessgoat22 » 05 Jun 2008, 17:01

Wow, you're just popping out awesome scripts lately!!! Looks very useful. Most of my files don't include too many language files, so I've been able to look through a couple files and find the problem when this happens to me, but this looks to be extremely helpful.

Thanks!
Image
That's like, I can't beat my neighbor in an argument, so instead I kill his dog.
-Best English Teacher Ever

User avatar
EY
Supporter
Supporter
Posts: 204
Joined: 05 Nov 2006, 23:13
Real name: Elias
Location: Montreal

Re: Language file checker

Postby EY » 05 Jun 2008, 20:14

Nice man thank you very much for this!
Never Say Never!

mtotheikle
New member
New member
Posts: 25
Joined: 11 Oct 2007, 03:03
Real name: Mike
Location: Spokane, WA

Re: Language file checker

Postby mtotheikle » 05 Jun 2008, 20:56

This will be very nice!

User avatar
EY
Supporter
Supporter
Posts: 204
Joined: 05 Nov 2006, 23:13
Real name: Elias
Location: Montreal

Re: Language file checker

Postby EY » 06 Jun 2008, 02:55

Are there any security wholes in that file?
Never Say Never!

mtotheikle
New member
New member
Posts: 25
Joined: 11 Oct 2007, 03:03
Real name: Mike
Location: Spokane, WA

Re: Language file checker

Postby mtotheikle » 06 Jun 2008, 05:34

eviL<3 wrote:Save this file as "include_lang.php" and put it into the root of the board. Then run it by visiting the file in your webbrowser. Note: use it at your own risk!


Just use it on a localhost like all these tool scripts should be and you will be fine.

User avatar
igorw
Past Contributor
Past Contributor
Posts: 1967
Joined: 01 Jun 2006, 20:48
Real name: Igor

Re: Language file checker

Postby igorw » 06 Jun 2008, 08:42

There's no direct security holes, but i definately don't suggest using it on a server. It's fine if you delete it directly after using it, but i wouldn't let it sit there ;).

Neo
New member
New member
Posts: 3
Joined: 26 Feb 2011, 18:45

Re: Language file checker

Postby Neo » 09 Mar 2011, 16:48

Thx used it with success!

Relaxin
New member
New member
Posts: 2
Joined: 17 Oct 2011, 13:25

Re: Language file checker

Postby Relaxin » 17 Oct 2011, 13:33

:) Great!!! I tried the checker several months and it works perfectly!

Papicx92
New member
New member
Posts: 1
Joined: 31 Jan 2016, 16:40

Re: Language file checker

Postby Papicx92 » 31 Jan 2016, 16:52

Hello
I'm sorry, but the current script does not check the files in subfolders languages.

The solution exists, you just change the last line of script

found

Code: Select all

else if (is_dir($folder . $file))
         {
            include_lang($folder . $file);

replace by

Code: Select all

else if (is_dir($folder . $file))
         {
            include_lang($folder . $file . '/');


This solution was found by Zoddo of phpbb-fr.com

User avatar
bonelifer
Administrator
Administrator
Posts: 476
Joined: 24 Jun 2006, 17:48
Real name: William
Location: htpc.MythBuntu

Re: Language file checker

Postby bonelifer » 11 Apr 2016, 15:16

Papicx92 thanks. I've updated the code in the first post.


Return to “Tools for MOD authors”

Who is online

Users browsing this forum: CommonCrawl [Bot] and 0 guests