{"id":7066,"date":"2022-12-20T19:35:11","date_gmt":"2022-12-20T22:35:11","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/gettext-man3\/"},"modified":"2022-12-20T19:35:11","modified_gmt":"2022-12-20T22:35:11","slug":"gettext-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/gettext-man3\/","title":{"rendered":"gettext (man3)"},"content":{"rendered":"<h1 align=\"center\">gettext<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#NOTES\">NOTES<\/a><br \/> <a href=\"#VERSION\">VERSION<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#AUTHOR\">AUTHOR<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Locale::gettext \u2212 message handling functions<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">use Locale::gettext; <br \/> use POSIX; # Needed for setlocale() <br \/> setlocale(LC_MESSAGES, &#8220;&#8221;); <br \/> # OO interface <br \/> my $d = Locale::gettext\u2212>domain(&#8220;my_program&#8221;); <br \/> print $d\u2212>get(&#8220;Welcome to my program&#8221;), &#8220;n&#8221;; <br \/> # (printed in the local language) <br \/> # Direct access to C functions <br \/> textdomain(&#8220;my_program&#8221;); <br \/> print gettext(&#8220;Welcome to my program&#8221;), &#8220;n&#8221;; <br \/> # (printed in the local language)<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The gettext module permits access from perl to the <b>gettext()<\/b> family of functions for retrieving message strings from databases constructed to internationalize software. <br \/> $d = Locale::gettext\u2212>domain( <small>DOMAIN<\/small> ) <br \/> $d = Locale::gettext\u2212>domain_raw( <small>DOMAIN<\/small> )<\/p>\n<p style=\"margin-left:14%;\">Creates a new object for retrieving strings in the domain <b><small>DOMAIN<\/small><\/b> and returns it. &#8220;domain&#8221; requests that strings be returned as Perl strings (possibly with wide characters) if possible while &#8220;domain_raw&#8221; requests that octet strings directly from functions like &#8220;dgettext()&#8221;.<\/p>\n<p style=\"margin-left:11%;\">$d\u2212>get( <small>MSGID<\/small> )<\/p>\n<p style=\"margin-left:14%;\">Calls &#8220;dgettext()&#8221; to return the translated string for the given <b><small>MSGID<\/small><\/b> .<\/p>\n<p style=\"margin-left:11%;\">$d\u2212>cget( <small>MSGID, CATEGORY<\/small> )<\/p>\n<p style=\"margin-left:14%;\">Calls &#8220;dcgettext()&#8221; to return the translated string for the given <b><small>MSGID<\/small><\/b> in the given <b><small>CATEGORY<\/small><\/b> .<\/p>\n<p style=\"margin-left:11%;\">$d\u2212>nget( <small>MSGID, MSGID_PLURAL, N<\/small> )<\/p>\n<p style=\"margin-left:14%;\">Calls &#8220;dngettext()&#8221; to return the translated string for the given <b><small>MSGID<\/small><\/b> or <b><small>MSGID_PLURAL<\/small><\/b> depending on <b>N<\/b>.<\/p>\n<p style=\"margin-left:11%;\">$d\u2212>ncget( <small>MSGID, MSGID_PLURAL, N, CATEGORY<\/small> )<\/p>\n<p style=\"margin-left:14%;\">Calls &#8220;dngettext()&#8221; to return the translated string for the given <b><small>MSGID<\/small><\/b> or <b><small>MSGID_PLURAL<\/small><\/b> depending on <b>N<\/b> in the given <b><small>CATEGORY<\/small><\/b> .<\/p>\n<p style=\"margin-left:11%;\">$d\u2212>dir([ <small>NEWDIR<\/small> ])<\/p>\n<p style=\"margin-left:14%;\">If <b><small>NEWDIR<\/small><\/b> is given, calls &#8220;bindtextdomain&#8221; to set the name of the directory where messages for the domain represented by $d are found. Returns the (possibly changed) current directory name.<\/p>\n<p style=\"margin-left:11%;\">$d\u2212>codeset([ <small>NEWCODE<\/small> ])<\/p>\n<p style=\"margin-left:14%;\">For instances created with &#8220;Locale::gettext\u2212>domain_raw&#8221;, manuiplates the character set of the returned strings. If <b><small>NEWCODE<\/small><\/b> is given, calls &#8220;bind_textdomain_codeset&#8221; to set the character encoding in which messages for the domain represented by $d are returned. Returns the (possibly changed) current encoding name.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>gettext()<\/b>, <b>dgettext()<\/b>, and <b>dcgettext()<\/b> attempt to retrieve a string matching their &#8220;msgid&#8221; parameter within the context of the current locale. <b>dcgettext()<\/b> takes the message\u2019s category and the text domain as parameters while <b>dgettext()<\/b> defaults to the <small>LC_MESSAGES<\/small> category and <b>gettext()<\/b> defaults to <small>LC_MESSAGES<\/small> and uses the current text domain. If the string is not found in the database, then &#8220;msgid&#8221; is returned.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>ngettext()<\/b>, <b>dngettext()<\/b>, and <b>dcngettext()<\/b> function similarily but implement differentiation of messages between singular and plural. See the documentation for the corresponding C functions for details.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>textdomain()<\/b> sets the current text domain and returns the previously active domain.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>bindtextdomain(domain, dirname)<\/i> instructs the retrieval functions to look for the databases belonging to domain &#8220;domain&#8221; in the directory &#8220;dirname&#8221;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>bind_textdomain_codeset(domain, codeset)<\/i> instructs the retrieval functions to translate the returned messages to the character encoding given by <b>codeset<\/b> if the encoding of the message catalog is known.<\/p>\n<h2>NOTES <a name=\"NOTES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Not all platforms provide all of the functions. Functions that are not available in the underlying C library will not be available in Perl either.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Perl programs should use the object interface. In addition to being able to return native Perl wide character strings, &#8220;bind_textdomain_codeset&#8221; will be emulated if the C library does not provide it.<\/p>\n<h2>VERSION <a name=\"VERSION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">1.07.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>gettext<\/b>(3i), <b>gettext<\/b>(1), <b>msgfmt<\/b>(1)<\/p>\n<h2>AUTHOR <a name=\"AUTHOR\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Kim Vandry <vandry@TZoNE.ORG><\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  Locale::gettext \u2212 message handling functions <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3412,3007],"class_list":["post-7066","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-localegettext","tag-man3"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7066","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7066"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7066\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7066"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7066"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7066"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}