1999-04-21 17:26:16 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2009-03-10 23:40:06 +00:00
|
|
|
| PHP Version 6 |
|
1999-04-21 17:26:16 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2008-12-31 11:12:40 +00:00
|
|
|
| Copyright (c) 1997-2009 The PHP Group |
|
1999-04-21 17:26:16 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2006-01-01 13:10:10 +00:00
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
1999-07-16 13:13:16 +00:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-10 20:04:29 +00:00
|
|
|
| available through the world-wide-web at the following url: |
|
2006-01-01 13:10:10 +00:00
|
|
|
| http://www.php.net/license/3_01.txt |
|
1999-07-16 13:13:16 +00:00
|
|
|
| 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. |
|
1999-04-21 17:26:16 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Author: Alex Plotnick <alex@wgate.com> |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
2001-05-24 10:07:29 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
1999-04-21 17:26:16 +00:00
|
|
|
#include "php.h"
|
|
|
|
|
|
|
|
#if HAVE_LIBINTL
|
|
|
|
|
2003-09-24 02:07:04 +00:00
|
|
|
#include <stdio.h>
|
2000-04-05 22:30:19 +00:00
|
|
|
#include "ext/standard/info.h"
|
2003-09-24 02:07:04 +00:00
|
|
|
#include "php_gettext.h"
|
1999-04-21 17:26:16 +00:00
|
|
|
|
2006-06-14 21:29:22 +00:00
|
|
|
/* {{{ 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
|
|
|
|
/* }}} */
|
|
|
|
|
2001-06-06 13:06:12 +00:00
|
|
|
/* {{{ php_gettext_functions[]
|
|
|
|
*/
|
2007-09-27 18:28:44 +00:00
|
|
|
const zend_function_entry php_gettext_functions[] = {
|
2006-06-14 21:29:22 +00:00
|
|
|
PHP_NAMED_FE(textdomain, zif_textdomain, arginfo_textdomain)
|
|
|
|
PHP_NAMED_FE(gettext, zif_gettext, arginfo_gettext)
|
2003-09-24 02:07:04 +00:00
|
|
|
/* Alias for gettext() */
|
2006-06-14 21:29:22 +00:00
|
|
|
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)
|
2001-08-29 13:13:24 +00:00
|
|
|
#if HAVE_NGETTEXT
|
2006-06-14 21:29:22 +00:00
|
|
|
PHP_NAMED_FE(ngettext, zif_ngettext, arginfo_ngettext)
|
2001-08-29 13:13:24 +00:00
|
|
|
#endif
|
|
|
|
#if HAVE_DNGETTEXT
|
2006-06-14 21:29:22 +00:00
|
|
|
PHP_NAMED_FE(dngettext, zif_dngettext, arginfo_dngettext)
|
2001-08-29 13:13:24 +00:00
|
|
|
#endif
|
|
|
|
#if HAVE_DCNGETTEXT
|
2006-06-14 21:29:22 +00:00
|
|
|
PHP_NAMED_FE(dcngettext, zif_dcngettext, arginfo_dcngettext)
|
2001-08-29 13:13:24 +00:00
|
|
|
#endif
|
2001-11-09 16:27:09 +00:00
|
|
|
#if HAVE_BIND_TEXTDOMAIN_CODESET
|
2006-06-14 21:29:22 +00:00
|
|
|
PHP_NAMED_FE(bind_textdomain_codeset, zif_bind_textdomain_codeset, arginfo_bind_textdomain_codeset)
|
2001-11-09 16:27:09 +00:00
|
|
|
#endif
|
1999-04-21 17:26:16 +00:00
|
|
|
{NULL, NULL, NULL}
|
|
|
|
};
|
2001-06-06 13:06:12 +00:00
|
|
|
/* }}} */
|
1999-04-21 17:26:16 +00:00
|
|
|
|
2004-07-29 22:23:23 +00:00
|
|
|
#include <libintl.h>
|
|
|
|
|
1999-12-17 21:50:07 +00:00
|
|
|
zend_module_entry php_gettext_module_entry = {
|
2003-09-24 02:07:04 +00:00
|
|
|
STANDARD_MODULE_HEADER,
|
2001-08-27 22:26:49 +00:00
|
|
|
"gettext",
|
|
|
|
php_gettext_functions,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2003-09-24 02:07:04 +00:00
|
|
|
PHP_MINFO(php_gettext),
|
|
|
|
NO_VERSION_YET,
|
2001-08-27 22:26:49 +00:00
|
|
|
STANDARD_MODULE_PROPERTIES
|
1999-04-21 17:26:16 +00:00
|
|
|
};
|
|
|
|
|
2000-05-23 22:26:51 +00:00
|
|
|
#ifdef COMPILE_DL_GETTEXT
|
|
|
|
ZEND_GET_MODULE(php_gettext)
|
|
|
|
#endif
|
|
|
|
|
2008-10-29 21:02:14 +00:00
|
|
|
#define PHP_GETTEXT_MAX_DOMAIN_LENGTH 1024
|
2008-10-30 14:22:21 +00:00
|
|
|
#define PHP_GETTEXT_MAX_MSGID_LENGTH 4096
|
|
|
|
|
2008-10-29 21:02:14 +00:00
|
|
|
#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; \
|
|
|
|
}
|
|
|
|
|
2008-11-01 23:08:52 +00:00
|
|
|
#define PHP_GETTEXT_LENGTH_CHECK(check_name, check_len) \
|
2008-10-30 14:22:21 +00:00
|
|
|
if (check_len > PHP_GETTEXT_MAX_MSGID_LENGTH) { \
|
|
|
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s passed too long", check_name); \
|
|
|
|
RETURN_FALSE; \
|
|
|
|
}
|
|
|
|
|
2003-09-24 02:07:04 +00:00
|
|
|
PHP_MINFO_FUNCTION(php_gettext)
|
1999-04-21 17:26:16 +00:00
|
|
|
{
|
2000-04-05 22:30:19 +00:00
|
|
|
php_info_print_table_start();
|
2001-06-09 16:55:27 +00:00
|
|
|
php_info_print_table_row(2, "GetText Support", "enabled");
|
2000-04-05 22:30:19 +00:00
|
|
|
php_info_print_table_end();
|
1999-04-21 17:26:16 +00:00
|
|
|
}
|
|
|
|
|
2006-11-17 13:37:02 +00:00
|
|
|
#define RETVAL_FS_STRING(s, f) \
|
|
|
|
RETVAL_STRING((s), (f)); \
|
|
|
|
if (UG(unicode)) { \
|
|
|
|
zval_string_to_unicode_ex(return_value, ZEND_U_CONVERTER(UG(filesystem_encoding_conv)) TSRMLS_CC); \
|
|
|
|
}
|
|
|
|
#define RETURN_FS_STRING(s, f) \
|
|
|
|
RETVAL_FS_STRING((s), (f)); \
|
|
|
|
return;
|
|
|
|
|
2006-11-15 17:14:50 +00:00
|
|
|
/* {{{ proto string textdomain(string domain) U
|
2000-08-08 20:28:19 +00:00
|
|
|
Set the textdomain to "domain". Returns the current domain */
|
2003-09-24 02:07:04 +00:00
|
|
|
PHP_NAMED_FUNCTION(zif_textdomain)
|
1999-04-21 17:26:16 +00:00
|
|
|
{
|
2006-11-15 17:14:50 +00:00
|
|
|
char *domain_str;
|
|
|
|
int domain_len;
|
|
|
|
|
|
|
|
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&", &domain_str, &domain_len, ZEND_U_CONVERTER(UG(filesystem_encoding_conv)))) {
|
|
|
|
return;
|
2000-12-08 16:25:38 +00:00
|
|
|
}
|
2006-11-15 17:14:50 +00:00
|
|
|
|
2008-10-29 21:02:14 +00:00
|
|
|
PHP_GETTEXT_DOMAIN_LENGTH_CHECK
|
|
|
|
|
2006-11-15 17:14:50 +00:00
|
|
|
if (!domain_len || (domain_len == 1 && *domain_str == '0')) {
|
|
|
|
domain_str = NULL;
|
1999-04-21 17:26:16 +00:00
|
|
|
}
|
2006-11-17 13:37:02 +00:00
|
|
|
RETURN_FS_STRING(textdomain(domain_str), ZSTR_DUPLICATE);
|
1999-04-21 17:26:16 +00:00
|
|
|
}
|
2000-03-19 23:39:05 +00:00
|
|
|
/* }}} */
|
1999-04-21 17:26:16 +00:00
|
|
|
|
2006-11-15 17:14:50 +00:00
|
|
|
/* {{{ proto binary gettext(string msgid) U
|
2000-08-08 20:28:19 +00:00
|
|
|
Return the translation of msgid for the current domain, or msgid unaltered if a translation does not exist */
|
2003-09-24 02:07:04 +00:00
|
|
|
PHP_NAMED_FUNCTION(zif_gettext)
|
1999-04-21 17:26:16 +00:00
|
|
|
{
|
2006-11-15 17:14:50 +00:00
|
|
|
char *msgid_str;
|
|
|
|
int msgid_len;
|
2008-10-30 14:22:21 +00:00
|
|
|
|
2006-11-15 17:14:50 +00:00
|
|
|
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&", &msgid_str, &msgid_len, UG(ascii_conv))) {
|
|
|
|
return;
|
2000-12-08 16:25:38 +00:00
|
|
|
}
|
2008-10-30 14:22:21 +00:00
|
|
|
|
2008-11-01 23:08:52 +00:00
|
|
|
PHP_GETTEXT_LENGTH_CHECK("msgid", msgid_len)
|
2008-10-30 14:22:21 +00:00
|
|
|
|
2006-11-17 13:37:02 +00:00
|
|
|
RETURN_STRING(gettext(msgid_str), ZSTR_DUPLICATE);
|
1999-04-21 17:26:16 +00:00
|
|
|
}
|
2000-03-19 23:39:05 +00:00
|
|
|
/* }}} */
|
1999-04-21 17:26:16 +00:00
|
|
|
|
2006-11-15 17:14:50 +00:00
|
|
|
/* {{{ proto binary dgettext(string domain_name, string msgid) U
|
2000-08-08 20:28:19 +00:00
|
|
|
Return the translation of msgid for domain_name, or msgid unaltered if a translation does not exist */
|
2003-09-24 02:07:04 +00:00
|
|
|
PHP_NAMED_FUNCTION(zif_dgettext)
|
1999-04-21 17:26:16 +00:00
|
|
|
{
|
2006-11-15 17:14:50 +00:00
|
|
|
char *domain_str, *msgid_str;
|
|
|
|
int domain_len, msgid_len;
|
|
|
|
|
|
|
|
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&s&", &domain_str, &domain_len, ZEND_U_CONVERTER(UG(filesystem_encoding_conv)), &msgid_str, &msgid_len, UG(ascii_conv))) {
|
|
|
|
return;
|
1999-04-21 17:26:16 +00:00
|
|
|
}
|
2008-10-29 21:02:14 +00:00
|
|
|
|
|
|
|
PHP_GETTEXT_DOMAIN_LENGTH_CHECK
|
2008-11-01 23:08:52 +00:00
|
|
|
PHP_GETTEXT_LENGTH_CHECK("msgid", msgid_len)
|
2008-10-29 21:02:14 +00:00
|
|
|
|
2006-11-17 13:37:02 +00:00
|
|
|
RETURN_STRING(dgettext(domain_str, msgid_str), ZSTR_DUPLICATE);
|
1999-04-21 17:26:16 +00:00
|
|
|
}
|
2000-03-19 23:39:05 +00:00
|
|
|
/* }}} */
|
1999-04-21 17:26:16 +00:00
|
|
|
|
2006-11-15 17:14:50 +00:00
|
|
|
/* {{{ proto binary dcgettext(string domain_name, string msgid, int category) U
|
2000-08-08 20:28:19 +00:00
|
|
|
Return the translation of msgid for domain_name and category, or msgid unaltered if a translation does not exist */
|
2003-09-24 02:07:04 +00:00
|
|
|
PHP_NAMED_FUNCTION(zif_dcgettext)
|
1999-04-21 17:26:16 +00:00
|
|
|
{
|
2006-11-15 17:14:50 +00:00
|
|
|
char *domain_str, *msgid_str;
|
|
|
|
int domain_len, msgid_len;
|
|
|
|
long category;
|
|
|
|
|
|
|
|
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&s&l", &domain_str, &domain_len, ZEND_U_CONVERTER(UG(filesystem_encoding_conv)), &msgid_str, &msgid_len, UG(ascii_conv), &category)) {
|
|
|
|
return;
|
1999-04-21 17:26:16 +00:00
|
|
|
}
|
2008-10-29 21:02:14 +00:00
|
|
|
|
|
|
|
PHP_GETTEXT_DOMAIN_LENGTH_CHECK
|
2008-11-01 23:08:52 +00:00
|
|
|
PHP_GETTEXT_LENGTH_CHECK("msgid", msgid_len)
|
2008-10-29 21:02:14 +00:00
|
|
|
|
2006-11-17 13:37:02 +00:00
|
|
|
RETURN_STRING(dcgettext(domain_str, msgid_str, category), ZSTR_DUPLICATE);
|
1999-04-21 17:26:16 +00:00
|
|
|
}
|
2000-03-19 23:39:05 +00:00
|
|
|
/* }}} */
|
1999-04-21 17:26:16 +00:00
|
|
|
|
2006-11-15 17:14:50 +00:00
|
|
|
/* {{{ proto string bindtextdomain(string domain_name, string dir) U
|
2000-08-08 20:28:19 +00:00
|
|
|
Bind to the text domain domain_name, looking for translations in dir. Returns the current domain */
|
2003-09-24 02:07:04 +00:00
|
|
|
PHP_NAMED_FUNCTION(zif_bindtextdomain)
|
1999-04-21 17:26:16 +00:00
|
|
|
{
|
2006-11-15 17:14:50 +00:00
|
|
|
char *domain_str, *dir_str, dir_tmp[MAXPATHLEN] = {0};
|
|
|
|
int domain_len, dir_len;
|
|
|
|
|
|
|
|
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&s&", &domain_str, &domain_len, ZEND_U_CONVERTER(UG(filesystem_encoding_conv)), &dir_str, &dir_len, ZEND_U_CONVERTER(UG(filesystem_encoding_conv)))) {
|
|
|
|
return;
|
2003-02-08 18:58:34 +00:00
|
|
|
}
|
2008-10-29 21:02:14 +00:00
|
|
|
|
|
|
|
PHP_GETTEXT_DOMAIN_LENGTH_CHECK
|
|
|
|
|
2008-11-22 15:44:07 +00:00
|
|
|
if (!domain_len || !*domain_str) {
|
2006-11-15 17:14:50 +00:00
|
|
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "the first parameter must not be empty");
|
2008-07-29 16:21:38 +00:00
|
|
|
RETURN_FALSE;
|
2006-11-15 17:14:50 +00:00
|
|
|
}
|
|
|
|
if (!dir_len || (dir_len == 1 && *dir_str == '0')) {
|
2007-01-16 14:42:14 +00:00
|
|
|
if (!VCWD_GETCWD(dir_tmp, sizeof(dir_tmp))) {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
} else if (!VCWD_REALPATH(dir_str, dir_tmp)) {
|
|
|
|
RETURN_FALSE;
|
1999-04-21 17:26:16 +00:00
|
|
|
}
|
2006-11-17 13:37:02 +00:00
|
|
|
RETURN_FS_STRING(bindtextdomain(domain_str, dir_tmp), ZSTR_DUPLICATE);
|
1999-04-21 17:26:16 +00:00
|
|
|
}
|
2000-03-19 23:39:05 +00:00
|
|
|
/* }}} */
|
1999-04-21 17:26:16 +00:00
|
|
|
|
2001-08-29 13:13:24 +00:00
|
|
|
#if HAVE_NGETTEXT
|
2006-11-15 17:14:50 +00:00
|
|
|
/* {{{ proto binary ngettext(string msgid1, string msgid2, int count) U
|
2001-08-27 22:26:49 +00:00
|
|
|
Plural version of gettext() */
|
2003-09-24 02:07:04 +00:00
|
|
|
PHP_NAMED_FUNCTION(zif_ngettext)
|
2001-08-27 18:43:07 +00:00
|
|
|
{
|
2006-11-15 17:14:50 +00:00
|
|
|
char *msgid_str1, *msgid_str2, *msgstr;
|
2008-11-02 21:06:46 +00:00
|
|
|
int msgid1_len, msgid2_len;
|
2006-11-15 17:14:50 +00:00
|
|
|
long count;
|
2008-10-30 14:22:21 +00:00
|
|
|
|
2008-11-02 21:06:46 +00:00
|
|
|
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&s&l", &msgid_str1, &msgid1_len, UG(ascii_conv), &msgid_str2, &msgid2_len, UG(ascii_conv), &count)) {
|
2006-11-15 17:14:50 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
2008-10-30 14:22:21 +00:00
|
|
|
|
2008-11-01 23:08:52 +00:00
|
|
|
PHP_GETTEXT_LENGTH_CHECK("msgid1", msgid1_len)
|
|
|
|
PHP_GETTEXT_LENGTH_CHECK("msgid2", msgid2_len)
|
2008-10-30 14:22:21 +00:00
|
|
|
|
2006-11-15 17:14:50 +00:00
|
|
|
if ((msgstr = ngettext(msgid_str1, msgid_str2, count))) {
|
2006-11-17 13:37:02 +00:00
|
|
|
RETURN_STRING(msgstr, ZSTR_DUPLICATE);
|
2001-08-27 18:43:07 +00:00
|
|
|
} else {
|
2006-11-15 17:14:50 +00:00
|
|
|
RETURN_FALSE;
|
2001-08-27 18:43:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
2001-08-29 13:13:24 +00:00
|
|
|
#endif
|
2001-08-27 18:43:07 +00:00
|
|
|
|
2001-08-29 13:13:24 +00:00
|
|
|
#if HAVE_DNGETTEXT
|
2006-11-15 17:14:50 +00:00
|
|
|
/* {{{ proto binary dngettext (string domain, string msgid1, string msgid2, int count) U
|
2001-08-27 22:26:49 +00:00
|
|
|
Plural version of dgettext() */
|
2003-09-24 02:07:04 +00:00
|
|
|
PHP_NAMED_FUNCTION(zif_dngettext)
|
2001-08-27 18:43:07 +00:00
|
|
|
{
|
2006-11-15 17:14:50 +00:00
|
|
|
char *domain_str, *msgid_str1, *msgid_str2, *msgstr;
|
2008-11-02 21:06:46 +00:00
|
|
|
int domain_len, msgid1_len, msgid2_len;
|
2006-11-15 17:14:50 +00:00
|
|
|
long count;
|
|
|
|
|
2008-11-02 21:06:46 +00:00
|
|
|
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&s&s&l", &domain_str, &domain_len, ZEND_U_CONVERTER(UG(filesystem_encoding_conv)), &msgid_str1, &msgid1_len, UG(ascii_conv), &msgid_str2, &msgid2_len, UG(ascii_conv), &count)) {
|
2006-11-15 17:14:50 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
2008-10-29 21:02:14 +00:00
|
|
|
|
|
|
|
PHP_GETTEXT_DOMAIN_LENGTH_CHECK
|
2008-11-01 23:08:52 +00:00
|
|
|
PHP_GETTEXT_LENGTH_CHECK("msgid1", msgid1_len)
|
|
|
|
PHP_GETTEXT_LENGTH_CHECK("msgid2", msgid2_len)
|
2008-10-29 21:02:14 +00:00
|
|
|
|
2006-11-15 17:14:50 +00:00
|
|
|
if ((msgstr = dngettext(domain_str, msgid_str1, msgid_str2, count))) {
|
2006-11-17 13:37:02 +00:00
|
|
|
RETURN_STRING(msgstr, ZSTR_DUPLICATE);
|
2001-08-27 18:43:07 +00:00
|
|
|
} else {
|
2006-11-15 17:14:50 +00:00
|
|
|
RETURN_FALSE;
|
2001-08-27 18:43:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
2001-08-29 13:13:24 +00:00
|
|
|
#endif
|
2001-08-27 18:43:07 +00:00
|
|
|
|
2001-08-29 13:13:24 +00:00
|
|
|
#if HAVE_DCNGETTEXT
|
2006-11-15 17:14:50 +00:00
|
|
|
/* {{{ proto binary dcngettext (string domain, string msgid1, string msgid2, int count, int category) U
|
|
|
|
Plural version of dcgettext() */
|
2003-09-24 02:07:04 +00:00
|
|
|
PHP_NAMED_FUNCTION(zif_dcngettext)
|
2001-08-27 18:43:07 +00:00
|
|
|
{
|
2006-11-15 17:14:50 +00:00
|
|
|
char *domain_str, *msgid_str1, *msgid_str2, *msgstr;
|
2008-11-02 21:06:46 +00:00
|
|
|
int domain_len, msgid1_len, msgid2_len;
|
2006-11-15 17:14:50 +00:00
|
|
|
long count, category;
|
|
|
|
|
2008-11-02 21:06:46 +00:00
|
|
|
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&s&s&ll", &domain_str, &domain_len, ZEND_U_CONVERTER(UG(filesystem_encoding_conv)), &msgid_str1, &msgid1_len, UG(ascii_conv), &msgid_str2, &msgid2_len, UG(ascii_conv), &count, &category)) {
|
2006-11-15 17:14:50 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
2008-10-29 21:02:14 +00:00
|
|
|
|
|
|
|
PHP_GETTEXT_DOMAIN_LENGTH_CHECK
|
2008-11-01 23:08:52 +00:00
|
|
|
PHP_GETTEXT_LENGTH_CHECK("msgid1", msgid1_len)
|
|
|
|
PHP_GETTEXT_LENGTH_CHECK("msgid2", msgid2_len)
|
2008-10-29 21:02:14 +00:00
|
|
|
|
2006-11-15 17:14:50 +00:00
|
|
|
if ((msgstr = dcngettext(domain_str, msgid_str1, msgid_str2, count, category))) {
|
2006-11-17 13:37:02 +00:00
|
|
|
RETURN_STRING(msgstr, ZSTR_DUPLICATE);
|
2001-08-27 18:43:07 +00:00
|
|
|
} else {
|
2006-11-15 17:14:50 +00:00
|
|
|
RETURN_FALSE;
|
2001-08-27 18:43:07 +00:00
|
|
|
}
|
|
|
|
}
|
2001-08-29 13:13:24 +00:00
|
|
|
/* }}} */
|
|
|
|
#endif
|
2001-08-27 18:43:07 +00:00
|
|
|
|
2001-11-09 16:27:09 +00:00
|
|
|
#if HAVE_BIND_TEXTDOMAIN_CODESET
|
2006-11-15 17:14:50 +00:00
|
|
|
/* {{{ proto string bind_textdomain_codeset (string domain, string codeset) U
|
2001-11-09 16:27:09 +00:00
|
|
|
Specify the character encoding in which the messages from the DOMAIN message catalog will be returned. */
|
2003-09-24 02:07:04 +00:00
|
|
|
PHP_NAMED_FUNCTION(zif_bind_textdomain_codeset)
|
2001-11-09 16:27:09 +00:00
|
|
|
{
|
2006-11-15 17:14:50 +00:00
|
|
|
char *domain_str, *codeset_str, *codeset_ret;
|
|
|
|
int domain_len, codeset_len;
|
2001-11-09 16:27:09 +00:00
|
|
|
|
2006-11-15 17:14:50 +00:00
|
|
|
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&s&", &domain_str, &domain_len, ZEND_U_CONVERTER(UG(filesystem_encoding_conv)), &codeset_str, &codeset_len, UG(ascii_conv))) {
|
|
|
|
return;
|
|
|
|
}
|
2008-10-29 21:02:14 +00:00
|
|
|
|
|
|
|
PHP_GETTEXT_DOMAIN_LENGTH_CHECK
|
|
|
|
|
2006-11-15 17:14:50 +00:00
|
|
|
if (!codeset_len) {
|
|
|
|
codeset_str = NULL;
|
|
|
|
}
|
|
|
|
if ((codeset_ret = bind_textdomain_codeset(domain_str, codeset_str))) {
|
2006-11-17 13:37:02 +00:00
|
|
|
RETURN_ASCII_STRING(codeset_ret, ZSTR_DUPLICATE);
|
2001-11-09 16:27:09 +00:00
|
|
|
} else {
|
2006-11-15 17:14:50 +00:00
|
|
|
RETURN_FALSE;
|
2002-08-07 11:50:49 +00:00
|
|
|
}
|
2001-11-09 16:27:09 +00:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1999-04-21 17:26:16 +00:00
|
|
|
#endif /* HAVE_LIBINTL */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* End:
|
2001-09-09 13:29:31 +00:00
|
|
|
* vim600: sw=4 ts=4 fdm=marker
|
|
|
|
* vim<600: sw=4 ts=4
|
1999-04-21 17:26:16 +00:00
|
|
|
*/
|
2001-08-29 13:13:24 +00:00
|
|
|
|