{
    "mode": "perldoc",
    "parameter": "Locale::Maketext::Lexicon",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Locale%3A%3AMaketext%3A%3ALexicon/json",
    "generated": "2026-06-16T00:59:02Z",
    "synopsis": "As part of a localization class, automatically glob for available lexicons:\npackage Hello::I18N;\nuse base 'Locale::Maketext';\nuse Locale::Maketext::Lexicon {\n'*' => [Gettext => '/usr/local/share/locale/*/LCMESSAGES/hello.mo'],\n### Uncomment to fallback when a key is missing from lexicons\n# auto   => 1,\n### Uncomment to decode lexicon entries into Unicode strings\n# decode => 1,\n### Uncomment to load and parse everything right away\n# preload => 1,\n### Uncomment to use %1 / %quant(%1) instead of [1] / [quant, 1]\n# style  => 'gettext',\n};\nExplicitly specify languages, during compile- or run-time:\npackage Hello::I18N;\nuse base 'Locale::Maketext';\nuse Locale::Maketext::Lexicon {\nde => [Gettext => 'hellode.po'],\nfr => [\nGettext => 'hellofr.po',\nGettext => 'local/hello/fr.po',\n],\n};\n# ... incrementally add new lexicons\nLocale::Maketext::Lexicon->import({\nde => [Gettext => 'local/hello/de.po'],\n})\nAlternatively, as part of a localization subclass:\npackage Hello::I18N::de;\nuse base 'Hello::I18N';\nuse Locale::Maketext::Lexicon (Gettext => \\*DATA);\nDATA\n# Some sample data\nmsgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: Hello 1.3.22.1\\n\"\n\"MIME-Version: 1.0\\n\"\n\"Content-Type: text/plain; charset=iso8859-1\\n\"\n\"Content-Transfer-Encoding: 8bit\\n\"\n#: Hello.pm:10\nmsgid \"Hello, World!\"\nmsgstr \"Hallo, Welt!\"\n#: Hello.pm:11\nmsgid \"You have %quant(%1,piece) of mail.\"\nmsgstr \"Sie haben %quant(%1,Poststueck,Poststuecken).\"",
    "sections": {
        "NAME": {
            "content": "Locale::Maketext::Lexicon - Use other catalog formats in Maketext\n",
            "subsections": []
        },
        "VERSION": {
            "content": "This document describes version 0.91 of Locale::Maketext::Lexicon.\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "As part of a localization class, automatically glob for available lexicons:\n\npackage Hello::I18N;\nuse base 'Locale::Maketext';\nuse Locale::Maketext::Lexicon {\n'*' => [Gettext => '/usr/local/share/locale/*/LCMESSAGES/hello.mo'],\n### Uncomment to fallback when a key is missing from lexicons\n# auto   => 1,\n### Uncomment to decode lexicon entries into Unicode strings\n# decode => 1,\n### Uncomment to load and parse everything right away\n# preload => 1,\n### Uncomment to use %1 / %quant(%1) instead of [1] / [quant, 1]\n# style  => 'gettext',\n};\n\nExplicitly specify languages, during compile- or run-time:\n\npackage Hello::I18N;\nuse base 'Locale::Maketext';\nuse Locale::Maketext::Lexicon {\nde => [Gettext => 'hellode.po'],\nfr => [\nGettext => 'hellofr.po',\nGettext => 'local/hello/fr.po',\n],\n};\n# ... incrementally add new lexicons\nLocale::Maketext::Lexicon->import({\nde => [Gettext => 'local/hello/de.po'],\n})\n\nAlternatively, as part of a localization subclass:\n\npackage Hello::I18N::de;\nuse base 'Hello::I18N';\nuse Locale::Maketext::Lexicon (Gettext => \\*DATA);\nDATA\n# Some sample data\nmsgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: Hello 1.3.22.1\\n\"\n\"MIME-Version: 1.0\\n\"\n\"Content-Type: text/plain; charset=iso8859-1\\n\"\n\"Content-Transfer-Encoding: 8bit\\n\"\n\n#: Hello.pm:10\nmsgid \"Hello, World!\"\nmsgstr \"Hallo, Welt!\"\n\n#: Hello.pm:11\nmsgid \"You have %quant(%1,piece) of mail.\"\nmsgstr \"Sie haben %quant(%1,Poststueck,Poststuecken).\"\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module provides lexicon-handling modules to read from other localization formats, such as\n*Gettext*, *Msgcat*, and so on.\n\nIf you are unfamiliar with the concept of lexicon modules, please consult Locale::Maketext and\nthe \"webl10n\" HTML files in the \"docs/\" directory of this module.\n\nA command-line utility xgettext.pl is also installed with this module, for extracting\ntranslatable strings from source files.\n\nThe \"import\" function\nThe \"import()\" function accepts two forms of arguments:\n\n(*format* => *source* ... )\nThis form takes any number of argument pairs (usually one); *source* may be a file name, a\nfilehandle, or an array reference.\n\nFor each such pair, it pass the contents specified by the second argument to\nLocale::Maketext::Lexicon::*format*->parse as a plain list, and export its return value as\nthe %Lexicon hash in the calling package.\n\nIn the case that there are multiple such pairs, the lexicon defined by latter ones overrides\nearlier ones.\n\n{ *language* => [ *format*, *source* ... ] ... }\nThis form accepts a hash reference. It will export a %Lexicon into the subclasses specified\nby each *language*, using the process described above. It is designed to alleviate the need\nto set up a separate subclass for each localized language, and just use the catalog files.\n\nThis module will convert the *language* arguments into lowercase, and replace all \"-\" with\n\"\", so \"zhTW\" and \"zh-tw\" will both map to the \"zhtw\" subclass.\n\nIf *language* begins with \"\", it is taken as an option that controls how lexicons are\nparsed. See \"Options\" for a list of available options.\n\nThe \"*\" is a special *language*; it must be used in conjunction with a filename that also\ncontains \"*\"; all matched files with a valid language code in the place of \"*\" will be\nautomatically prepared as a lexicon subclass. If there is multiple \"*\" in the filename, the\nlast one is used as the language name.\n",
            "subsections": [
                {
                    "name": "Options",
                    "content": "\"auto\"\nIf set to a true value, missing lookups on lexicons are handled silently, as if an \"Auto\"\nlexicon has been appended on all language lexicons.\n\n\"decode\"\nIf set to a true value, source entries will be converted into utf8-strings (available in\nPerl 5.6.1 or later). This feature needs the Encode or Encode::compat module.\n\nCurrently, only the \"Gettext\" backend supports this option.\n\n\"encoding\"\nThis option only has effect when \"decode\" is set to true. It specifies an encoding to store\nlexicon entries, instead of utf8-strings.\n\nIf \"encoding\" is set to \"locale\", the encoding from the current locale setting is used.\n\n\"preload\"\nBy default parsing is delayed until first use of the lexicon, set this option to true value\nto parse it asap. Increment adding lexicons forces parsing.\n"
                },
                {
                    "name": "Subclassing format handlers",
                    "content": "If you wish to override how sources specified in different data types are handled, please use a\nsubclass that overrides \"lexiconget*TYPE*\".\n\nXXX: not documented well enough yet. Patches welcome.\n"
                }
            ]
        },
        "NOTES": {
            "content": "When you attempt to localize an entry missing in the lexicon, Maketext will throw an exception\nby default. To inhibit this behaviour, override the \"AUTO\" key in your language subclasses, for\nexample:\n\n$Hello::I18N::en::Lexicon{AUTO} = 1; # autocreate missing keys\n\nIf you want to implement a new \"Lexicon::*\" backend module, please note that \"parse()\" takes an\narray containing the source strings from the specified filehandle or filename, which are *not*\n\"chomp\"ed. Although if the source is an array reference, its elements will probably not contain\nany newline characters anyway.\n\nThe \"parse()\" function should return a hash reference, which will be assigned to the *typeglob*\n(*Lexicon) of the language module. All it amounts to is that if the returned reference points to\na tied hash, the %Lexicon will be aliased to the same tied hash if it was not initialized\npreviously.\n",
            "subsections": []
        },
        "ACKNOWLEDGMENTS": {
            "content": "Thanks to Jesse Vincent for suggesting this module to be written.\n\nThanks also to Sean M. Burke for coming up with Locale::Maketext in the first place, and\nencouraging me to experiment with alternative Lexicon syntaxes.\n\nThanks also to Yi Ma Mao for providing the MO file parsing subroutine, as well as inspiring me\nto implement file globbing and transcoding support.\n\nSee the AUTHORS file in the distribution for a list of people who have sent helpful patches,\nideas or comments.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "xgettext.pl for extracting translatable strings from common template systems and perl source\nfiles.\n\nLocale::Maketext, Locale::Maketext::Lexicon::Auto, Locale::Maketext::Lexicon::Gettext,\nLocale::Maketext::Lexicon::Msgcat, Locale::Maketext::Lexicon::Tie\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "*   Clinton Gormley <drtech@cpan.org>\n\n*   Audrey Tang <cpan@audreyt.org>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright 2002-2013 by Audrey Tang <cpan@audreyt.org>.\n\nThis software is released under the MIT license cited below.\n\nThe \"MIT\" License\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software\nand associated documentation files (the \"Software\"), to deal in the Software without\nrestriction, including without limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or\nsubstantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING\nBUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\nDAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "This software is Copyright (c) 2014 by Audrey Tang.\n\nThis is free software, licensed under:\n\nThe MIT (X11) License\n",
            "subsections": []
        }
    },
    "summary": "Locale::Maketext::Lexicon - Use other catalog formats in Maketext",
    "flags": [],
    "examples": [],
    "see_also": []
}