summaryrefslogtreecommitdiff
path: root/ext/gettext
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/gettext
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/gettext')
-rw-r--r--ext/gettext/CREDITS2
-rw-r--r--ext/gettext/config.m450
-rw-r--r--ext/gettext/config.w3212
-rw-r--r--ext/gettext/gettext.c392
-rw-r--r--ext/gettext/gettext.dsp113
-rw-r--r--ext/gettext/php_gettext.h55
-rw-r--r--ext/gettext/tests/44938.phpt85
-rw-r--r--ext/gettext/tests/dcngettext.phpt30
-rw-r--r--ext/gettext/tests/gettext_basic-enus.phpt28
-rw-r--r--ext/gettext/tests/gettext_basic.phpt25
-rw-r--r--ext/gettext/tests/gettext_bind_textdomain_codeset-retval.phpt22
-rw-r--r--ext/gettext/tests/gettext_bind_textdomain_codeset-wrongparams.phpt23
-rw-r--r--ext/gettext/tests/gettext_bindtextdomain-cwd.phpt27
-rw-r--r--ext/gettext/tests/gettext_bindtextdomain-emptydomain.phpt16
-rw-r--r--ext/gettext/tests/gettext_bindtextdomain-path.phpt16
-rw-r--r--ext/gettext/tests/gettext_bindtextdomain-wrongparams.phpt19
-rw-r--r--ext/gettext/tests/gettext_dcgettext-wrongparams.phpt16
-rw-r--r--ext/gettext/tests/gettext_dcgettext.phpt25
-rw-r--r--ext/gettext/tests/gettext_dgettext.phpt30
-rw-r--r--ext/gettext/tests/gettext_dgettext_error_wrongparams.phpt34
-rw-r--r--ext/gettext/tests/gettext_dngettext-plural.phpt24
-rw-r--r--ext/gettext/tests/gettext_dngettext-wrongparams.phpt23
-rw-r--r--ext/gettext/tests/gettext_gettext_error_wrongparams.phpt17
-rw-r--r--ext/gettext/tests/gettext_ngettext-wrongparams.phpt33
-rw-r--r--ext/gettext/tests/gettext_ngettext.phpt26
-rw-r--r--ext/gettext/tests/gettext_phpinfo.phpt19
-rw-r--r--ext/gettext/tests/gettext_textdomain-retval.phpt29
-rw-r--r--ext/gettext/tests/gettext_textdomain-wrongparams.phpt25
-rw-r--r--ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest.mobin0 -> 84 bytes
-rw-r--r--ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest.po4
-rw-r--r--ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest_switch.mobin0 -> 102 bytes
-rw-r--r--ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest_switch.po4
-rw-r--r--ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest_switched.po2
-rw-r--r--ext/gettext/tests/locale/en/LC_CTYPE/dngettextTest.mobin0 -> 86 bytes
-rw-r--r--ext/gettext/tests/locale/en/LC_CTYPE/dngettextTest.po4
-rw-r--r--ext/gettext/tests/locale/en/LC_MESSAGES/dgettextTest.mobin0 -> 84 bytes
-rw-r--r--ext/gettext/tests/locale/en/LC_MESSAGES/dgettextTest.po4
-rw-r--r--ext/gettext/tests/locale/en/LC_MESSAGES/dgettextTest_switch.mobin0 -> 102 bytes
-rw-r--r--ext/gettext/tests/locale/en/LC_MESSAGES/dgettextTest_switch.po4
-rw-r--r--ext/gettext/tests/locale/en/LC_MESSAGES/dngettextTest.mobin0 -> 84 bytes
-rw-r--r--ext/gettext/tests/locale/en/LC_MESSAGES/dngettextTest.po4
-rw-r--r--ext/gettext/tests/locale/en/LC_MESSAGES/messages.mobin0 -> 201 bytes
-rw-r--r--ext/gettext/tests/locale/en/LC_MESSAGES/messages.po15
-rw-r--r--ext/gettext/tests/locale/fi/LC_MESSAGES/messages.mobin0 -> 199 bytes
-rw-r--r--ext/gettext/tests/locale/fi/LC_MESSAGES/messages.po15
45 files changed, 1272 insertions, 0 deletions
diff --git a/ext/gettext/CREDITS b/ext/gettext/CREDITS
new file mode 100644
index 0000000..acaebd7
--- /dev/null
+++ b/ext/gettext/CREDITS
@@ -0,0 +1,2 @@
+GetText
+Alex Plotnick
diff --git a/ext/gettext/config.m4 b/ext/gettext/config.m4
new file mode 100644
index 0000000..02d436c
--- /dev/null
+++ b/ext/gettext/config.m4
@@ -0,0 +1,50 @@
+dnl
+dnl $Id$
+dnl
+
+PHP_ARG_WITH(gettext,for GNU gettext support,
+[ --with-gettext[=DIR] Include GNU gettext support])
+
+if test "$PHP_GETTEXT" != "no"; then
+ for i in $PHP_GETTEXT /usr/local /usr; do
+ test -r $i/include/libintl.h && GETTEXT_DIR=$i && break
+ done
+
+ if test -z "$GETTEXT_DIR"; then
+ AC_MSG_ERROR(Cannot locate header file libintl.h)
+ fi
+
+ GETTEXT_LIBDIR=$GETTEXT_DIR/$PHP_LIBDIR
+ GETTEXT_INCDIR=$GETTEXT_DIR/include
+
+ O_LDFLAGS=$LDFLAGS
+ LDFLAGS="$LDFLAGS -L$GETTEXT_LIBDIR"
+ AC_CHECK_LIB(intl, bindtextdomain, [
+ GETTEXT_LIBS=intl
+ GETTEXT_CHECK_IN_LIB=intl
+ ],
+ AC_CHECK_LIB(c, bindtextdomain, [
+ GETTEXT_LIBS=
+ GETTEXT_CHECK_IN_LIB=c
+ ],[
+ AC_MSG_ERROR(Unable to find required gettext library)
+ ])
+ )
+ LDFLAGS=$O_LDFLAGS
+
+ AC_DEFINE(HAVE_LIBINTL,1,[ ])
+ PHP_NEW_EXTENSION(gettext, gettext.c, $ext_shared)
+ PHP_SUBST(GETTEXT_SHARED_LIBADD)
+
+ if test -n "$GETTEXT_LIBS"; then
+ PHP_ADD_LIBRARY_WITH_PATH($GETTEXT_LIBS, $GETTEXT_LIBDIR, GETTEXT_SHARED_LIBADD)
+ fi
+
+ PHP_ADD_INCLUDE($GETTEXT_INCDIR)
+
+ AC_CHECK_LIB($GETTEXT_CHECK_IN_LIB, ngettext, [AC_DEFINE(HAVE_NGETTEXT, 1, [ ])])
+ AC_CHECK_LIB($GETTEXT_CHECK_IN_LIB, dngettext, [AC_DEFINE(HAVE_DNGETTEXT, 1, [ ])])
+ AC_CHECK_LIB($GETTEXT_CHECK_IN_LIB, dcngettext, [AC_DEFINE(HAVE_DCNGETTEXT, 1, [ ])])
+ AC_CHECK_LIB($GETTEXT_CHECK_IN_LIB, bind_textdomain_codeset, [AC_DEFINE(HAVE_BIND_TEXTDOMAIN_CODESET, 1, [ ])])
+
+fi
diff --git a/ext/gettext/config.w32 b/ext/gettext/config.w32
new file mode 100644
index 0000000..0755de2
--- /dev/null
+++ b/ext/gettext/config.w32
@@ -0,0 +1,12 @@
+// $Id$
+// vim:ft=javascript
+
+ARG_WITH("gettext", "gettext support", "no");
+
+if (PHP_GETTEXT != "no") {
+ if (CHECK_LIB("libintl_a.lib;libintl.lib", "gettext", PHP_GETTEXT) && CHECK_HEADER_ADD_INCLUDE("libintl.h", "CFLAGS_GETTEXT")) {
+ EXTENSION("gettext", "gettext.c", PHP_GETTEXT_SHARED, "-DHAVE_BIND_TEXTDOMAIN_CODESET=1 -DHAVE_DNGETTEXT=1 -DHAVE_NGETTEXT=1 -DHAVE_LIBINTL=1 -DHAVE_DCNGETTEXT=1");
+ } else {
+ WARNING("gettext not enabled; libraries and headers not found");
+ }
+}
diff --git a/ext/gettext/gettext.c b/ext/gettext/gettext.c
new file mode 100644
index 0000000..ed86b6c
--- /dev/null
+++ b/ext/gettext/gettext.c
@@ -0,0 +1,392 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: Alex Plotnick <alex@wgate.com> |
+ +----------------------------------------------------------------------+
+ */
+
+/* $Id$ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+
+#if HAVE_LIBINTL
+
+#include <stdio.h>
+#include "ext/standard/info.h"
+#include "php_gettext.h"
+
+/* {{{ arginfo */
+ZEND_BEGIN_ARG_INFO(arginfo_textdomain, 0)
+ ZEND_ARG_INFO(0, domain)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_gettext, 0)
+ ZEND_ARG_INFO(0, msgid)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_dgettext, 0)
+ ZEND_ARG_INFO(0, domain_name)
+ ZEND_ARG_INFO(0, msgid)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_dcgettext, 0)
+ ZEND_ARG_INFO(0, domain_name)
+ ZEND_ARG_INFO(0, msgid)
+ ZEND_ARG_INFO(0, category)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_bindtextdomain, 0)
+ ZEND_ARG_INFO(0, domain_name)
+ ZEND_ARG_INFO(0, dir)
+ZEND_END_ARG_INFO()
+
+#if HAVE_NGETTEXT
+ZEND_BEGIN_ARG_INFO(arginfo_ngettext, 0)
+ ZEND_ARG_INFO(0, msgid1)
+ ZEND_ARG_INFO(0, msgid2)
+ ZEND_ARG_INFO(0, count)
+ZEND_END_ARG_INFO()
+#endif
+
+#if HAVE_DNGETTEXT
+ZEND_BEGIN_ARG_INFO(arginfo_dngettext, 0)
+ ZEND_ARG_INFO(0, domain)
+ ZEND_ARG_INFO(0, msgid1)
+ ZEND_ARG_INFO(0, msgid2)
+ ZEND_ARG_INFO(0, count)
+ZEND_END_ARG_INFO()
+#endif
+
+#if HAVE_DCNGETTEXT
+ZEND_BEGIN_ARG_INFO(arginfo_dcngettext, 0)
+ ZEND_ARG_INFO(0, domain)
+ ZEND_ARG_INFO(0, msgid1)
+ ZEND_ARG_INFO(0, msgid2)
+ ZEND_ARG_INFO(0, count)
+ ZEND_ARG_INFO(0, category)
+ZEND_END_ARG_INFO()
+#endif
+
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+ZEND_BEGIN_ARG_INFO(arginfo_bind_textdomain_codeset, 0)
+ ZEND_ARG_INFO(0, domain)
+ ZEND_ARG_INFO(0, codeset)
+ZEND_END_ARG_INFO()
+#endif
+/* }}} */
+
+/* {{{ php_gettext_functions[]
+ */
+const zend_function_entry php_gettext_functions[] = {
+ PHP_NAMED_FE(textdomain, zif_textdomain, arginfo_textdomain)
+ PHP_NAMED_FE(gettext, zif_gettext, arginfo_gettext)
+ /* Alias for gettext() */
+ PHP_NAMED_FE(_, zif_gettext, arginfo_gettext)
+ PHP_NAMED_FE(dgettext, zif_dgettext, arginfo_dgettext)
+ PHP_NAMED_FE(dcgettext, zif_dcgettext, arginfo_dcgettext)
+ PHP_NAMED_FE(bindtextdomain, zif_bindtextdomain, arginfo_bindtextdomain)
+#if HAVE_NGETTEXT
+ PHP_NAMED_FE(ngettext, zif_ngettext, arginfo_ngettext)
+#endif
+#if HAVE_DNGETTEXT
+ PHP_NAMED_FE(dngettext, zif_dngettext, arginfo_dngettext)
+#endif
+#if HAVE_DCNGETTEXT
+ PHP_NAMED_FE(dcngettext, zif_dcngettext, arginfo_dcngettext)
+#endif
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+ PHP_NAMED_FE(bind_textdomain_codeset, zif_bind_textdomain_codeset, arginfo_bind_textdomain_codeset)
+#endif
+ PHP_FE_END
+};
+/* }}} */
+
+#include <libintl.h>
+
+zend_module_entry php_gettext_module_entry = {
+ STANDARD_MODULE_HEADER,
+ "gettext",
+ php_gettext_functions,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ PHP_MINFO(php_gettext),
+ NO_VERSION_YET,
+ STANDARD_MODULE_PROPERTIES
+};
+
+#ifdef COMPILE_DL_GETTEXT
+ZEND_GET_MODULE(php_gettext)
+#endif
+
+#define PHP_GETTEXT_MAX_DOMAIN_LENGTH 1024
+#define PHP_GETTEXT_MAX_MSGID_LENGTH 4096
+
+#define PHP_GETTEXT_DOMAIN_LENGTH_CHECK \
+ if (domain_len > PHP_GETTEXT_MAX_DOMAIN_LENGTH) { \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "domain passed too long"); \
+ RETURN_FALSE; \
+ }
+
+#define PHP_GETTEXT_LENGTH_CHECK(check_name, check_len) \
+ if (check_len > PHP_GETTEXT_MAX_MSGID_LENGTH) { \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s passed too long", check_name); \
+ RETURN_FALSE; \
+ }
+
+PHP_MINFO_FUNCTION(php_gettext)
+{
+ php_info_print_table_start();
+ php_info_print_table_row(2, "GetText Support", "enabled");
+ php_info_print_table_end();
+}
+
+/* {{{ proto string textdomain(string domain)
+ Set the textdomain to "domain". Returns the current domain */
+PHP_NAMED_FUNCTION(zif_textdomain)
+{
+ char *domain, *domain_name, *retval;
+ int domain_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &domain, &domain_len) == FAILURE) {
+ return;
+ }
+
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK
+
+ if (strcmp(domain, "") && strcmp(domain, "0")) {
+ domain_name = domain;
+ } else {
+ domain_name = NULL;
+ }
+
+ retval = textdomain(domain_name);
+
+ RETURN_STRING(retval, 1);
+}
+/* }}} */
+
+/* {{{ proto string gettext(string msgid)
+ Return the translation of msgid for the current domain, or msgid unaltered if a translation does not exist */
+PHP_NAMED_FUNCTION(zif_gettext)
+{
+ char *msgid, *msgstr;
+ int msgid_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &msgid, &msgid_len) == FAILURE) {
+ return;
+ }
+
+ PHP_GETTEXT_LENGTH_CHECK("msgid", msgid_len)
+ msgstr = gettext(msgid);
+
+ RETURN_STRING(msgstr, 1);
+}
+/* }}} */
+
+/* {{{ proto string dgettext(string domain_name, string msgid)
+ Return the translation of msgid for domain_name, or msgid unaltered if a translation does not exist */
+PHP_NAMED_FUNCTION(zif_dgettext)
+{
+ char *domain, *msgid, *msgstr;
+ int domain_len, msgid_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &domain, &domain_len, &msgid, &msgid_len) == FAILURE) {
+ return;
+ }
+
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK
+ PHP_GETTEXT_LENGTH_CHECK("msgid", msgid_len)
+
+ msgstr = dgettext(domain, msgid);
+
+ RETURN_STRING(msgstr, 1);
+}
+/* }}} */
+
+/* {{{ proto string dcgettext(string domain_name, string msgid, long category)
+ Return the translation of msgid for domain_name and category, or msgid unaltered if a translation does not exist */
+PHP_NAMED_FUNCTION(zif_dcgettext)
+{
+ char *domain, *msgid, *msgstr;
+ int domain_len, msgid_len;
+ long category;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl", &domain, &domain_len, &msgid, &msgid_len, &category) == FAILURE) {
+ return;
+ }
+
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK
+ PHP_GETTEXT_LENGTH_CHECK("msgid", msgid_len)
+
+ msgstr = dcgettext(domain, msgid, category);
+
+ RETURN_STRING(msgstr, 1);
+}
+/* }}} */
+
+/* {{{ proto string bindtextdomain(string domain_name, string dir)
+ Bind to the text domain domain_name, looking for translations in dir. Returns the current domain */
+PHP_NAMED_FUNCTION(zif_bindtextdomain)
+{
+ char *domain, *dir;
+ int domain_len, dir_len;
+ char *retval, dir_name[MAXPATHLEN];
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &domain, &domain_len, &dir, &dir_len) == FAILURE) {
+ return;
+ }
+
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK
+
+ if (domain[0] == '\0') {
+ php_error(E_WARNING, "The first parameter of bindtextdomain must not be empty");
+ RETURN_FALSE;
+ }
+
+ if (dir[0] != '\0' && strcmp(dir, "0")) {
+ if (!VCWD_REALPATH(dir, dir_name)) {
+ RETURN_FALSE;
+ }
+ } else if (!VCWD_GETCWD(dir_name, MAXPATHLEN)) {
+ RETURN_FALSE;
+ }
+
+ retval = bindtextdomain(domain, dir_name);
+
+ RETURN_STRING(retval, 1);
+}
+/* }}} */
+
+#if HAVE_NGETTEXT
+/* {{{ proto string ngettext(string MSGID1, string MSGID2, int N)
+ Plural version of gettext() */
+PHP_NAMED_FUNCTION(zif_ngettext)
+{
+ char *msgid1, *msgid2, *msgstr;
+ int msgid1_len, msgid2_len;
+ long count;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl", &msgid1, &msgid1_len, &msgid2, &msgid2_len, &count) == FAILURE) {
+ return;
+ }
+
+ PHP_GETTEXT_LENGTH_CHECK("msgid1", msgid1_len)
+ PHP_GETTEXT_LENGTH_CHECK("msgid2", msgid2_len)
+
+ msgstr = ngettext(msgid1, msgid2, count);
+ if (msgstr) {
+ RETVAL_STRING(msgstr, 1);
+ }
+}
+/* }}} */
+#endif
+
+#if HAVE_DNGETTEXT
+/* {{{ proto string dngettext (string domain, string msgid1, string msgid2, int count)
+ Plural version of dgettext() */
+PHP_NAMED_FUNCTION(zif_dngettext)
+{
+ char *domain, *msgid1, *msgid2, *msgstr = NULL;
+ int domain_len, msgid1_len, msgid2_len;
+ long count;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sssl", &domain, &domain_len,
+ &msgid1, &msgid1_len, &msgid2, &msgid2_len, &count) == FAILURE) {
+ return;
+ }
+
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK
+ PHP_GETTEXT_LENGTH_CHECK("msgid1", msgid1_len)
+ PHP_GETTEXT_LENGTH_CHECK("msgid2", msgid2_len)
+
+ msgstr = dngettext(domain, msgid1, msgid2, count);
+ if (msgstr) {
+ RETVAL_STRING(msgstr, 1);
+ }
+}
+/* }}} */
+#endif
+
+#if HAVE_DCNGETTEXT
+/* {{{ proto string dcngettext (string domain, string msgid1, string msgid2, int n, int category)
+ Plural version of dcgettext() */
+PHP_NAMED_FUNCTION(zif_dcngettext)
+{
+ char *domain, *msgid1, *msgid2, *msgstr = NULL;
+ int domain_len, msgid1_len, msgid2_len;
+ long count, category;
+
+ RETVAL_FALSE;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sssll", &domain, &domain_len,
+ &msgid1, &msgid1_len, &msgid2, &msgid2_len, &count, &category) == FAILURE) {
+ return;
+ }
+
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK
+ PHP_GETTEXT_LENGTH_CHECK("msgid1", msgid1_len)
+ PHP_GETTEXT_LENGTH_CHECK("msgid2", msgid2_len)
+
+ msgstr = dcngettext(domain, msgid1, msgid2, count, category);
+
+ if (msgstr) {
+ RETVAL_STRING(msgstr, 1);
+ }
+}
+/* }}} */
+#endif
+
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+
+/* {{{ proto string bind_textdomain_codeset (string domain, string codeset)
+ Specify the character encoding in which the messages from the DOMAIN message catalog will be returned. */
+PHP_NAMED_FUNCTION(zif_bind_textdomain_codeset)
+{
+ char *domain, *codeset, *retval = NULL;
+ int domain_len, codeset_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &domain, &domain_len, &codeset, &codeset_len) == FAILURE) {
+ return;
+ }
+
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK
+
+ retval = bind_textdomain_codeset(domain, codeset);
+
+ if (!retval) {
+ RETURN_FALSE;
+ }
+ RETURN_STRING(retval, 1);
+}
+/* }}} */
+#endif
+
+
+#endif /* HAVE_LIBINTL */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: sw=4 ts=4 fdm=marker
+ * vim<600: sw=4 ts=4
+ */
+
diff --git a/ext/gettext/gettext.dsp b/ext/gettext/gettext.dsp
new file mode 100644
index 0000000..79ea194
--- /dev/null
+++ b/ext/gettext/gettext.dsp
@@ -0,0 +1,113 @@
+# Microsoft Developer Studio Project File - Name="gettext" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=gettext - Win32 Release_TS
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "gettext.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "gettext.mak" CFG="gettext - Win32 Release_TS"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "gettext - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "gettext - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "gettext - Win32 Release_TS"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release_TS"
+# PROP BASE Intermediate_Dir "Release_TS"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release_TS"
+# PROP Intermediate_Dir "Release_TS"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL_GETTEXT" /D ZTS=1 /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GETTEXT_EXPORTS" /D "COMPILE_DL_GETTEXT" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_LIBINTL=1 /D HAVE_BIND_TEXTDOMAIN_CODESET=1 /D HAVE_NGETTEXT=1 /D HAVE_DNGETTEXT=1 /FR /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x406 /d "NDEBUG"
+# ADD RSC /l 0x406 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php5ts.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_gettext.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline"
+# ADD LINK32 php5ts.lib libintl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_gettext.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline"
+
+!ELSEIF "$(CFG)" == "gettext - Win32 Debug_TS"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Debug_TS"
+# PROP BASE Intermediate_Dir "Debug_TS"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Debug_TS"
+# PROP Intermediate_Dir "Debug_TS"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MSSQL_EXPORTS" /D "COMPILE_DL_GETTEXT" /D ZTS=1 /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D ZEND_DEBUG=1 /D HAVE_NGETTEXT=1 /D HAVE_DNGETTEXT=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GETTEXT_EXPORTS" /D "COMPILE_DL_GETTEXT" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_LIBINTL=1 /D HAVE_BIND_TEXTDOMAIN_CODESET=1 /FR /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x406 /d "NDEBUG"
+# ADD RSC /l 0x406 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php5ts.lib /nologo /dll /machine:I386 /out:"../../Debug_TS/php_gettext.dll" /libpath:"..\..\Debug_TS"
+# ADD LINK32 php5ts_debug.lib libintl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /debug /machine:I386 /out:"../../Debug_TS/php_gettext.dll" /libpath:"..\..\Debug_TS"
+
+!ENDIF
+
+# Begin Target
+
+# Name "gettext - Win32 Release_TS"
+# Name "gettext - Win32 Debug_TS"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\gettext.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\php_gettext.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/ext/gettext/php_gettext.h b/ext/gettext/php_gettext.h
new file mode 100644
index 0000000..0c517d9
--- /dev/null
+++ b/ext/gettext/php_gettext.h
@@ -0,0 +1,55 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2013 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: Alex Plotnick <alex@wgate.com> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#ifndef PHP_GETTEXT_H
+#define PHP_GETTEXT_H
+
+#if HAVE_LIBINTL
+
+extern zend_module_entry php_gettext_module_entry;
+#define gettext_module_ptr &php_gettext_module_entry
+
+PHP_MINFO_FUNCTION(php_gettext);
+
+PHP_NAMED_FUNCTION(zif_textdomain);
+PHP_NAMED_FUNCTION(zif_gettext);
+PHP_NAMED_FUNCTION(zif_dgettext);
+PHP_NAMED_FUNCTION(zif_dcgettext);
+PHP_NAMED_FUNCTION(zif_bindtextdomain);
+#if HAVE_NGETTEXT
+PHP_NAMED_FUNCTION(zif_ngettext);
+#endif
+#if HAVE_DNGETTEXT
+PHP_NAMED_FUNCTION(zif_dngettext);
+#endif
+#if HAVE_DCNGETTEXT
+PHP_NAMED_FUNCTION(zif_dcngettext);
+#endif
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+PHP_NAMED_FUNCTION(zif_bind_textdomain_codeset);
+#endif
+
+#else
+#define gettext_module_ptr NULL
+#endif /* HAVE_LIBINTL */
+
+#define phpext_gettext_ptr gettext_module_ptr
+
+#endif /* PHP_GETTEXT_H */
diff --git a/ext/gettext/tests/44938.phpt b/ext/gettext/tests/44938.phpt
new file mode 100644
index 0000000..f2d594a
--- /dev/null
+++ b/ext/gettext/tests/44938.phpt
@@ -0,0 +1,85 @@
+--TEST--
+#44938: gettext functions crash with overlong strings
+--SKIPIF--
+<?php
+if (!extension_loaded("gettext")) {
+ die("skip\n");
+}
+--FILE--
+<?php
+$overflown = str_repeat('C', 8476509);
+$msgid = "msgid";
+$domain = "domain";
+$category = "cat";
+
+var_dump(bindtextdomain($overflown, 'path'));
+
+var_dump(dngettext($overflown, $msgid, $msgid, 1));
+var_dump(dngettext($domain, $overflown, $msgid, 1));
+var_dump(dngettext($domain, $msgid, $overflown, 1));
+
+var_dump(gettext($overflown));
+
+var_dump(ngettext($overflown, $msgid, -1));
+var_dump(ngettext($msgid, $overflown, -1));
+
+var_dump(dcgettext($overflown, $msgid, -1));
+var_dump(dcgettext($domain, $overflown, -1));
+
+var_dump(dcngettext($overflown, $msgid, $msgid, -1, -1));
+var_dump(dcngettext($domain, $overflown, $msgid, -1, -1));
+var_dump(dcngettext($domain, $msgid, $overflown, -1, -1));
+
+var_dump(dgettext($overflown, $msgid));
+var_dump(dgettext($domain, $overflown));
+
+var_dump(textdomain($overflown));
+?>
+==DONE==
+--EXPECTF--
+
+Warning: bindtextdomain(): domain passed too long in %s on line %d
+bool(false)
+
+Warning: dngettext(): domain passed too long in %s on line %d
+bool(false)
+
+Warning: dngettext(): msgid1 passed too long in %s on line %d
+bool(false)
+
+Warning: dngettext(): msgid2 passed too long in %s on line %d
+bool(false)
+
+Warning: gettext(): msgid passed too long in %s on line %d
+bool(false)
+
+Warning: ngettext(): msgid1 passed too long in %s on line %d
+bool(false)
+
+Warning: ngettext(): msgid2 passed too long in %s on line %d
+bool(false)
+
+Warning: dcgettext(): domain passed too long in %s on line %d
+bool(false)
+
+Warning: dcgettext(): msgid passed too long in %s on line %d
+bool(false)
+
+Warning: dcngettext(): domain passed too long in %s on line %d
+bool(false)
+
+Warning: dcngettext(): msgid1 passed too long in %s on line %d
+bool(false)
+
+Warning: dcngettext(): msgid2 passed too long in %s on line %d
+bool(false)
+
+Warning: dgettext(): domain passed too long in %s on line %d
+bool(false)
+
+Warning: dgettext(): msgid passed too long in %s on line %d
+bool(false)
+
+Warning: textdomain(): domain passed too long in %s on line %d
+bool(false)
+==DONE==
diff --git a/ext/gettext/tests/dcngettext.phpt b/ext/gettext/tests/dcngettext.phpt
new file mode 100644
index 0000000..2b8e2b1
--- /dev/null
+++ b/ext/gettext/tests/dcngettext.phpt
@@ -0,0 +1,30 @@
+--TEST--
+dcngettext() tests
+--SKIPIF--
+<?php
+if (!extension_loaded("gettext")) die("skip");
+if (!function_exists("dcngettext")) die("skip dcngettext() doesn't exist");
+?>
+--FILE--
+<?php
+
+var_dump(dcngettext(1,1,1,1));
+var_dump(dcngettext(1,1,1,1,1));
+var_dump(dcngettext("test","test","test",1,1));
+var_dump(dcngettext("test","test","test",0,0));
+var_dump(dcngettext("test","test","test",-1,-1));
+var_dump(dcngettext("","","",1,1));
+var_dump(dcngettext("","","",0,0));
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: dcngettext() expects exactly 5 parameters, 4 given in %s on line %d
+bool(false)
+string(1) "1"
+string(4) "test"
+string(4) "test"
+string(4) "test"
+string(0) ""
+string(0) ""
+Done
diff --git a/ext/gettext/tests/gettext_basic-enus.phpt b/ext/gettext/tests/gettext_basic-enus.phpt
new file mode 100644
index 0000000..4691d77
--- /dev/null
+++ b/ext/gettext/tests/gettext_basic-enus.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Gettext basic test with en_US locale that should be on nearly every system
+--SKIPIF--
+<?php
+ if (!extension_loaded("gettext")) {
+ die("skip\n");
+ }
+ if (!setlocale(LC_ALL, 'en_US.UTF-8')) {
+ die("skip en_US.UTF-8 locale not supported.");
+ }
+?>
+--FILE--
+<?php
+
+chdir(dirname(__FILE__));
+setlocale(LC_ALL, 'en_US.UTF-8');
+bindtextdomain ("messages", "./locale");
+textdomain ("messages");
+echo gettext("Basic test"), "\n";
+echo _("Basic test"), "\n";
+
+?>
+--EXPECT--
+A basic test
+A basic test
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09 \ No newline at end of file
diff --git a/ext/gettext/tests/gettext_basic.phpt b/ext/gettext/tests/gettext_basic.phpt
new file mode 100644
index 0000000..441ca57
--- /dev/null
+++ b/ext/gettext/tests/gettext_basic.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Gettext basic test
+--SKIPIF--
+<?php
+ if (!extension_loaded("gettext")) {
+ die("skip\n");
+ }
+ if (!setlocale(LC_ALL, 'fi_FI')) {
+ die("skip fi_FI locale not supported.");
+ }
+?>
+--FILE--
+<?php // $Id$
+
+chdir(dirname(__FILE__));
+setlocale(LC_ALL, 'fi_FI');
+bindtextdomain ("messages", "./locale");
+textdomain ("messages");
+echo gettext("Basic test"), "\n";
+echo _("Basic test"), "\n";
+
+?>
+--EXPECT--
+Perustesti
+Perustesti
diff --git a/ext/gettext/tests/gettext_bind_textdomain_codeset-retval.phpt b/ext/gettext/tests/gettext_bind_textdomain_codeset-retval.phpt
new file mode 100644
index 0000000..2c8e561
--- /dev/null
+++ b/ext/gettext/tests/gettext_bind_textdomain_codeset-retval.phpt
@@ -0,0 +1,22 @@
+--TEST--
+test if bind_textdomain_codeset() returns correct value
+--SKIPIF--
+<?php
+ if (!extension_loaded("gettext")) {
+ die("skip");
+ }
+?>
+--FILE--
+<?php
+ var_dump(bind_textdomain_codeset(false,false));
+ var_dump(bind_textdomain_codeset('messages', "UTF-8"));
+
+ echo "Done\n";
+?>
+--EXPECTF--
+bool(false)
+string(5) "UTF-8"
+Done
+--CREDITS--
+Florian Holzhauer fh-pt@fholzhauer.de
+PHP Testfest Berlin 2009-05-09 \ No newline at end of file
diff --git a/ext/gettext/tests/gettext_bind_textdomain_codeset-wrongparams.phpt b/ext/gettext/tests/gettext_bind_textdomain_codeset-wrongparams.phpt
new file mode 100644
index 0000000..eb50c5d
--- /dev/null
+++ b/ext/gettext/tests/gettext_bind_textdomain_codeset-wrongparams.phpt
@@ -0,0 +1,23 @@
+--TEST--
+test if bind_textdomain_codeset() fails on wrong param count
+--SKIPIF--
+<?php
+ if (!extension_loaded("gettext")) {
+ die("skip");
+ }
+?>
+--FILE--
+<?php
+ bind_textdomain_codeset('messages');
+ bind_textdomain_codeset('messages','foo','bar');
+
+ echo "Done\n";
+?>
+--EXPECTF--
+Warning: bind_textdomain_codeset() expects exactly 2 parameters, 1 given in %s on line %d
+
+Warning: bind_textdomain_codeset() expects exactly 2 parameters, 3 given in %s on line %d
+Done
+--CREDITS--
+Florian Holzhauer fh-pt@fholzhauer.de
+PHP Testfest Berlin 2009-05-09 \ No newline at end of file
diff --git a/ext/gettext/tests/gettext_bindtextdomain-cwd.phpt b/ext/gettext/tests/gettext_bindtextdomain-cwd.phpt
new file mode 100644
index 0000000..375e5fb
--- /dev/null
+++ b/ext/gettext/tests/gettext_bindtextdomain-cwd.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Test if bindtextdomain() returns string id if no directory path is set(if directory path is 'null')
+--SKIPIF--
+<?php
+if (!extension_loaded("gettext")) {
+ die("skip gettext extension is not loaded.\n");
+}
+if (!setlocale(LC_ALL, 'en_US.UTF-8')) {
+ die("skip en_US.UTF-8 locale not supported.");
+}
+--FILE--
+<?php
+$base_dir = dirname(__FILE__);
+chdir($base_dir);
+setlocale(LC_ALL, 'en_US.UTF-8');
+bindtextdomain('messages',null);
+var_dump(gettext('Basic test'));
+bindtextdomain('messages', './locale');
+var_dump(gettext('Basic test'));
+
+?>
+--EXPECTF--
+string(10) "Basic test"
+string(12) "A basic test"
+--CREDIT--
+Moritz Neuhaeuser, info@xcompile.net
+PHP Testfest Berlin 2009-05-09
diff --git a/ext/gettext/tests/gettext_bindtextdomain-emptydomain.phpt b/ext/gettext/tests/gettext_bindtextdomain-emptydomain.phpt
new file mode 100644
index 0000000..0ebe66e
--- /dev/null
+++ b/ext/gettext/tests/gettext_bindtextdomain-emptydomain.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Test if bindtextdomain() errors if the domain is empty.
+--SKIPIF--
+<?php
+if (!extension_loaded("gettext")) {
+ die("skip gettext extension is not loaded.\n");
+}
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+bindtextdomain('', 'foobar');
+--EXPECTF--
+Warning: The first parameter of bindtextdomain must not be empty in %s on line %d
+--CREDITS--
+Till Klampaeckel, till@php.net
+PHP Testfest Berlin 2009-05-09 \ No newline at end of file
diff --git a/ext/gettext/tests/gettext_bindtextdomain-path.phpt b/ext/gettext/tests/gettext_bindtextdomain-path.phpt
new file mode 100644
index 0000000..45349b4
--- /dev/null
+++ b/ext/gettext/tests/gettext_bindtextdomain-path.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Test if bindtextdomain() returns false if path does not exist.
+--SKIPIF--
+<?php
+if (!extension_loaded("gettext")) {
+ die("skip gettext extension is not loaded.\n");
+}
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+var_dump(bindtextdomain('example.org', 'foobar'));
+--EXPECTF--
+bool(false)
+--CREDITS--
+Till Klampaeckel, till@php.net
+PHP Testfest Berlin 2009-05-09 \ No newline at end of file
diff --git a/ext/gettext/tests/gettext_bindtextdomain-wrongparams.phpt b/ext/gettext/tests/gettext_bindtextdomain-wrongparams.phpt
new file mode 100644
index 0000000..97939a4
--- /dev/null
+++ b/ext/gettext/tests/gettext_bindtextdomain-wrongparams.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Test if bindtextdomain() errors if you don't supply enough parameters.
+--SKIPIF--
+<?php
+if (!extension_loaded("gettext")) {
+ die("skip gettext extension is not loaded.\n");
+}
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+bindtextdomain('foobar');
+bindtextdomain();
+--EXPECTF--
+Warning: bindtextdomain() expects exactly 2 parameters, 1 given in %s on line %d
+
+Warning: bindtextdomain() expects exactly 2 parameters, 0 given in %s on line %d
+--CREDITS--
+Till Klampaeckel, till@php.net
+PHP Testfest Berlin 2009-05-09 \ No newline at end of file
diff --git a/ext/gettext/tests/gettext_dcgettext-wrongparams.phpt b/ext/gettext/tests/gettext_dcgettext-wrongparams.phpt
new file mode 100644
index 0000000..372a957
--- /dev/null
+++ b/ext/gettext/tests/gettext_dcgettext-wrongparams.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Test if dcgettext() errors when you don't supply the correct params.
+--SKIPIF--
+<?php
+if (!extension_loaded("gettext")) {
+ die("skip gettext extension is not loaded.\n");
+}
+--FILE--
+<?php
+var_dump(dcgettext('a', 'b'));
+--EXPECTF--
+Warning: dcgettext() expects exactly 3 parameters, 2 given in %s on line %d
+NULL
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09 \ No newline at end of file
diff --git a/ext/gettext/tests/gettext_dcgettext.phpt b/ext/gettext/tests/gettext_dcgettext.phpt
new file mode 100644
index 0000000..24b558e
--- /dev/null
+++ b/ext/gettext/tests/gettext_dcgettext.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Test dcgettext() functionality
+--SKIPIF--
+<?php
+if (!extension_loaded("gettext")) {
+ die("skip gettext extension is not loaded.\n");
+}
+if (!setlocale(LC_ALL, 'en_US.UTF-8')) {
+ die("skip en_US.UTF-8 locale not supported.");
+}
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+setlocale(LC_MESSAGES, 'en_US.UTF-8');
+setlocale(LC_ALL, 'en_US.UTF-8');
+bindtextdomain('dngettextTest', './locale');
+
+var_dump(dcgettext('dngettextTest', 'item', LC_CTYPE));
+var_dump(dcgettext('dngettextTest', 'item', LC_MESSAGES));
+--EXPECTF--
+string(8) "cProdukt"
+string(7) "Produkt"
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09 \ No newline at end of file
diff --git a/ext/gettext/tests/gettext_dgettext.phpt b/ext/gettext/tests/gettext_dgettext.phpt
new file mode 100644
index 0000000..a9a1337
--- /dev/null
+++ b/ext/gettext/tests/gettext_dgettext.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Test dgettext() functionality
+--SKIPIF--
+<?php
+if (!extension_loaded("gettext")) {
+ die("SKIP gettext extension is not loaded.\n");
+}
+if (!setlocale(LC_ALL, 'en_US.UTF-8')) {
+ die("SKIP en_US.UTF-8 locale not supported.");
+}
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+setlocale(LC_MESSAGES, 'en_US.UTF-8');
+setlocale(LC_ALL, 'en_US.UTF-8');
+bindtextdomain('dgettextTest', './locale');
+bindtextdomain('dgettextTest_switch', './locale');
+textdomain('dgettextTest');
+
+var_dump(gettext('item'));
+var_dump(dgettext('dgettextTest_switch', 'item'));
+var_dump(gettext('item'));
+?>
+--EXPECT--
+string(7) "Produkt"
+string(16) "Produkt_switched"
+string(7) "Produkt"
+--CREDITS--
+Moritz Neuhaeuser, info@xcompile.net
+PHP Testfest Berlin 2009-05-09
diff --git a/ext/gettext/tests/gettext_dgettext_error_wrongparams.phpt b/ext/gettext/tests/gettext_dgettext_error_wrongparams.phpt
new file mode 100644
index 0000000..7839358
--- /dev/null
+++ b/ext/gettext/tests/gettext_dgettext_error_wrongparams.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Check how dgettext() with wrong parameter types and wrong parameter cou types and wrong parameter count behaves.
+--SKIPIF--
+<?php
+ if (!extension_loaded("gettext")) {
+ die("skip extension gettext not loaded\n");
+ }
+ if (!setlocale(LC_ALL, 'en_US.UTF-8')) {
+ die("skip en_US.UTF-8 locale not supported.");
+ }
+
+?>
+--FILE--
+<?php
+ chdir(dirname(__FILE__));
+ setlocale(LC_ALL, 'en_US.UTF-8');
+ dgettext ('foo');
+ dgettext ();
+
+ dgettext(array(), 'foo');
+ dgettext('foo', array());
+
+?>
+--EXPECTF--
+Warning: dgettext() expects exactly 2 parameters, 1 given in %s.php on line %d
+
+Warning: dgettext() expects exactly 2 parameters, 0 given in %s.php on line %d
+
+Warning: dgettext() expects parameter 1 to be string, array given in %s.php on line %d
+
+Warning: dgettext() expects parameter 2 to be string, array given in %s.php on line %d
+--CREDITS--
+Moritz Neuhaeuser, info@xcompile.net
+PHP Testfest Berlin 2009-05-09
diff --git a/ext/gettext/tests/gettext_dngettext-plural.phpt b/ext/gettext/tests/gettext_dngettext-plural.phpt
new file mode 100644
index 0000000..0417c0e
--- /dev/null
+++ b/ext/gettext/tests/gettext_dngettext-plural.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Test if dngettext() returns the correct translations (optionally plural).
+--SKIPIF--
+<?php
+if (!extension_loaded("gettext")) {
+ die("skip gettext extension is not loaded.\n");
+}
+if (!setlocale(LC_ALL, 'en_US.UTF-8')) {
+ die("skip en_US.UTF-8 locale not supported.");
+}
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+setlocale(LC_ALL, 'en_US.UTF-8');
+bindtextdomain('dngettextTest', './locale');
+
+var_dump(dngettext('dngettextTest', 'item', 'items', 1));
+var_dump(dngettext('dngettextTest', 'item', 'items', 2));
+--EXPECT--
+string(7) "Produkt"
+string(8) "Produkte"
+--CREDITS--
+Till Klampaeckel, till@php.net
+PHP Testfest Berlin 2009-05-09 \ No newline at end of file
diff --git a/ext/gettext/tests/gettext_dngettext-wrongparams.phpt b/ext/gettext/tests/gettext_dngettext-wrongparams.phpt
new file mode 100644
index 0000000..4bcf093
--- /dev/null
+++ b/ext/gettext/tests/gettext_dngettext-wrongparams.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Test if dngettext() errors when you don't supply the correct params.
+--SKIPIF--
+<?php
+if (!extension_loaded("gettext")) {
+ die("skip gettext extension is not loaded.\n");
+}
+if (!setlocale(LC_ALL, 'en_US.UTF-8')) {
+ die("skip en_US.UTF-8 locale not supported.");
+}
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+setlocale(LC_ALL, 'en_US.UTF-8');
+bindtextdomain('dngettextTest', './locale');
+
+var_dump(dngettext('dngettextTest', 'item', 'items'));
+--EXPECTF--
+Warning: dngettext() expects exactly 4 parameters, 3 given in %s on line %d
+NULL
+--CREDITS--
+Till Klampaeckel, till@php.net
+PHP Testfest Berlin 2009-05-09 \ No newline at end of file
diff --git a/ext/gettext/tests/gettext_gettext_error_wrongparams.phpt b/ext/gettext/tests/gettext_gettext_error_wrongparams.phpt
new file mode 100644
index 0000000..a901090
--- /dev/null
+++ b/ext/gettext/tests/gettext_gettext_error_wrongparams.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Check how gettext() with wrong parameters behaves.
+--SKIPIF--
+<?php
+ if (!extension_loaded("gettext")) {
+ die("skip extension gettext not loaded\n");
+ }
+?>
+--FILE--
+<?php
+gettext (array());
+?>
+--EXPECTF--
+Warning: gettext() expects parameter 1 to be string, array given in %s on line 2
+--CREDITS--
+Moritz Neuhaeuser, info@xcompile.net
+PHP Testfest Berlin 2009-05-09
diff --git a/ext/gettext/tests/gettext_ngettext-wrongparams.phpt b/ext/gettext/tests/gettext_ngettext-wrongparams.phpt
new file mode 100644
index 0000000..9003aef
--- /dev/null
+++ b/ext/gettext/tests/gettext_ngettext-wrongparams.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Check how ngettext() with wrong parameters behaves.
+--SKIPIF--
+<?php
+ if (!extension_loaded("gettext")) {
+ die("SKIP extension gettext not loaded\n");
+ }
+
+?>
+--FILE--
+<?php
+ngettext(array(), "", 1);
+ngettext("", array(), 1);
+ngettext("", "", array());
+ngettext();
+ngettext("");
+ngettext("", "");
+?>
+--EXPECTF--
+Warning: ngettext() expects parameter 1 to be string, array given in %s on line 2
+
+Warning: ngettext() expects parameter 2 to be string, array given in %s on line 3
+
+Warning: ngettext() expects parameter 3 to be long, array given in %s on line 4
+
+Warning: ngettext() expects exactly 3 parameters, 0 given in %s on line 5
+
+Warning: ngettext() expects exactly 3 parameters, 1 given in %s on line 6
+
+Warning: ngettext() expects exactly 3 parameters, 2 given in %s on line 7
+--CREDITS--
+Tim Eggert, tim@elbart.com
+PHP Testfest Berlin 2009-05-09
diff --git a/ext/gettext/tests/gettext_ngettext.phpt b/ext/gettext/tests/gettext_ngettext.phpt
new file mode 100644
index 0000000..d0f1302
--- /dev/null
+++ b/ext/gettext/tests/gettext_ngettext.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Test ngettext() functionality
+--SKIPIF--
+<?php
+ if (!extension_loaded("gettext")) {
+ die("SKIP extension gettext not loaded\n");
+ }
+ if (!setlocale(LC_ALL, 'en_US.UTF-8')) {
+ die("SKIP en_US.UTF-8 locale not supported.");
+ }
+?>
+--FILE--
+<?php // $Id$
+chdir(dirname(__FILE__));
+setlocale(LC_ALL, 'en_US.UTF-8');
+bindtextdomain('dngettextTest', './locale');
+textdomain('dngettextTest');
+var_dump(ngettext('item', 'items', 1));
+var_dump(ngettext('item', 'items', 2));
+?>
+--EXPECT--
+string(7) "Produkt"
+string(8) "Produkte"
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
diff --git a/ext/gettext/tests/gettext_phpinfo.phpt b/ext/gettext/tests/gettext_phpinfo.phpt
new file mode 100644
index 0000000..6a38943
--- /dev/null
+++ b/ext/gettext/tests/gettext_phpinfo.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Test phpinfo() displays gettext support
+--SKIPIF--
+<?php
+ if (!extension_loaded("gettext")) {
+ die("SKIP extension gettext not loaded\n");
+ }
+?>
+--FILE--
+<?php
+phpinfo();
+?>
+--EXPECTF--
+%a
+%rGetText Support.*enabled%r
+%a
+--CREDITS--
+Tim Eggert, tim@elbart.com
+PHP Testfest Berlin 2009-05-09
diff --git a/ext/gettext/tests/gettext_textdomain-retval.phpt b/ext/gettext/tests/gettext_textdomain-retval.phpt
new file mode 100644
index 0000000..3e82f67
--- /dev/null
+++ b/ext/gettext/tests/gettext_textdomain-retval.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Check if textdomain() returns the new domain
+--SKIPIF--
+<?php
+ if (!extension_loaded("gettext")) {
+ die("skip\n");
+ }
+ if (!setlocale(LC_ALL, 'en_US.UTF-8')) {
+ die("skip en_US.UTF-8 locale not supported.");
+ }
+?>
+--FILE--
+<?php
+
+chdir(dirname(__FILE__));
+setlocale(LC_ALL, 'en_US.UTF-8');
+bindtextdomain ("messages", "./locale");
+echo textdomain('test'), "\n";
+echo textdomain(null), "\n";
+echo textdomain('foo'), "\n";
+?>
+--EXPECT--
+
+test
+test
+foo
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09 \ No newline at end of file
diff --git a/ext/gettext/tests/gettext_textdomain-wrongparams.phpt b/ext/gettext/tests/gettext_textdomain-wrongparams.phpt
new file mode 100644
index 0000000..251ee9a
--- /dev/null
+++ b/ext/gettext/tests/gettext_textdomain-wrongparams.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Check how textdomain() with wrong parameters behaves.
+--SKIPIF--
+<?php
+ if (!extension_loaded("gettext")) {
+ die("skip\n");
+ }
+ if (!setlocale(LC_ALL, 'en_US.UTF-8')) {
+ die("skip en_US.UTF-8 locale not supported.");
+ }
+?>
+--FILE--
+<?php // $Id$
+
+chdir(dirname(__FILE__));
+setlocale(LC_ALL, 'en_US.UTF-8');
+bindtextdomain ("messages", "./locale");
+textdomain (array());
+
+?>
+--EXPECTF--
+Warning: textdomain() expects parameter 1 to be string, array given in %s on line 6
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09 \ No newline at end of file
diff --git a/ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest.mo b/ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest.mo
new file mode 100644
index 0000000..255e1e9
--- /dev/null
+++ b/ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest.mo
Binary files differ
diff --git a/ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest.po b/ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest.po
new file mode 100644
index 0000000..159a90f
--- /dev/null
+++ b/ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest.po
@@ -0,0 +1,4 @@
+msgid "item"
+msgid_plural "items"
+msgstr[0] "Produkt"
+msgstr[1] "Produkte"
diff --git a/ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest_switch.mo b/ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest_switch.mo
new file mode 100644
index 0000000..c2ab696
--- /dev/null
+++ b/ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest_switch.mo
Binary files differ
diff --git a/ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest_switch.po b/ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest_switch.po
new file mode 100644
index 0000000..b56d189
--- /dev/null
+++ b/ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest_switch.po
@@ -0,0 +1,4 @@
+msgid "item"
+msgid_plural "items"
+msgstr[0] "Produkt_switched"
+msgstr[1] "Produkte_switched"
diff --git a/ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest_switched.po b/ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest_switched.po
new file mode 100644
index 0000000..d6f6ea2
--- /dev/null
+++ b/ext/gettext/tests/locale/en/LC_CTYPE/dgettextTest_switched.po
@@ -0,0 +1,2 @@
+msgid "item"
+msgstr[0] "cProdukt_switched"
diff --git a/ext/gettext/tests/locale/en/LC_CTYPE/dngettextTest.mo b/ext/gettext/tests/locale/en/LC_CTYPE/dngettextTest.mo
new file mode 100644
index 0000000..e9c63ef
--- /dev/null
+++ b/ext/gettext/tests/locale/en/LC_CTYPE/dngettextTest.mo
Binary files differ
diff --git a/ext/gettext/tests/locale/en/LC_CTYPE/dngettextTest.po b/ext/gettext/tests/locale/en/LC_CTYPE/dngettextTest.po
new file mode 100644
index 0000000..863e83c
--- /dev/null
+++ b/ext/gettext/tests/locale/en/LC_CTYPE/dngettextTest.po
@@ -0,0 +1,4 @@
+msgid "item"
+msgid_plural "items"
+msgstr[0] "cProdukt"
+msgstr[1] "cProdukte"
diff --git a/ext/gettext/tests/locale/en/LC_MESSAGES/dgettextTest.mo b/ext/gettext/tests/locale/en/LC_MESSAGES/dgettextTest.mo
new file mode 100644
index 0000000..255e1e9
--- /dev/null
+++ b/ext/gettext/tests/locale/en/LC_MESSAGES/dgettextTest.mo
Binary files differ
diff --git a/ext/gettext/tests/locale/en/LC_MESSAGES/dgettextTest.po b/ext/gettext/tests/locale/en/LC_MESSAGES/dgettextTest.po
new file mode 100644
index 0000000..159a90f
--- /dev/null
+++ b/ext/gettext/tests/locale/en/LC_MESSAGES/dgettextTest.po
@@ -0,0 +1,4 @@
+msgid "item"
+msgid_plural "items"
+msgstr[0] "Produkt"
+msgstr[1] "Produkte"
diff --git a/ext/gettext/tests/locale/en/LC_MESSAGES/dgettextTest_switch.mo b/ext/gettext/tests/locale/en/LC_MESSAGES/dgettextTest_switch.mo
new file mode 100644
index 0000000..c2ab696
--- /dev/null
+++ b/ext/gettext/tests/locale/en/LC_MESSAGES/dgettextTest_switch.mo
Binary files differ
diff --git a/ext/gettext/tests/locale/en/LC_MESSAGES/dgettextTest_switch.po b/ext/gettext/tests/locale/en/LC_MESSAGES/dgettextTest_switch.po
new file mode 100644
index 0000000..b56d189
--- /dev/null
+++ b/ext/gettext/tests/locale/en/LC_MESSAGES/dgettextTest_switch.po
@@ -0,0 +1,4 @@
+msgid "item"
+msgid_plural "items"
+msgstr[0] "Produkt_switched"
+msgstr[1] "Produkte_switched"
diff --git a/ext/gettext/tests/locale/en/LC_MESSAGES/dngettextTest.mo b/ext/gettext/tests/locale/en/LC_MESSAGES/dngettextTest.mo
new file mode 100644
index 0000000..255e1e9
--- /dev/null
+++ b/ext/gettext/tests/locale/en/LC_MESSAGES/dngettextTest.mo
Binary files differ
diff --git a/ext/gettext/tests/locale/en/LC_MESSAGES/dngettextTest.po b/ext/gettext/tests/locale/en/LC_MESSAGES/dngettextTest.po
new file mode 100644
index 0000000..159a90f
--- /dev/null
+++ b/ext/gettext/tests/locale/en/LC_MESSAGES/dngettextTest.po
@@ -0,0 +1,4 @@
+msgid "item"
+msgid_plural "items"
+msgstr[0] "Produkt"
+msgstr[1] "Produkte"
diff --git a/ext/gettext/tests/locale/en/LC_MESSAGES/messages.mo b/ext/gettext/tests/locale/en/LC_MESSAGES/messages.mo
new file mode 100644
index 0000000..335cbdd
--- /dev/null
+++ b/ext/gettext/tests/locale/en/LC_MESSAGES/messages.mo
Binary files differ
diff --git a/ext/gettext/tests/locale/en/LC_MESSAGES/messages.po b/ext/gettext/tests/locale/en/LC_MESSAGES/messages.po
new file mode 100644
index 0000000..2faf01f
--- /dev/null
+++ b/ext/gettext/tests/locale/en/LC_MESSAGES/messages.po
@@ -0,0 +1,15 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: gettext_basic.phpt:11
+msgid "Basic test"
+msgstr "A basic test"
diff --git a/ext/gettext/tests/locale/fi/LC_MESSAGES/messages.mo b/ext/gettext/tests/locale/fi/LC_MESSAGES/messages.mo
new file mode 100644
index 0000000..55f4d1a
--- /dev/null
+++ b/ext/gettext/tests/locale/fi/LC_MESSAGES/messages.mo
Binary files differ
diff --git a/ext/gettext/tests/locale/fi/LC_MESSAGES/messages.po b/ext/gettext/tests/locale/fi/LC_MESSAGES/messages.po
new file mode 100644
index 0000000..3505156
--- /dev/null
+++ b/ext/gettext/tests/locale/fi/LC_MESSAGES/messages.po
@@ -0,0 +1,15 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: gettext_basic.phpt:11
+msgid "Basic test"
+msgstr "Perustesti"