{
    "mode": "perldoc",
    "parameter": "Locale::gettext",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Locale%3A%3Agettext/json",
    "generated": "2026-06-15T14:21:05Z",
    "synopsis": "use Locale::gettext;\nuse POSIX;     # Needed for setlocale()\nsetlocale(LCMESSAGES, \"\");\n# OO interface\nmy $d = Locale::gettext->domain(\"myprogram\");\nprint $d->get(\"Welcome to my program\"), \"\\n\";\n# (printed in the local language)\n# Direct access to C functions\ntextdomain(\"myprogram\");\nprint gettext(\"Welcome to my program\"), \"\\n\";\n# (printed in the local language)",
    "sections": {
        "NAME": {
            "content": "Locale::gettext - message handling functions\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Locale::gettext;\nuse POSIX;     # Needed for setlocale()\n\nsetlocale(LCMESSAGES, \"\");\n\n# OO interface\nmy $d = Locale::gettext->domain(\"myprogram\");\n\nprint $d->get(\"Welcome to my program\"), \"\\n\";\n# (printed in the local language)\n\n# Direct access to C functions\ntextdomain(\"myprogram\");\n\nprint gettext(\"Welcome to my program\"), \"\\n\";\n# (printed in the local language)\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The gettext module permits access from perl to the gettext() family of functions for retrieving\nmessage strings from databases constructed to internationalize software.\n\n$d = Locale::gettext->domain(DOMAIN)\n$d = Locale::gettext->domainraw(DOMAIN)\nCreates a new object for retrieving strings in the domain DOMAIN and returns it. \"domain\"\nrequests that strings be returned as Perl strings (possibly with wide characters) if possible\nwhile \"domainraw\" requests that octet strings directly from functions like \"dgettext()\".\n\n$d->get(MSGID)\nCalls \"dgettext()\" to return the translated string for the given MSGID.\n\n$d->cget(MSGID, CATEGORY)\nCalls \"dcgettext()\" to return the translated string for the given MSGID in the given CATEGORY.\n\n$d->nget(MSGID, MSGIDPLURAL, N)\nCalls \"dngettext()\" to return the translated string for the given MSGID or MSGIDPLURAL\ndepending on N.\n\n$d->ncget(MSGID, MSGIDPLURAL, N, CATEGORY)\nCalls \"dngettext()\" to return the translated string for the given MSGID or MSGIDPLURAL\ndepending on N in the given CATEGORY.\n\n$d->dir([NEWDIR])\nIf NEWDIR is given, calls \"bindtextdomain\" to set the name of the directory where messages for\nthe domain represented by $d are found. Returns the (possibly changed) current directory name.\n\n$d->codeset([NEWCODE])\nFor instances created with \"Locale::gettext->domainraw\", manuiplates the character set of the\nreturned strings. If NEWCODE is given, calls \"bindtextdomaincodeset\" to set the character\nencoding in which messages for the domain represented by $d are returned. Returns the\n(possibly changed) current encoding name.\n",
            "subsections": [
                {
                    "name": "gettext",
                    "content": "parameter within the context of the current locale. dcgettext() takes the message's category and\nthe text domain as parameters while dgettext() defaults to the LCMESSAGES category and"
                },
                {
                    "name": "gettext",
                    "content": "in the database, then \"msgid\" is returned.\n"
                },
                {
                    "name": "ngettext",
                    "content": "messages between singular and plural. See the documentation for the corresponding C functions\nfor details.\n"
                },
                {
                    "name": "textdomain",
                    "content": "*bindtextdomain(domain, dirname)* instructs the retrieval functions to look for the databases\nbelonging to domain \"domain\" in the directory \"dirname\"\n\n*bindtextdomaincodeset(domain, codeset)* instructs the retrieval functions to translate the\nreturned messages to the character encoding given by codeset if the encoding of the message\ncatalog is known.\n"
                }
            ]
        },
        "NOTES": {
            "content": "Not all platforms provide all of the functions. Functions that are not available in the\nunderlying C library will not be available in Perl either.\n\nPerl programs should use the object interface. In addition to being able to return native Perl\nwide character strings, \"bindtextdomaincodeset\" will be emulated if the C library does not\nprovide it.\n",
            "subsections": []
        },
        "VERSION": {
            "content": "1.07.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "",
            "subsections": [
                {
                    "name": "gettext",
                    "content": ""
                }
            ]
        },
        "AUTHOR": {
            "content": "Kim Vandry <vandry@TZoNE.ORG>\n",
            "subsections": []
        }
    },
    "summary": "Locale::gettext - message handling functions",
    "flags": [],
    "examples": [],
    "see_also": []
}