<?php

	function announcements($output) {
		global $db, $lang;
		$announcements = $db->query("SELECT * FROM `announcements`");
		foreach($announcements as $announcement) {
			$content = json_decode($announcement["announcement_content"], true);
			$contents = [];
			foreach($content as $details) {
				if($details["lang"] == 1) {
					$contents["{".$announcement["announcement_area"]."}"] = $details["content"];
				}
				if($details["lang"] == $lang) {
					$contents["{".$announcement["announcement_area"]."}"] = $details["content"];
					break;
				}
			}
			if($contents) {
				$output = str_replace(array_keys($contents), $contents, $output);
			}
		}
		return $output;
	}