All pastes #66631 Raw Edit

Miscellany

public text v1 · immutable
#66631 ·published 2006-06-17 19:58 UTC
rendered paste body
/**
 * Allows a post to be seperated into languages, and will return the content for
 * the visitor's langauge
 */
function posttools_lang($args = null, $content) {
	global $posttools_languageShown;

	if ($posttools_languageShown) {
		return '';
	}
	
	if ($_COOKIE['pt_lang']) {
		$language = $_COOKIE['pt_lang'];
	} else {
		$language = strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2));
	}
	if ($args['what'] === $language) {
		$posttools_languageShown = true;
		return $content;
	}
	
	return '';
}