While using this function, remember to call bindtextdomain for as many domains as you want to use in your application. For example, if I have module1 and module2 as 2 separate domains in the same application, you can do the following:
bindtextdomain("module1", "//path/to/my/locale/folder");
bindtextdomain("module2", "//path/to/my/locale/folder");
textdomain("module1");
echo _("Label1"); // this call will get the message from module1
echo dgettext("module2", "Label1"); // this call will get the message from module2
===
Viral Shah| CARVIEW |
Select Language
HTTP/2 301
server: myracloud
date: Fri, 26 Dec 2025 22:02:29 GMT
content-type: text/html
content-length: 161
location: https://www.php.net/manual/function.dgettext.php
HTTP/2 302
server: myracloud
date: Fri, 26 Dec 2025 22:02:30 GMT
content-type: text/html; charset=utf-8
content-length: 0
content-language: en
permissions-policy: interest-cohort=()
x-frame-options: SAMEORIGIN
location: https://www.php.net/manual/en/function.dgettext.php
expires: Fri, 26 Dec 2025 22:02:30 GMT
cache-control: max-age=0
HTTP/2 200
server: myracloud
date: Fri, 26 Dec 2025 22:02:30 GMT
content-type: text/html; charset=utf-8
content-language: en
permissions-policy: interest-cohort=()
x-frame-options: SAMEORIGIN
link: ; rel=shorturl
last-modified: Fri, 26 Dec 2025 20:08:16 GMT
vary: accept-encoding
content-encoding: gzip
expires: Fri, 26 Dec 2025 22:02:30 GMT
cache-control: max-age=0
PHP: dgettext - Manual
update page now
dgettext
(PHP 4, PHP 5, PHP 7, PHP 8)
dgettext — Override the current domain
Description
The dgettext() function allows you to override
the current domain for a single message lookup.
Parameters
domain-
The domain
message-
The message
Return Values
A string on success.
Errors/Exceptions
Throws a ValueError if domain
is the empty string.
Changelog
| Version | Description |
|---|---|
| 8.4.0 |
Now throws a ValueError if domain
is the empty string.
|
+add a note
User Contributed Notes 1 note
viral at noeticsolutions dot com ¶
19 years ago
↑ and ↓ to navigate •
Enter to select •
Esc to close • / to open
Press Enter without
selection to search using Google