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

Fall-back options for missing language files

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Resolution: Fixed
    • 3.0.x
    • 3.0.6
    • Other
    • None
    • PHP Environment:
      Database:

    Description

      I've suggested this a few times, but I never really remember getting an answer or saw anything like this being added.

      One major problem with language packs is modifications that add extra language files. If the user does not upload the language files for each language they will get errors. I get too many people coming back to me asking why are they getting errors saying that their language file is missing, which I would no longer get if the set lang function had fall-back modes.

      So I wrote a fall-back mode up, and, though it may not be the best way to do it, it only requires 1 addition to the core code, so it is simple to write instructions on how to do it for you guys.

      Here is my change:
      Open:
      includes/session.php

      Find:

      if ((@include $language_filename) === false)

      Before, add:

      			if (!file_exists($language_filename))
      			{
      				global $config;
      				if ($this->lang_name == 'en')
      				{
      					// The user's selected language is missing the file, the board default's language is missing the file, and the file doesn't exist in /en.
      					$language_filename = str_replace($this->lang_path . 'en', $this->lang_path . $this->data['user_lang'], $language_filename);
      					trigger_error('Language file ' . $language_filename . ' couldn\'t be opened.', E_USER_ERROR);
      				}
      				else if ($this->lang_name == basename($config['default_lang']))
      				{
      					// Fall back to the English Language
      					$this->lang_name = 'en';
      					$this->set_lang($lang, $help, $lang_file, $use_db, $use_help);
      				}
      				else if (file_exists($this->lang_path . $this->data['user_lang'] . "/common.$phpEx"))
      				{
      					// Fall back to the board default language
      					$this->lang_name = basename($config['default_lang']);
      					$this->set_lang($lang, $help, $lang_file, $use_db, $use_help);
      				}
       
      				// Reset the lang name
      				$this->lang_name = (file_exists($this->lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']);
      				return;
      			}

      I've also made a patch with tortoise svn and attached it (the code pasted in the code box messes up tabs and isn't really readable...).

      I've tested it using en/en_us/es with en_us as my language, and es as board default and it seemed to work correctly when I tested it by renaming the viewforum language file from en_us and then es.

      Attachments

        Activity

          People

            Acyd Burn Meik Sievertsen [X] (Inactive)
            EXreaction EXreaction [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: