public function formatAddress($html = false)
    {
        //Check if this locale has a fmt field
        if (isset($this->locale['fmt'])) {
            $address_format = $this->locale['fmt'];

            //Loop through each address part and process it!
            $formatted_address = $address_format;

            //Replace the street values
            foreach ($this->address_map as $key => $value) {
                $formatted_address = str_replace('%' . $key, $this->input_map[$value], $formatted_address);
            }

            //Remove blank lines from the resulting address
            $formatted_address = preg_replace('((\%n)+)', '%n', $formatted_address);


            //Replace new lines!
            if ($html) {
                $formatted_address = htmlentities($formatted_address, ENT_QUOTES, 'UTF-8', false);
                $formatted_address = str_replace('%n', "\n" . '<br>', $formatted_address);
            } else {
                $formatted_address = trim(str_replace('%n', "\n", $formatted_address));
            }

            return $formatted_address;
        } else {
            throw new LocaleMissingFormatException('Locale missing format');
        }
    }