'Translation not working with Poedit & Php

I've been trying with the following code to translate using Poedit & PHP. It's a very basic example which I'm trying to translate in German language. I've files in the following folders.

/home/test/test.php
/home/test/localization.php
/home/test/locale/de_DE/LC_MESSAGES/default.po
/home/test/locale/de_DE/LC_MESSAGES/default.mo

test.php

require_once("localization.php");
echo _("Hello World!");

localization.php

$locale = "de_DE";

if (isset($_GET["locale"])) 
    $locale = $_GET["locale"];

putenv("LC_ALL=$locale");

setlocale(LC_ALL, $locale);

bindtextdomain("default", "./locale");

textdomain("default");

When I run localhost:8080/test/test.php, It shows only english message "Hello World!". I've translated in default.po. Here it is:

msgid ""
msgstr ""
"Project-Id-Version: a\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-01-29 09:37+0530\n"
"PO-Revision-Date: 2014-01-29 09:38+0530\n"
"Last-Translator: Rahul <[email protected]>\n"
"Language-Team: b <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: _;gettext;gettext_noop\n"
"X-Poedit-Basepath: .\n"
"X-Poedit-Language: German\n"
"X-Poedit-Country: GERMANY\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-SearchPath-0: .\n"

#: test.php:4
msgid "Hello World!"
msgstr "Hallo Welt!"

Any ideas where I'm going wrong? Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source