{
    "mode": "perldoc",
    "parameter": "Locale::PO",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Locale%3A%3APO/json",
    "generated": "2026-06-12T12:18:56Z",
    "synopsis": "use Locale::PO;\n$po = new Locale::PO([-option=>value,...])\n[$string =] $po->msgid([new string]);\n[$string =] $po->msgstr([new string]);\n[$string =] $po->comment([new string]);\n[$string =] $po->automatic([new string]);\n[$string =] $po->reference([new string]);\n[$value =] $po->fuzzy([value]);\n[$value =] $po->addflag('c-format');\nprint $po->dump;\n$quotedstring = $po->quote($string);\n$string = $po->dequote($quotedstring);\n$aref = Locale::PO->loadfileasarray(<filename>,[encoding]);\n$href = Locale::PO->loadfileashash(<filename>,[encoding]);\nLocale::PO->savefilefromarray(<filename>,$aref,[encoding]);\nLocale::PO->savefilefromhash(<filename>,$href,[encoding]);",
    "sections": {
        "NAME": {
            "content": "Locale::PO - Perl module for manipulating .po entries from GNU gettext\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Locale::PO;\n\n$po = new Locale::PO([-option=>value,...])\n[$string =] $po->msgid([new string]);\n[$string =] $po->msgstr([new string]);\n[$string =] $po->comment([new string]);\n[$string =] $po->automatic([new string]);\n[$string =] $po->reference([new string]);\n[$value =] $po->fuzzy([value]);\n[$value =] $po->addflag('c-format');\nprint $po->dump;\n\n$quotedstring = $po->quote($string);\n$string = $po->dequote($quotedstring);\n\n$aref = Locale::PO->loadfileasarray(<filename>,[encoding]);\n$href = Locale::PO->loadfileashash(<filename>,[encoding]);\nLocale::PO->savefilefromarray(<filename>,$aref,[encoding]);\nLocale::PO->savefilefromhash(<filename>,$href,[encoding]);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module simplifies management of GNU gettext .po files and is an alternative to using emacs\npo-mode. It provides an object-oriented interface in which each entry in a .po file is a\nLocale::PO object.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "new\nmy Locale::PO $po = new Locale::PO;\nmy Locale::PO $po = new Locale::PO(%options);\n\nCreate a new Locale::PO object to represent a po entry. You can optionally set the\nattributes of the entry by passing a list/hash of the form:\n\n-option=>value, -option=>value, etc.\n\nWhere options are msgid, msgidplural, msgstr, msgctxt, comment, automatic, reference,\nfuzzymsgctxt, fuzzymsgid, fuzzymsgidplural, fuzzy, and c-format. See accessor methods\nbelow.\n\nTo generate a po file header, add an entry with an empty msgid, like this:\n\n$po = new Locale::PO(-msgid=>'', -msgstr=>\n\"Project-Id-Version: PACKAGE VERSION\\\\n\" .\n\"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\\\\n\" .\n\"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\\\n\" .\n\"Language-Team: LANGUAGE <LL@li.org>\\\\n\" .\n\"MIME-Version: 1.0\\\\n\" .\n\"Content-Type: text/plain; charset=CHARSET\\\\n\" .\n\"Content-Transfer-Encoding: ENCODING\\\\n\");\n\nmsgid\nSet or get the untranslated string from the object.\n\nThis method expects the new string in unquoted form but returns the current string in quoted\nform.\n\nmsgidplural\nSet or get the untranslated plural string from the object.\n\nThis method expects the new string in unquoted form but returns the current string in quoted\nform.\n\nmsgstr\nSet or get the translated string from the object.\n\nThis method expects the new string in unquoted form but returns the current string in quoted\nform.\n\nmsgstrn\nGet or set the translations if there are purals involved. Takes and returns a hashref where\nthe keys are the 'N' case and the values are the strings. eg:\n\n$po->msgstrn(\n{\n0 => 'found %d plural translations',\n1 => 'found %d singular translation',\n}\n);\n\nThis method expects the new strings in unquoted form but returns the current strings in\nquoted form.\n\nmsgctxt\nSet or get the translation context string from the object.\n\nThis method expects the new string in unquoted form but returns the current string in quoted\nform.\n\nfuzzymsgid\nSet or get the outdated untranslated string from the object.\n\nThis method expects the new string in unquoted form but returns the current string in quoted\nform.\n\nfuzzymsgidplural\nSet or get the outdated untranslated plural string from the object.\n\nThis method expects the new string in unquoted form but returns the current string in quoted\nform.\n\nfuzzymsgctxt\nSet or get the outdated translation context string from the object.\n\nThis method expects the new string in unquoted form but returns the current string in quoted\nform.\n\nobsolete\nReturns 1 if the entry is obsolete. Obsolete entries have their msgid, msgidplural, msgstr,\nmsgstrn and msgctxt lines commented out with \"#~\"\n\nWhen using loadfileashash, non-obsolete entries will always replace obsolete entries with\nthe same msgid.\n\ncomment\nSet or get translator comments from the object.\n\nIf there are no such comments, then the value is undef. Otherwise, the value is a string\nthat contains the comment lines delimited with \"\\n\". The string includes neither the \"# \" at\nthe beginning of each comment line nor the newline at the end of the last comment line.\n\nautomatic\nSet or get automatic comments from the object (inserted by emacs po-mode or xgettext).\n\nIf there are no such comments, then the value is undef. Otherwise, the value is a string\nthat contains the comment lines delimited with \"\\n\". The string includes neither the \"#. \"\nat the beginning of each comment line nor the newline at the end of the last comment line.\n\nreference\nSet or get reference marking comments from the object (inserted by emacs po-mode or\ngettext).\n\nfuzzy\nSet or get the fuzzy flag on the object (\"check this translation\"). When setting, use 1 to\nturn on fuzzy, and 0 to turn it off.\n\ncformat\nSet or get the c-format or no-c-format flag on the object.\n\nThis can take 3 values: 1 implies c-format, 0 implies no-c-format, and undefined implies\nneither.\n\nphpformat\nSet or get the php-format or no-php-format flag on the object.\n\nThis can take 3 values: 1 implies php-format, 0 implies no-php-format, and undefined implies\nneither.\n\nhasflag\nif ($po->hasflag('perl-format')) {\n...\n}\n\nReturns true if the flag exists in the entry's #~ comment\n\naddflag\n$po->addflag('perl-format');\n\nAdds the flag to the #~ comment\n\nremoveflag\n$po->removeflag('perl-format');\n\nRemoves the flag from the #~ comment\n\nloadedlinenumber\nWhen using one of the loadfileas* methods, this will return the line number that the entry\nstarted at in the file.\n\ndump\nReturns the entry as a string, suitable for output to a po file.\n\nquote\nApplies po quotation rules to a string, and returns the quoted string. The quoted string\nwill have all existing double-quote characters escaped by backslashes, and will be enclosed\nin double quotes.\n\ndequote\nReturns a quoted po string to its natural form.\n\nloadfileasarray\nGiven the filename of a po-file, reads the file and returns a reference to a list of\nLocale::PO objects corresponding to the contents of the file, in the same order. Accepts an\noptional encoding parameter (e.g. \"utf8\") which defines how the po-file's input stream will\nbe configured.\n\nloadfileashash\nGiven the filename of a po-file, reads the file and returns a reference to a hash of\nLocale::PO objects corresponding to the contents of the file. The hash keys are the\nuntranslated strings, so this is a cheap way to remove duplicates. The method will prefer to\nkeep entries that have been translated. Accepts an optional encoding parameter (e.g. \"utf8\")\nwhich defines how the po-file's input stream will be configured.\n\nsavefilefromarray\nGiven a filename and a reference to a list of Locale::PO objects, saves those objects to the\nfile, creating a po-file. Accepts an optional encoding parameter (e.g. \"utf8\") which defines\nhow the po-file's output stream will be configured.\n\nsavefilefromhash\nGiven a filename and a reference to a hash of Locale::PO objects, saves those objects to the\nfile, creating a po-file. The entries are sorted alphabetically by untranslated string.\nAccepts an optional encoding parameter (e.g. \"utf8\") which defines how the po-file's output\nstream will be configured.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Maintainer: Ken Prows, perl@xev.net\n\nOriginal version by: Alan Schwartz, alansz@pennmush.org\n",
            "subsections": []
        },
        "BUGS": {
            "content": "If you loadfileas* then savefilefrom*, the output file may have slight cosmetic differences\nfrom the input file (an extra blank line here or there).\n\nmsgid, msgidplural, msgstr, msgstrn and msgctxt expect a non-quoted string as input, but\nreturn quoted strings. I'm hesitant to change this in fear of breaking the modules/scripts of\npeople already using Locale::PO.\n\nLocale::PO requires blank lines between entries, but Uniforum style PO files don't have any.\n\nPlease submit all bug requests using CPAN's ticketing system.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "",
            "subsections": [
                {
                    "name": "xgettext",
                    "content": ""
                }
            ]
        }
    },
    "summary": "Locale::PO - Perl module for manipulating .po entries from GNU gettext",
    "flags": [],
    "examples": [],
    "see_also": []
}