Adds the page to the logged in user's watchlist

@param string $lang The code for the language to show any error message in (default: user preference)
@return bool True on success
483640
public function watch( $lang = null ) {

		Hooks::runHook( 'StartWatch' );

		pecho( "Watching {$this->title}...\n\n", PECHO_NOTICE );

		$tokens = $this->wiki->get_tokens();

		if( $tokens['watch'] == '+\\' ) {
			pecho( "User has logged out.\n\n", PECHO_FATAL );
			return false;
		}

		$apiArray = array(
			'action' => 'watch',
			'token'  => $tokens['watch'],
			'title'  => $this->title
		);

		if( !is_null( $lang ) ) $apiArray['uselang'] = $lang;

		$result = $this->wiki->apiQuery( $apiArray, true );

		if( isset( $result['watch'] ) ) {
			if( isset( $result['watch']['watched'] ) ) {
				return true;
			} else {
				pecho( "Watch error...\n\n" . print_r( $result['watch'], true ) . "\n\n", PECHO_FATAL );
				return false;
			}
		} else {
			pecho( "Watch error...\n\n" . print_r( $result, true ), PECHO_FATAL );
			return false;
		}

	}
580954
public function translation_exists($lang, $includeall = true) {
        $translations = $this->get_list_of_translations($includeall);
        return isset($translations[$lang]);
    }
1117188
public function templatesByLangListAction($lang, Request $request)
    {
        $this->checkToolAccess();
        $params = $request->query->all();

        if (!isset($params['hiddenFilters'])) {
            $params['hiddenFilters'] = [];
        }
        $params['hiddenFilters']['lang'] = $lang;

        return new JsonResponse(
            $this->finder->search(Template::class, $params)
        );
    }
914705
public function setLang($lang)
    {
        if (2 !== strlen($lang)) {
            throw new \InvalidArgumentException('Language identifier should be 2 characters long.');
        }

        if (!in_array($lang, $this->getSupportedLanguages())) {
            throw new \InvalidArgumentException(sprintf('Language "%s" is not supported.', $lang));
        }

        $this->lang = $lang;

        return $this;
    }
1341867
public function isIncludeDefaultLanguage($lang = null)
    {
        // if active lang is not passed in, use current active
        if (!$lang) {
            $lang = $this->getLanguage();
        }

        return !($this->default === $lang && $this->config->get('system.languages.include_default_lang') === false);
    }
590242
public function load($lang) {
        $langDir = MODULES_DIR . DS . RouteController::$currentModule . '/Views/lang/' . $lang;

        $files = glob($langDir . "/*.php");
        if (count($files) == 0) {
            throw new \Exception(ExceptionMessages::TRANSLATION_FILES_NOT_FOUND);
        }

        foreach ($files as $file) {
            $fileInfo = pathinfo($file);
            self::$translations[$fileInfo['filename']] = require_once $file;
        }
    }
53205
public function setLang( $lang ) {
		if ( !IntuitionUtil::nonEmptyStr( $lang ) ) {
			return false;
		}
		$this->currentLanguage = $this->normalizeLang( $lang );
		return true;
	}
1190720
public function createRoot(Lang $lang) : void
    {
        if (php_sapi_name() !== 'cli')
        {
            throw new \Exception("Method createRoot() is allowed only in CLI mode.");
        }

        $root = $this->pageRepository->findOneAbsoluteRoot();

        if ($root === NULL)
        {
            $root = new Page;
            $root->setName('root');
            $root->setView('root');
            $root->makeRoot();
            $root->save();
        }

        $langRoot = $this->pageRepository->findOneLangRoot($lang, TRUE);

        if ($langRoot === NULL)
        {
            $langRootName = 'root-' . $lang->getName();

            $langRoot = new Page;
            $langRoot->setName($langRootName);
            $langRoot->setView($langRootName);
            $langRoot->setParent($root);
            $langRoot->insertAsLastChildOf($root);
            $langRoot->save();

            $this->pageUrlManager->saveUrl($lang, $langRoot, '__a@&*^-9' . $langRootName);
        }
    }
731562
public function getLanguage(string $lang): ResponseInterface
    {
        return $this->client->sendRequest($this->createRequest('GET', $this->createUri("/api/2/language/$lang/")));
    }
1107811
public function set_language( $lang = 'en-US' ) {
		if ( isset( $this->language ) && $this->language === $lang ) {
			return true; // Bail out, no need to do anything.
		}

		$success            = false;
		$language_file_name = \dirname( __FILE__ ) . '/lang/' . $lang . '.json';

		if ( \file_exists( $language_file_name ) ) {
			$raw_language_file = \file_get_contents( $language_file_name );

			if ( false !== $raw_language_file ) {
				$language_file = \json_decode( $raw_language_file, true );

				if ( false !== $language_file ) {
					$this->language           = $lang;
					$this->pattern_trie       = Trie_Node::build_trie( $language_file['patterns'] );
					$this->pattern_exceptions = $language_file['exceptions'];

					$success = true;
				}
			}
		}

		// Clean up.
		if ( ! $success ) {
			$this->language           = null;
			$this->pattern_trie       = null;
			$this->pattern_exceptions = [];
		}

		// Make sure hyphenationExceptions is not set to force remerging of patgen and custom exceptions.
		$this->merged_exception_patterns = null;

		return $success;
	}
55488
public function setLang($lang)
    {
    	// Argument Validation
    	if (gettype($lang) != 'string')
        	throw new CAS_TypeMismatchException($lang, '$lang', 'string');

        phpCAS::traceBegin();
        $obj = new $lang();
        if (!($obj instanceof CAS_Languages_LanguageInterface)) {
            throw new CAS_InvalidArgumentException(
                '$className must implement the CAS_Languages_LanguageInterface'
            );
        }
        $this->_lang = $lang;
        phpCAS::traceEnd();
    }
701318
public static function setLanguage($language) {

		if(false === is_string($language)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($language)), E_USER_ERROR);
		}

		self :: $language = $language;
	}
144882
public function set_diacritic_language( $lang = 'en-US' ) {
		if ( isset( $this->data['diacriticLanguage'] ) && $this->data['diacriticLanguage'] === $lang ) {
			return;
		}

		$this->data['diacriticLanguage'] = $lang;
		$language_file_name              = \dirname( __FILE__ ) . '/diacritics/' . $lang . '.json';

		if ( \file_exists( $language_file_name ) ) {
			$diacritics_file              = \json_decode( \file_get_contents( $language_file_name ), true );
			$this->data['diacriticWords'] = $diacritics_file['diacritic_words'];
		} else {
			unset( $this->data['diacriticWords'] );
		}

		$this->update_diacritics_replacement_arrays();
	}
1191719
function doUserLanguage(Userinfo $userinfo, Userinfo &$existinguser)
	{
		$changed = false;
		//Update the user language with the current used in Joomla or the one existing from an other plugin
		if (empty($userinfo->language)) {
			$user_lang = '';
			if (!empty($userinfo->params)) {
				$params = new Registry($userinfo->params);
				$user_lang = $params->get('language');
			}
			$userinfo->language = !empty($user_lang) ? $user_lang : Factory::getLanguage()->getTag();
		}
		if (!empty($userinfo->language) && isset($existinguser->language) && !empty($existinguser->language) && $userinfo->language != $existinguser->language) {
			try {
				$this->updateUserLanguage($userinfo, $existinguser);
				$existinguser->language = $userinfo->language;
				$this->debugger->addDebug(Text::_('LANGUAGE_UPDATED') . ' : ' . $existinguser->language . ' -> ' . $userinfo->language);

				$changed = true;
			} catch (Exception $e) {
				$this->debugger->addError(Text::_('LANGUAGE_UPDATED_ERROR') . ' ' . $e->getMessage());
			}
		} else {
			//return a debug to inform we skipped this step
			$this->debugger->addDebug(Text::_('LANGUAGE_NOT_UPDATED'));
		}
		return $changed;
	}
150391
public function setTranslatableLang($lang)
    {
        if (is_string($lang)) {
            $lang = new Lang($lang);
        }

        $this->translatableLang = $lang;

        return $this;
    }
481423
public function setUserDefaultLanguage($lang)
    {
        $app = Application::getFacadeApplication();
        $db = $app['database']->connection();
        $session = $app['session'];

        $this->uDefaultLanguage = $lang;
        $session->set('uDefaultLanguage', $lang);
        $db->Execute('update Users set uDefaultLanguage = ? where uID = ?', array($lang, $this->getUserID()));
    }
940276
public function getPagesMenu($menuName, $lang = NULL)
    {
//         $currentUser = $this->securityContext->getToken()->getUser();
//         if ($currentUser != 'anon.')
//         {
//             $roles = $currentUser->getRoles();
//         }
//         else
//         {
//             $roles = array();
//         }
        $pages = $this->doctrine->getRepository('FulgurioLightCMSBundle:PageMenu')->findPagesOfMenu($menuName, $lang);
        $availablePages = array();
        foreach ($pages as &$page)
        {
//             $pageAccesses = $page->getAccess();
//             if (empty($pageAccesses))
//             {
//                 $page->setAllowedChildren($this->doctrine->getRepository('FulgurioLightCMSBundle:Page')->getAllowedChildren($roles, $page));
                $availablePages[] = $page;
//             }
//             else if (is_object($currentUser))
//             {
//                 foreach ($pageAccesses as $pageAccess)
//                 {
//                     if ($currentUser->hasRole($pageAccess))
//                     {
//                         $page->setAllowedChildren($this->doctrine->getRepository('FulgurioLightCMSBundle:Page')->getAllowedChildren($roles, $page));
//                         $availablePages[] = $page;
//                         break;
//                     }
//                 }
//             }
        }
        return $availablePages;
    }