Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-9709

Missing language files for MCP could be substituted by default / english ones

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.7-PL1
    • Fix Version/s: 3.1.0-b1
    • Labels:
      None
    • Environment:
      PHP 5.3.1, MySQL 5.1.41, Opera 10.54 / Firefox 3.0.5

      Description

      When having installed other language packs (like DE and ES) and mods most basic board elements automatically show the english language constants if the localized ones are not found (e.g. user language is set to ES and using some functionality of a mod that only came with EN language).

      However, in the MCP this fails totally. This is because "add_mod_info()" in "/includes/functions_module.php" only makes sure the "/mods" folder exists but cannot compare the files found in there with anything. Hence, no file might match the criteria, which ultimately results in all of the mod lang consts not being parsed by the template system.

      A quick workaround would be to check if the user has another language set than english. If so, simply load all english files. After that the function can overwrite any localization it finds, whereas non-existing would still at least exist in english.

      The following code fragment at the beginning of the function helps me on my board:

      global $config;
      if( $user-> lang_name!= 'en' ) {  // 'en' because all mods at least come with english language
      	$sUserLang= $user-> lang_name;
      	$user-> lang_name= 'en';  // Force to look for english
      	$this-> add_mod_info( $module_class );  // Recursively find all english files first
      	$user-> lang_name= $sUserLang;  // Revert language chosen by user
      }
      

      This problem also exists in ACP, but that is out of interest by me.

        Activity

        Hide
        A_Jelly_Doughnut A_Jelly_Doughnut added a comment -

        While its true that all MODs released at phpbb.com have English available, we cannot assume that for all MODs from all sources.

        Having said that, in most cases phpBB does fall back to the English language if the native language does not exist and English does. I think we should look at why that isn't happening in this case.

        Show
        A_Jelly_Doughnut A_Jelly_Doughnut added a comment - While its true that all MODs released at phpbb.com have English available, we cannot assume that for all MODs from all sources. Having said that, in most cases phpBB does fall back to the English language if the native language does not exist and English does. I think we should look at why that isn't happening in this case.
        Hide
        AmigoJack AmigoJack added a comment -

        Yes, EN is not necessarily a reliable fallback.

        I also clearly pointed out that this is an issue of the MCP. I assume all MCP mods who miss a localized language file in "/language/xx/mods/info_mcp_xxx.php" will bring up unparsed constants as final HTML output, if the user uses that language (instead of the one that came with the mod).

        Show
        AmigoJack AmigoJack added a comment - Yes, EN is not necessarily a reliable fallback. I also clearly pointed out that this is an issue of the MCP. I assume all MCP mods who miss a localized language file in "/language/xx/mods/info_mcp_xxx.php" will bring up unparsed constants as final HTML output, if the user uses that language (instead of the one that came with the mod).
        Hide
        nickvergessen Joas Schilling added a comment -

        I think we should look at why that isn't happening in this case.

        			$dir = @opendir($user->lang_path . $user->lang_name . '/mods');
         
        			if ($dir)
        			{
        				while (($entry = readdir($dir)) !== false)
        				{
        					if (strpos($entry, 'info_' . strtolower($module_class) . '_') === 0 && substr(strrchr($entry, '.'), 1) == $phpEx)
        					{
        						$add_files[] = 'mods/' . substr(basename($entry), 0, -(strlen($phpEx) + 1));
        					}
        				}
        				closedir($dir);
        			}
         
        			if (sizeof($add_files))
        			{
        				$user->add_lang($add_files);
        			}

        We just go through the lang_name dir, not en and the default language aswell.

        Show
        nickvergessen Joas Schilling added a comment - I think we should look at why that isn't happening in this case. $dir = @opendir($user->lang_path . $user->lang_name . '/mods');   if ($dir) { while (($entry = readdir($dir)) !== false) { if (strpos($entry, 'info_' . strtolower($module_class) . '_') === 0 && substr(strrchr($entry, '.'), 1) == $phpEx) { $add_files[] = 'mods/' . substr(basename($entry), 0, -(strlen($phpEx) + 1)); } } closedir($dir); }   if (sizeof($add_files)) { $user->add_lang($add_files); } We just go through the lang_name dir, not en and the default language aswell.
        Hide
        nickvergessen Joas Schilling added a comment -

        We have language fallback in 3.1

        Show
        nickvergessen Joas Schilling added a comment - We have language fallback in 3.1

          People

          • Assignee:
            nickvergessen Joas Schilling
            Reporter:
            AmigoJack AmigoJack
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development