Locale-Maketext-Lexicon-1.00/000755 000765 000024 00000000000 12306052703 016617 5ustar00clintonstaff000000 000000 Locale-Maketext-Lexicon-1.00/AUTHORS000644 000765 000024 00000002326 12306052703 017672 0ustar00clintonstaff000000 000000 [Credits] Here is a list of people and their CPAN id, extracted from the ChangeLog file and the mailing list archives. These people have either submitted patches or suggestions, or their bug reports or comments have inspired the appropriate patches. Corrections, additions, deletions welcome: Alain Barbet (ALIAN) Alexandre Simon (ASIMON) Andy Wardley (ABW) Ansgar Burchardt Brian Cassidy (BRICAS) Calum Halcrow Charlie Garrison (CNG) Christian Hansen Cosimo Streppone (COSIMO) Clinton Gormley (DRTECH) Felix Ostmann Gaal Yahas (GAAL) gerhardj Harmen Helmut Lichtenberg Hsin-Chan Chien (HCCHIEN) Ivan Bessarabov (BESSARABV) Jesse Vincent (JESSE) Jiing Deng Joe McCarty Macpaul Lin Mathieu Arnold (MAT) Mikael Sennerholm Niko Tyni Noelle Christian Robert Spier (ROBRT) Ruslan U. Zakirov (RUZ) Sava Chankov (SAVA) Sebastian Knapp Sean M. Burke (SBURKE) Stephen Quinney (SJQUINNEY) Tatsuhiko Miyagawa (MIYAGAWA) Thierry Vignaud Tokuhiro Matsuno (TOKUHIROM) Ton Voon (TONVOON) Wei-Hon Chen Yann Kerherve (YANNK) Yi Ma Mao (IMACAT) Locale-Maketext-Lexicon-1.00/Changes000644 000765 000024 00000051427 12306052703 020123 0ustar00clintonstaff000000 000000 [Changes for 1.00 - 2014-03-06] * Add missing support for c.loc() [Changes for 0.99 - 2014-02-03] * Localise $/ correctly (TOKUHIROM) This change was missing from 0.97 [Changes for 0.98 - 2014-01-22] * Exclude POT files (gerhardj) [Changes for 0.97 - 2014-01-09] * Localise $/ correctly (TOKUHIROM) [Changes for 0.96 - 2013-06-28] * Bumping - bad release [Changes for 0.95 - 2013-06-28] * Handle Haml blocks too (Calum Halcrow) [Changes for 0.94 - 2013-05-07] * Corrected spelling of Text::Haml * xgettext.pl was not being installed [Changes for 0.93 - 2013-03-28] * Moved to Dist::Zilla * Added support for HAML (Calum Halcrow) [Changes for 0.92 - 2012-12-05] * Fixed test for Perl 5.17.6+. (ANDK) [Changes for 0.91 - 2011-08-19] * Fixed test count for newly added tests [Changes for 0.90 - 2011-08-19] * Doc changes [Changes for 0.89 - 2011-08-19] * Added support to the TT2 parser for Mojolicious style tags Thanks to COSIMO for the patch [Changes for 0.88 - 2011-07-30] * Fixed the t/5-extract.t test count [Changes for 0.87 - 2011-07-20] * Locale::Maketext::Extract::Plugin::Mason - Added support for Mason 2 Thanks to ASIMON for the patch. * Locale::Maketext::Extract - Now warns on loading bad plugins if warnings enabled * Locale::Maketext::Extract::Plugin::Base - Corrected the synopsis Thanks to TOKUHIROM for the bug reports [Changes for 0.86 - 2011-02-16] * Bumped version because the META file was showing an old version number. [Changes for 0.85 - 2011-02-11] * Changed Locale::Maketext::Extract::Run to ignore: - .git/ - unix pipes - binary files Thanks to audreyt for the patch https://github.com/audreyt/locale-maketext-lexicon/commit/1e4d112d435daa7b72eb8b49208f3b2e3185bc22 [Changes for 0.84 - 2010-12-24] * Changed the minimum version of Locale::Maketext to 1.17, to avoid error reports from recent Perl versions, which still have an old Locale::Maketext * Locale::Maketext::Extract - added a fix from Ivan Bessarov to avoid uninit warnings when msgids contain trailing spaces [Changes for 0.83 - 2010-12-09] * Locale::Maketext::Lexicon - remove the local $@ when loading PO files - made it difficult to debug errors when loading PO's Thanks to Ton Voon for the patch https://rt.cpan.org/Ticket/Display.html?id=63722 [Changes for 0.82 - 2010-04-12] * Locale::Maketext::Extract::Plugin::Base * Locale::Maketext::Extract::Plugin::TT2 * Locale::Maketext::Extract - fixed some spelling errors - thanks to Ansgar Burchardt for the patch [Changes for 0.81 - 2010-04-09] * Locale::Maketext::Extract::PLugin::FormFu - the plugin now understands YAML of the form: mesage_loc: ['Max files: [_1]', 10] Thanks to Charlie Garrison for the patch [Changes for 0.80 - 2010-04-08] * Locale::Maketext::Lexicon - Added the _preload option, which forces parsing of the lexicon as soon as it is loaded. Improves memory usage and performance in a prefork environment Thanks to Ruslan Zakirov for the patch [Changes for 0.79 - 2010-03-02] * Locale::Maketext::Lexicon::Tie - Removed a deprecated use of "defined %" for Perl 5.11+ [Changes for 0.78 - 2010-02-23] * Locale::Maketext::Lexicon - Removed a deprecated use of "defined %" for Perl 5.11+ [Changes for 0.77 - 2008-12-29] * Locale::Maketext::Extract::Plugin::FormFu - Rewrote the FormFu plugin completely to use the YAML.pm parser. Previously, this plugin was completely broken. - Resolves bugs: - http://rt.cpan.org/Ticket/Display.html?id=42000 # Locale::Maketext::Extract::Plugin::FormFu broken - http://rt.cpan.org/Ticket/Display.html?id=39292 # Parsing formfu config * Locale::Maketext::Extract::Plugin::YAML - Improved the accuracy of the line numbers. - Added documentation and tests for using folded and block scalars. * Locale::Maketext::Extract::Plugin::PPI - Added a PPI based Perl plugin - more accurate than the Perl plugin, but much slower. - Not enabled by default - moved the Perl extraction tests into t/51-perlextract.t - Resolves bug: http://rt.cpan.org/Ticket/Display.html?id=14701 # xgettext doesn't handle interpolating functions Also, corrected the POD to use the correct names for the plugins. [Changes for 0.76 - 2008-12-14] * Locale::Maketext::Extract / Locale::Maketext::Lexicon::Gettext - Roundtripping of fuzzy comments now works. If a translation is marked by the translator as fuzzy, then it should remain so when re-extracted - Added tests for roundtripping of fuzzy, and for format markers * Locale::Maketext::Lexicon - Fixed bug http://rt.cpan.org/Public/Bug/Display.html?id=14999 # relative paths to lang files fail - added tests to prove it * Locale::Maketext::Extract::Plugin::TT2 - changed the line string to contain only the start line, and not the range as this was not consistent with the gettext spec [Changes for 0.75 - 2008-11-24] * Locale::Maketext::Extract / Locale::Maketext::Extract::Run Changed the order of extraction to: - extract all strings - then read, compile and write each PO file Speeds the extraction process up by a factor of the number of languages used. $Ext->read_po now resets the compiled entries, so that a fresh po file can be written. Also tidied up the verbose messages Bumped both to 0.33 * Locale::Maketext::Extract::Run / xgettext.pl Added the -W | --wrap option, which forces the file location comments to be on separate lines, as per POEdit The output order of the PO file has changed to match gettext producers, so the arguments now appear before the file locations. * t/5-extract_strings.tt Fixed a bad SKIP plan [Changes for 0.74 - 2008-11-22] * Locale::Maketext::Extract::Plugin::Perl The Perl plugin now combines concatenated strings, eg loc('string' . ' and this') Contributed by Felix Ostmann * Locale::Maketext::Extract::Run Localised $_ correctly to avoid conflict with external strings Contributed by Sebastian Knapp * Locale::Maketext::Run Fixed bug http://rt.cpan.org/Ticket/Display.html?id=31940 Debian bug http://bugs.debian.org/307777 xgettext.pl -f was not chomping file names correctly Contributed by Niko Tyni [Changes for 0.73 - 2008-10-28] * Locale::Maketext::Extract::Plugin::TextTemplate - renamed MyParser to Locale::Maketext::Extract::Plugin::TextTemplate::Parser to avoid namespace clashes * CPANTS improvements - Updated the Makefile to list all mentioned modules - Added a LICENSE file - added a Test::Pod test [Changes for 0.72 - 2008-10-10] Contributed by: Clinton Gormley (DRTECH) * Locale::Maketext::Extract::Plugin::TT2 - fixed bug where extracted strings still had escaped quotes and backslashes - if args are literal, they're now wrapped in double quotes instead of single quotes - special characters in args are escaped properly [Changes for 0.71 - 2008-10-05] * Bump version number of Locale::Maketext::Extract::Plugin::TextTemplate to 0.30 so PAUSE can index it correctly. [Changes for 0.70 - 2008-10-04] Contributed by: Clinton Gormley (DRTECH) * Refactored Locale::Maketext::Extract - Each format is handled by a different plugin - Each format recognises certain default file types - Custom plugins can be used * Locale::Maketext::Extract::Plugin::TT2 - Uses Template Toolkit as a parser - Handles inline filter, block filters, and function calls to "l" or "loc" Contibuted by: Andy Wardley [ABW] * Locale::Maketext::Extract::Plugin::YAML uses the YAML module as a parser and can recognise the form: key: _"string" * Locale::Maketext::Extract::Run - Added -P|plugins option to specify which parser plugins to use - Added -w|warnings to turn parser warnings on and off - Added -v|verbose to output the files that are being processed, the plugins used to process them, and the extracted strings - Fixed a bug in the File::Find routine to correctly prune .svn directories and their contents * Locale::Maketext::Extract::Plugin::Perl - Added a defined check to avoid a warning. [Changes for 0.68 - 2008-08-18] * Locale::Maketext::Extract: Support for other forms of localization in TT templates and TT HEREDOCS. Contributed by: Felix Antonius Wilhelm Ostmann [Changes for 0.67 - 2008-08-04] * Locale::Maketext::Extract: Support in Extract.pm and Lexicon/Gettext.pm for parsing and keeping user comments in PO files. Contributed by: Cosimo Streppone [Changes for 0.66 - 2008-02-12] * Locale::Maketext::Extract: Support in Extract.pm->extract for HTML::FormFu config files. Contributed by: Andreas Marienborg [Changes for 0.65 - 2007-12-22] * Perl 5.9.5+ is pickier about what "being used only once" means, so we make sure to avoid that warning. Contributed by: Alex Vandiver * Also restore compatibility with Perl 5.005 and earlier by avoiding the "no warnings" pragma. * Tidied up code style, documentation, copyright years, etc. [Changes for 0.64 - 2007-05-28] * Locale::Maketext::Extract: Extraction wasn't able to deal with escaped quotes within single- and double-quoted strings. (Bump version to 0.22.) Contributed by: Matthew O'Connor [Changes for 0.63 - 2007-02-07] * Locale::Maketext::Lexicon used to generated mysteriouse error "next at ..." instead of skipping the locale, when the requested .po file does not exist. Contributed by: Ruslan U. Zakirov [Changes for 0.62 - 2006-06-15] * For the longest time, direct import of Locale::Maketext::Lexicon from within localization classes (such as MyApp::I18N::zh_tw) was untested and broken. It now works the way described in the SYNOPSIS section of the Locale::Maketext::Lexicon documentation. Contributed by: Yann Kerherve [Changes for 0.61 - 2006-04-27] * LICENSING CHANGE: This compilation and all individual files in it are now under the permissive "MIT" license. See the COPYRIGHT section in README for the new terms. * Repair Perl 5.005 compatibility in the build system. Reported By: Rong-En Fan [Changes for 0.60 - 2006-04-13] * Locale::Maketext::Extract: Bump version to 0.20. No functionality changes to Locale::Maketext::Lexicon; all changes in this release are to Locale::Maketext::Extract. * The ->compile call now moves ->entries into ->compiled_entries, instead of mutating them in-place. This allows repeated cycles of ->extract/->compile calls before the final ->write_po. * Consequently, in the ->read_po/->write_po API, the "$verbatim" flag is now ignored. * ->read_po no longer fails on empty PO files. * The return values of ->msgids/->msgstr are now always in gettext style and never in maketext style. * In xgettext.pl, the -u flag (specifies the style of the source programs as gettext instead of the default maketext) now has nothing to do with output escaping. This closes another long-standing bug of "vanishing backslashes" when the same .po file is written once with -u and once without. * The --unescaped flag to "xgettext.pl" is deprecated and renamed to the more appropriate "--use-gettext-style". * Locale::Maketext::Extract::Run now accepts single-letter directory names instead of erroneously stripping them out. [Changes for 0.58 - 2006-04-13] * Locale::Maketext::Extract: Direct calls to ->write_po now escapes the msg strings by default (reverting to <=0.54 behaviour), but calls via xgettext.pl (and ::Extract::Run) now always specify the "verbatim" flag to ->write_po, so users of extraction tools are still free from double escaping. Requested by: Thierry Vignaud * Locale::Maketext::Extract: Allow the "# loc" marker at the end of a statement: say "foo"; # loc previously it only worked on closing brackets and commas. * Locale::Maketext::Lexicon: The "gettext" style no longer parses "%0" as a variable. Also allows spaces between function arguments: %quant(%1, %2) [Changes for 0.57 - 2006-04-11] * Locale::Maketext::Locale: The "_style => 'gettext'" option was broken for function forms such as "%quant(%1)", as well as adjacent variables such as "%1%2%3". [Changes for 0.56 - 2006-04-02] * Locale::Maketext::Lexicon: Specifying the new "_auto => 1" option now turns on _AUTO fallback handling for all language handles. Requested by: Jesse Vincent * Locale::Maketext::Lexicon: Specifying the new "_style => 'gettext'" option makes "%1" and "%quant(%1)" to be used for interpolation, instead of "[_1]" and "[quant,_1]". [Changes for 0.55 - 2006-03-22] * Locale::Maketext::Extract: Fix a long-standing bug that caused double-escaping of backslashes and double quotes in loc strings. Contributed by: Brian Cassidy [Changes for 0.54 - 2006-03-14] * When importing into an already defined lexicon and merging with its entries, we need to clear the Locale::Maketext cache, otherwise _AUTO entries generated by the old lexicon will linger around. Contributed by: Helmut Lichtenberg [Changes for 0.53 - 2005-12-05] * Make xgettext.pl work with poEdit by not trying to read from empty .po files. Patch from Brian Cassidy. [Changes for 0.52 - 2005-12-04] * Christian Hansen pointed out 0.51's fix was bass ackwards. [Changes for 0.51 - 2005-12-03] * Locale::Maketext::Extract::Run's use of File::Find::find with (follow => 1) may break on systems without symbolic links. Reported by Brian Cassidy. [Changes for 0.50 - 2005-11-04] * Per suggestion from Sava Chankov, add the (quite outdated) webl10n articles to docs/ directory. Patches from Mikael Sennerholm: * Added "localize" and "localise" to the list of recognized L10N functions in Locale::Maketext::Extract. * Skip .svn directories in Locale::Maketext::Extract::Run. [Changes for 0.49 - 2005-04-13] * Stephen Quinney notes that we are too eager to die on nonexisting files passed in as part of a lexicon_get_() source. We now silently ignore nonexistant files, only reporting error when it exists but cannot be read or parsed. [Changes for 0.48 - 2005-03-12] Patches from Thierry Vignaud: * In Gettext.pm, do not silently skip last entry of a catalog. * In Extract.pm, do not silently skip first entry of a catalog if there's only one empty line tween header and first real message. [Changes for 0.47 - 2005-02-03] * EXISTS in Locale::Maketext::Lexicon has the potential to trigger deep recursion. Reported by Wei-Hon Chen. [Changes for 0.46 - 2004-12-16] * Patch from Thierry Vignaud: Add a "_allow_empty" option to the Gettext backend, to allow empty strings with * Harmen suggested a doc patch to better document the _AUTO key for allowing empty or missing keys. * Changed all ::L10N to ::I18N in examples, to agree with the de facto community standard. [Changes for 0.45 - 2004-10-26] * Fix decoding problem on Big5 containing "]", as reported by Jiing Deng. * For \*DATA calls, we can get the 'main' package from $0, skip tracing the caller chain. [Changes for 0.44 - 2004-09-25] * Fixed a regression from 0.43 that prevented %*(...) interpolations. * Remove RCS headers from source files.. [Changes for 0.43 - 2004-09-24] * Fix decoding problem on Big5 containing "\". [Changes for 0.42 - 2004-08-25] * Devel::DProf did not like the closure-based delay loading mechanism; rewrite using OO-based promises instead. [Changes for 0.41 - 2004-08-24] * Delayed loading of lexicons now repects the original options. * Delay actualization of lexicon parsing until the first use. (Suggested by Jesse Vincent) [Changes for 0.40 - 2004-08-22] * Moved under SVK management. * The 'locale' encoding now works on Win32, using Win32::Console::OutputCP() to probe the code page. [Changes for 0.38 - 2004-04-26] * The quotemeta() introduced in 0.37 broke Locale::Maketext::Simple. * L::M::Extract now parses the '# loc' and '# loc_pair' markers before end of lines, as used in RT. * New module, L::M::Extract::Run, that encapsulates the xgettext.pl script. [Changes for 0.37 - 2004-04-21] * Thanks Christian Hansen for reminding me of the quotemeta() bug. * Forgot to put quotemeta() around dir patterns; pointed out by Jouke Visser. This caused tests on Win32 to fail. * Respect the LAGUAGES and LC_MESSAGES environment variables. [Changes for 0.36 - 2004-03-17] * "_encoding" now takes a special "locale" value, which will get the encoding from user's locale. * Gettext used to break when the re-encoded lexicon contains Maketext's escape characters like "[" and "~". * Extract.pm should not prepend an empty "" before a single-line "string\n". Such treatments are meant for multiline strings. * proper escaping of \ and " in _format. [Changes for 0.35 - 2004-02-19] * We no longer depend on Regexp::Common and Pod::Usage. * Extract strings inside functions that has spaces inside the parens, like 'loc( "test" )', as suggested by Helmut Lichtenberg. [Changes for 0.34 - 2003-12-31] * Update copyright years to 2004. * Fix Msgcat so it also handle CRLF gracefully. * .po files with DOSish CRLF line-ending was not parsed correctly. [Changes for 0.33 - 2003-12-08] * Multiline strings were produced with an extra "\n" by xgettext.pl. * "xgettext.pl -u" was broken. * Various documentation and error message fixes. [Changes for 0.32 - 2003-10-14] * Excise $& from ::Extract, ::Msgcat and ::Gettext. * Micro-optimize (encode|decode)_utf8 in the inner loop of ::Gettext instead of (encode|decode)('utf8', ...). [Changes for 0.31 - 2003-10-13] * 0.30 still broken on Robert Spiers's darwin box, so rewrote them to totally avoid capturing parenthesis. * Also modify Extract.pm to be not reentrant. [Changes for 0.30 - 2003-10-13] * '*' in sources will now get properlly expanded by globbing. * The reentrant-regex transformation used in ::Gettext was breaking 5.8.0 in subtle ways. Reimplemented to use a two-pass approach. [Changes for 0.29 - 2003-10-09] * Update readme and pods to mention ::Extract. * Add test for extraction. * Refactor xgettext.pl out into Locale::Maketext::Extract. * Move bin/ into script/. [Changes for 0.28 - 2003-08-28] * Gettext was chomping everything. Fixed. * Support for Kwiki-style generic loc string: {{...}} [Changes for 0.27 - 2003-07-07] * Change tests to use utf8, not big5, for perl 5.6.1 people with broken Locale::Maketext (1.06). * Supress uninitialized warnings. * Jonas Lincoln reported that empty globs was causing problems. * Strip the extra parens off tt2 templates. * Be very extra magical and assume that main:: comes from the caller if it is not yet opened. * Chia-Liang Kao pointed out that getting sources from glob was not working. * "xgettext.pl -g" was documented but never enabled. * Fixed xgettext.pl's multiline handling. * TT2 regex was wrong; thanks Chia-Liang Kao for pointing out. [Changes for 0.26 - 2003-05-03] * Incoporated a modified version of Matthieu Arnold's patch that enables Encode-specific testing for Perl 5.6.1 with Encode::compat. [Changes for 0.25 - 2003-04-30] * Change t/TestPkg/L10N.pm to t/T_L10N.pm in accord with imacat's arrangement. * Fixes cases where there are multiple '*'s in the glob entry. [Changes for 0.22 - 2003-04-28] * Document the choice of using the final '*' for glob patterns that has multiple '*'s. * Add extra debug info. * prefer the last * for globbing languages. [Changes for 0.21 - 2003-04-27] * Remove unneccessary MO files. * Updates copyrights to 2003. * Mathieu Arnold pointed out that multiline handling was incorrect. * Implemented correct parsing of multiple "#, flag1, flag2". * "#, fuzzy" entries are now ignored, unless _use_fuzzy is set to true. * Documentation fix: removed the ambiguous [ ... ] by imacat's request. * Filehandle sources are now seek()ed back to the original position after reading; this allows using the same handle for two language subclasses. [Changes for 0.20 - 2003-04-26] * Add a note that we now turns 'zh-tw' into 'zh_tw' during import. this fixed imacat's major gripe with previous versions of L::M::L. * Nixed the TODO test since it's not really on my todo. * Add copyright notice around parse_mo() by imacat's request. * Test suite from imacat's Locale::Maketext::Gettext. * Documenting the new _encoding, _decode and wildcard support. * Add IMACAT to authors and acknowledgement list. * New _decode and _encoding flag to control auto-recoding. * Globbing support for import lists. [Changes for 0.16 - 2003-02-22] * Gaal Yahas's patch to recognize __ in addition of _. * Wei-Hon Chen pointed out pod errors. [Changes for 0.15 - 2002-11-29] * Corrected %quant(,%1) -- should be %quant(%1). * POD tweaks. * Random fixes from Alain Barbet. * Merging from old lexicons now work properly with and without -u. [Changes for 0.14 - 2002-11-13] * Escapes are now applicable even with -u. [Changes for 0.13 - 2002-11-13] * Alain's parser patch. This makes multi-line handling a breeze. [Changes for 0.12 - 2002-11-07] * Patch from Alain Barbett: Fix multiline gettext strings. * Document "xgettext.pl -u" before I forget about it. [Changes for 0.11 - 2002-10-27] * First sane CPAN release version. Locale-Maketext-Lexicon-1.00/dist.ini000644 000765 000024 00000002044 12306052703 020263 0ustar00clintonstaff000000 000000 name = Locale-Maketext-Lexicon author = Clinton Gormley author = Audrey Tang license = MIT copyright_holder = Audrey Tang version = 1.00 [GatherDir] exclude_filename = README.pod exclude_match = ^cover.* exclude_match = ^nytprof.* exclude_match = ^bench.* [ExecDir] dir = script [PruneCruft] [PkgVersion] [MetaJSON] [ExtraTests] [PodSyntaxTests] [EOLTests] [Manifest] [MakeMaker] [Prereqs / BuildRequires] [Prereqs] perl = 5.005 Locale::Maketext = 1.17 [Prereqs / Recommends] HTML::Parser = 3.56 Lingua::EN::Sentence = 0.25 PPI = 1.203 Template = 2.20 Template::Constants = 2.75 YAML = 0.66 YAML::Loader = 0.66 Text::Haml = 0 [@Git] tag_format = version_%v [GitHub::Meta] fork = 0 repo = locale-maketext-lexicon [PodWeaver] [MetaYAML] [License] [ReadmeFromPod] [CheckChangeLog] [ConfirmRelease] [UploadToCPAN] Locale-Maketext-Lexicon-1.00/docs/000755 000765 000024 00000000000 12306052703 017547 5ustar00clintonstaff000000 000000 Locale-Maketext-Lexicon-1.00/lib/000755 000765 000024 00000000000 12306052703 017365 5ustar00clintonstaff000000 000000 Locale-Maketext-Lexicon-1.00/LICENSE000644 000765 000024 00000002206 12306052703 017624 0ustar00clintonstaff000000 000000 This software is Copyright (c) 2014 by Audrey Tang. This is free software, licensed under: The MIT (X11) License The MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Locale-Maketext-Lexicon-1.00/Makefile.PL000644 000765 000024 00000002150 12306052703 020567 0ustar00clintonstaff000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.013. use strict; use warnings; use 5.005; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "Use other catalog formats in Maketext", "AUTHOR" => "Clinton Gormley , Audrey Tang ", "BUILD_REQUIRES" => {}, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" }, "DISTNAME" => "Locale-Maketext-Lexicon", "EXE_FILES" => [ "script/xgettext.pl" ], "LICENSE" => "mit", "NAME" => "Locale::Maketext::Lexicon", "PREREQ_PM" => { "Locale::Maketext" => "1.17" }, "TEST_REQUIRES" => {}, "VERSION" => "1.00", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Locale::Maketext" => "1.17" ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); Locale-Maketext-Lexicon-1.00/MANIFEST000644 000765 000024 00000003206 12306052703 017751 0ustar00clintonstaff000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.013. AUTHORS Changes LICENSE MANIFEST MANIFEST.SKIP META.json META.yml Makefile.PL README dist.ini docs/webl10n.html docs/webl10n.zh-tw.html lib/Locale/Maketext/Extract.pm lib/Locale/Maketext/Extract/Plugin/Base.pm lib/Locale/Maketext/Extract/Plugin/FormFu.pm lib/Locale/Maketext/Extract/Plugin/Generic.pm lib/Locale/Maketext/Extract/Plugin/Haml.pm lib/Locale/Maketext/Extract/Plugin/Mason.pm lib/Locale/Maketext/Extract/Plugin/PPI.pm lib/Locale/Maketext/Extract/Plugin/Perl.pm lib/Locale/Maketext/Extract/Plugin/TT2.pm lib/Locale/Maketext/Extract/Plugin/TextTemplate.pm lib/Locale/Maketext/Extract/Plugin/YAML.pm lib/Locale/Maketext/Extract/Run.pm lib/Locale/Maketext/Lexicon.pm lib/Locale/Maketext/Lexicon/Auto.pm lib/Locale/Maketext/Lexicon/Gettext.pm lib/Locale/Maketext/Lexicon/Msgcat.pm lib/Locale/Maketext/Lexicon/Tie.pm script/xgettext.pl t/1-basic.t t/2-lmg.t t/3-big-endian.t t/4-encodings.t t/5-extract.t t/51-perlextract.t t/52-extractpluginselection.t t/55-runextract.t t/6-gettext.t t/61-badcharset.t t/7-roundtrip.t t/8-plugin-args.t t/9-bug-import-for-subclasses.t t/91-pod_test.t t/T_L10N.pm t/badcharset.po t/comments.po t/gencat.m t/lib/Myi18n.pm t/lib/Myi18n/en.po t/locale/en/LC_MESSAGES/test.mo t/locale/en/LC_MESSAGES/test_be.mo t/locale/en/LC_MESSAGES/test_utf8.mo t/locale/zh_CN/LC_MESSAGES/test.mo t/locale/zh_CN/LC_MESSAGES/test_be.mo t/locale/zh_CN/LC_MESSAGES/test_utf8.mo t/locale/zh_TW/LC_MESSAGES/test.mo t/locale/zh_TW/LC_MESSAGES/test_be.mo t/locale/zh_TW/LC_MESSAGES/test_utf8.mo t/messages.mo t/messages.po t/preload.t t/release-eol.t t/release-pod-syntax.t Locale-Maketext-Lexicon-1.00/MANIFEST.SKIP000644 000765 000024 00000000155 12306052703 020516 0ustar00clintonstaff000000 000000 ^.svn$ .svn/ .bak$ .rej$ ~$ .old$ blib pm_to_blib ^Makefile$ .project ^.git/ .gitignore .tar.gz$ README.pod Locale-Maketext-Lexicon-1.00/META.json000644 000765 000024 00000003141 12306052703 020237 0ustar00clintonstaff000000 000000 { "abstract" : "Use other catalog formats in Maketext", "author" : [ "Clinton Gormley ", "Audrey Tang " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 5.013, CPAN::Meta::Converter version 2.133380", "license" : [ "mit" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Locale-Maketext-Lexicon", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.30" } }, "develop" : { "requires" : { "Test::Pod" : "1.41" } }, "runtime" : { "recommends" : { "HTML::Parser" : "3.56", "Lingua::EN::Sentence" : "0.25", "PPI" : "1.203", "Template" : "2.20", "Template::Constants" : "2.75", "Text::Haml" : "0", "YAML" : "0.66", "YAML::Loader" : "0.66" }, "requires" : { "Locale::Maketext" : "1.17", "perl" : "5.005" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/clintongormley/locale-maketext-lexicon/issues" }, "homepage" : "http://search.cpan.org/dist/Locale-Maketext-Lexicon", "repository" : { "type" : "git", "url" : "git://github.com/clintongormley/locale-maketext-lexicon.git", "web" : "https://github.com/clintongormley/locale-maketext-lexicon" } }, "version" : "1.00" } Locale-Maketext-Lexicon-1.00/META.yml000644 000765 000024 00000001635 12306052703 020075 0ustar00clintonstaff000000 000000 --- abstract: 'Use other catalog formats in Maketext' author: - 'Clinton Gormley ' - 'Audrey Tang ' build_requires: {} configure_requires: ExtUtils::MakeMaker: '6.30' dynamic_config: 0 generated_by: 'Dist::Zilla version 5.013, CPAN::Meta::Converter version 2.133380' license: mit meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Locale-Maketext-Lexicon recommends: HTML::Parser: '3.56' Lingua::EN::Sentence: '0.25' PPI: '1.203' Template: '2.20' Template::Constants: '2.75' Text::Haml: '0' YAML: '0.66' YAML::Loader: '0.66' requires: Locale::Maketext: '1.17' perl: '5.005' resources: bugtracker: https://github.com/clintongormley/locale-maketext-lexicon/issues homepage: http://search.cpan.org/dist/Locale-Maketext-Lexicon repository: git://github.com/clintongormley/locale-maketext-lexicon.git version: '1.00' Locale-Maketext-Lexicon-1.00/README000644 000765 000024 00000020750 12306052703 017503 0ustar00clintonstaff000000 000000 NAME Locale::Maketext::Lexicon - Use other catalog formats in Maketext VERSION version 1.00 SYNOPSIS As part of a localization class, automatically glob for available lexicons: package Hello::I18N; use base 'Locale::Maketext'; use Locale::Maketext::Lexicon { '*' => [Gettext => '/usr/local/share/locale/*/LC_MESSAGES/hello.mo'], ### Uncomment to fallback when a key is missing from lexicons # _auto => 1, ### Uncomment to decode lexicon entries into Unicode strings # _decode => 1, ### Uncomment to load and parse everything right away # _preload => 1, ### Uncomment to use %1 / %quant(%1) instead of [_1] / [quant, _1] # _style => 'gettext', }; Explicitly specify languages, during compile- or run-time: package Hello::I18N; use base 'Locale::Maketext'; use Locale::Maketext::Lexicon { de => [Gettext => 'hello_de.po'], fr => [ Gettext => 'hello_fr.po', Gettext => 'local/hello/fr.po', ], }; # ... incrementally add new lexicons Locale::Maketext::Lexicon->import({ de => [Gettext => 'local/hello/de.po'], }) Alternatively, as part of a localization subclass: package Hello::I18N::de; use base 'Hello::I18N'; use Locale::Maketext::Lexicon (Gettext => \*DATA); __DATA__ # Some sample data msgid "" msgstr "" "Project-Id-Version: Hello 1.3.22.1\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=iso8859-1\n" "Content-Transfer-Encoding: 8bit\n" #: Hello.pm:10 msgid "Hello, World!" msgstr "Hallo, Welt!" #: Hello.pm:11 msgid "You have %quant(%1,piece) of mail." msgstr "Sie haben %quant(%1,Poststueck,Poststuecken)." DESCRIPTION This module provides lexicon-handling modules to read from other localization formats, such as *Gettext*, *Msgcat*, and so on. If you are unfamiliar with the concept of lexicon modules, please consult Locale::Maketext and the "webl10n" HTML files in the "docs/" directory of this module. A command-line utility xgettext.pl is also installed with this module, for extracting translatable strings from source files. The "import" function The "import()" function accepts two forms of arguments: (*format* => *source* ... ) This form takes any number of argument pairs (usually one); *source* may be a file name, a filehandle, or an array reference. For each such pair, it pass the contents specified by the second argument to Locale::Maketext::Lexicon::*format*->parse as a plain list, and export its return value as the %Lexicon hash in the calling package. In the case that there are multiple such pairs, the lexicon defined by latter ones overrides earlier ones. { *language* => [ *format*, *source* ... ] ... } This form accepts a hash reference. It will export a %Lexicon into the subclasses specified by each *language*, using the process described above. It is designed to alleviate the need to set up a separate subclass for each localized language, and just use the catalog files. This module will convert the *language* arguments into lowercase, and replace all "-" with "_", so "zh_TW" and "zh-tw" will both map to the "zh_tw" subclass. If *language* begins with "_", it is taken as an option that controls how lexicons are parsed. See "Options" for a list of available options. The "*" is a special *language*; it must be used in conjunction with a filename that also contains "*"; all matched files with a valid language code in the place of "*" will be automatically prepared as a lexicon subclass. If there is multiple "*" in the filename, the last one is used as the language name. Options "_auto" If set to a true value, missing lookups on lexicons are handled silently, as if an "Auto" lexicon has been appended on all language lexicons. "_decode" If set to a true value, source entries will be converted into utf8-strings (available in Perl 5.6.1 or later). This feature needs the Encode or Encode::compat module. Currently, only the "Gettext" backend supports this option. "_encoding" This option only has effect when "_decode" is set to true. It specifies an encoding to store lexicon entries, instead of utf8-strings. If "_encoding" is set to "locale", the encoding from the current locale setting is used. "_preload" By default parsing is delayed until first use of the lexicon, set this option to true value to parse it asap. Increment adding lexicons forces parsing. Subclassing format handlers If you wish to override how sources specified in different data types are handled, please use a subclass that overrides "lexicon_get_*TYPE*". XXX: not documented well enough yet. Patches welcome. VERSION This document describes version 0.91 of Locale::Maketext::Lexicon. NOTES When you attempt to localize an entry missing in the lexicon, Maketext will throw an exception by default. To inhibit this behaviour, override the "_AUTO" key in your language subclasses, for example: $Hello::I18N::en::Lexicon{_AUTO} = 1; # autocreate missing keys If you want to implement a new "Lexicon::*" backend module, please note that "parse()" takes an array containing the source strings from the specified filehandle or filename, which are *not* "chomp"ed. Although if the source is an array reference, its elements will probably not contain any newline characters anyway. The "parse()" function should return a hash reference, which will be assigned to the *typeglob* (*Lexicon) of the language module. All it amounts to is that if the returned reference points to a tied hash, the %Lexicon will be aliased to the same tied hash if it was not initialized previously. ACKNOWLEDGMENTS Thanks to Jesse Vincent for suggesting this module to be written. Thanks also to Sean M. Burke for coming up with Locale::Maketext in the first place, and encouraging me to experiment with alternative Lexicon syntaxes. Thanks also to Yi Ma Mao for providing the MO file parsing subroutine, as well as inspiring me to implement file globbing and transcoding support. See the AUTHORS file in the distribution for a list of people who have sent helpful patches, ideas or comments. SEE ALSO xgettext.pl for extracting translatable strings from common template systems and perl source files. Locale::Maketext, Locale::Maketext::Lexicon::Auto, Locale::Maketext::Lexicon::Gettext, Locale::Maketext::Lexicon::Msgcat, Locale::Maketext::Lexicon::Tie AUTHORS Audrey Tang COPYRIGHT Copyright 2002-2013 by Audrey Tang . This software is released under the MIT license cited below. The "MIT" License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. AUTHORS * Clinton Gormley * Audrey Tang COPYRIGHT AND LICENSE This software is Copyright (c) 2014 by Audrey Tang. This is free software, licensed under: The MIT (X11) License Locale-Maketext-Lexicon-1.00/script/000755 000765 000024 00000000000 12306052703 020123 5ustar00clintonstaff000000 000000 Locale-Maketext-Lexicon-1.00/t/000755 000765 000024 00000000000 12306052703 017062 5ustar00clintonstaff000000 000000 Locale-Maketext-Lexicon-1.00/t/1-basic.t000755 000765 000024 00000012135 12306052703 020473 0ustar00clintonstaff000000 000000 #!/usr/bin/perl -w use strict; use Test::More tests => 33; package Hello::I18N; use Test::More; use Tie::Hash; my $warned; $SIG{__WARN__} = sub { $warned++ }; use_ok( base => 'Locale::Maketext' ); use_ok( 'Locale::Maketext::Lexicon' => { en => ['Auto'], fr => [ 'Tie' => ['Tie::StdHash'] ], de => [ 'Gettext' => \*::DATA ], zh_tw => [ 'Gettext' => 't/messages.mo' ], zh_cn => [ 'Msgcat' => 't/gencat.m' ], zh_hk => [ 'Msgcat' => 't/gencat.m', 'Gettext' => 't/messages.po', ], } ); ok( !$warned, 'no warnings on blank lines' ); Locale::Maketext::Lexicon->import( { de_de => [ 'Gettext' => \*::DATA ], _use_fuzzy => 1, } ); package main; ################################################################ ok( my $lh = Hello::I18N->get_handle('en-us'), 'Auto - get_handle' ); is( $lh->maketext('Heute die Welt'), 'Heute die Welt', 'Auto - autofilling' ); ################################################################ ok( $lh = Hello::I18N->get_handle('de'), 'Gettext - get_handle' ); is( $lh->maketext('Hello, World!'), 'Hallo, Welt!', 'Gettext - simple case' ); is( $lh->maketext( 'You have [*,_1,piece] of mail.', 10 ), 'Sie haben 10 Poststuecken.', 'Gettext - complex case' ); is( $lh->maketext( '[_1] [_2] [_*]', 1, 2, 3 ), '123 2 1', 'Gettext - asterisk interpolation' ); is( $lh->maketext( '[_1][_2][_*]', 1, 2, 3 ), '12321', 'Gettext - concatenated variables' ); is( $lh->maketext( '[_1]()', 10 ), '10()', 'Gettext - correct parens' ); is( $lh->maketext('__Content-Type'), 'text/plain; charset=ISO-8859-1', 'Gettext - metadata' ); is( $lh->maketext( '[_1]()', 10 ), '10()', 'Gettext - correct parens' ); is( $lh->maketext("\n\nKnowledge\nAnd\nNature\n\n"), "\n\n" . "Ich wuenschte recht gelehrt zu werden,\n" . "Und moechte gern, was auf der Erden\n" . "Und in dem Himmel ist, erfassen,\n" . "Die Wissenschaft und die Natur.\n\n", 'Gettext - multiline' ); is( eval { $lh->maketext("The Hitchhiker's Guide to the Galaxy") }, undef, 'Gettext - fuzzy entries are ignored' ); ok( $lh = Hello::I18N->get_handle('de_de'), 'Gettext - get_handle on DATA again' ); is( eval { $lh->maketext("The Hitchhiker's Guide to the Galaxy") }, 'Der Fuehrer des Trampers zur Galaxie', 'Gettext - fuzzy entries are recognized with _use_fuzzy' ); ################################################################ SKIP: { skip( "no msgunfmt available", 2 ) unless `msgunfmt -V` and !$?; ok( $lh = Hello::I18N->get_handle('zh_tw'), 'Gettext - get_handle' ); is( $lh->maketext('This is a test'), '這是測試', 'Gettext - MO File' ); } ################################################################ ok( $lh = Hello::I18N->get_handle('fr'), 'Tie - get_handle' ); $Hello::I18N::fr::Lexicon{"Good morning"} = 'Bon jour'; $Hello::I18N::fr::Lexicon{"Good morning, [_1]"} = 'Bon jour, [_1]'; is( $lh->maketext('Good morning'), 'Bon jour', 'Tie - simple case' ); is( $lh->maketext( 'Good morning, [_1]', 'Sean' ), 'Bon jour, Sean', 'Tie - complex case' ); ################################################################ ok( $lh = Hello::I18N->get_handle('zh_cn'), 'Msgcat - get_handle' ); is( $lh->maketext( 1, 1 ), 'First string', 'Msgcat - simple case' ); is( $lh->maketext( 1, 2 ), 'Second string', 'Msgcat - continued string' ); is( $lh->maketext( 1, 3 ), 'Third string', 'Msgcat - quote character' ); is( $lh->maketext( 1, 4 ), 'Fourth string', 'Msgcat - quote character + continued string' ); ################################################################ ok( $lh = Hello::I18N->get_handle('zh_hk'), 'Multiple lexicons - get_handle' ); is( $lh->maketext( 1, 1 ), 'First string', 'Multiple lexicons - first' ); is( $lh->maketext('This is a test'), '這是測試', 'Multiple lexicons - second' ); ################################################################ use lib 't/lib/'; use_ok('Myi18n'); ok( $lh = Myi18n->get_handle('en'), 'Loaded relative langfile' ); is( $lh->maketext('Test relative langfiles'), 'Relative works!', 'Relative langfile trans' ); __DATA__ msgid "" msgstr "" "Project-Id-Version: Test App 0.01\n" "POT-Creation-Date: 2002-05-02 11:36+0800\n" "PO-Revision-Date: 2002-05-13 02:00+0800\n" "Last-Translator: \n" "Language-Team: German \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=ISO-8859-1\n" "Content-Transfer-Encoding: 8bit\n" #: Hello.pm:10 msgid "Hello, World!" msgstr "Hallo, Welt!" #: Hello.pm:11 msgid "You have %*(%1,piece) of mail." msgstr "Sie haben %*(%1,Poststueck,Poststuecken)." #: Hello.pm:12 msgid "%1()" msgstr "%1()" #: Hello.pm:13 msgid "%1 %2 %*" msgstr "%* %2 %1" #: Hello.pm:14 msgid "%1%2%*" msgstr "%*%2%1" #: Hello.pm:15 msgid "" "\n" "\n" "Knowledge\n" "And\n" "Nature\n" "\n" msgstr "" "\n" "\n" "Ich wuenschte recht gelehrt zu werden,\n" "Und moechte gern, was auf der Erden\n" "Und in dem Himmel ist, erfassen,\n" "Die Wissenschaft und die Natur.\n" "\n" #: Hello.pm:16 #, big, furry, fuzzy msgid "The Hitchhiker's Guide to the Galaxy" msgstr "Der Fuehrer des Trampers zur Galaxie" Locale-Maketext-Lexicon-1.00/t/2-lmg.t000755 000765 000024 00000003621 12306052703 020172 0ustar00clintonstaff000000 000000 #! /usr/bin/perl -w # Basic test suite # Copyright (c) 2003 imacat. All rights reserved. This program is free # software; you can redistribute it and/or modify it under the same terms # as Perl itself. use strict; use Test; BEGIN { plan(tests => 0), exit unless eval { require Encode::compat; 1 } or eval { require Encode; 1 } } BEGIN { plan tests => 14 } use FindBin; use File::Spec::Functions qw(catdir catfile); use lib $FindBin::Bin; use vars qw($LOCALEDIR); $LOCALEDIR = catdir($FindBin::Bin, "locale"); # Basic checks use Encode qw(decode); # bindtextdomain eval { require T_L10N; $_ = T_L10N->get_handle("en"); $_->bindtextdomain("test", $LOCALEDIR); $_ = $_->bindtextdomain("test"); }; # 1 ok($@, ""); # 2 ok($_, "$LOCALEDIR"); # textdomain eval { require T_L10N; $_ = T_L10N->get_handle("en"); $_->bindtextdomain("test", $LOCALEDIR); $_->textdomain("test"); $_ = $_->textdomain; }; # 3 ok($@, ""); # 4 ok($_, "test"); # readmo eval { $_ = catfile($LOCALEDIR, "zh_TW", "LC_MESSAGES", "test.mo"); ($_, %_) = T_L10N->readmo($_); }; # 5 ok($@, ""); # 6 ok($_, "Big5"); # 7 ok(scalar(keys %_), 2); # 8 ok($_{"Hello, world!"}, decode("Big5", "janC")); # English eval { require T_L10N; $_ = T_L10N->get_handle("en"); $_->bindtextdomain("test", $LOCALEDIR); $_->textdomain("test"); $_ = $_->maketext("Hello, world!"); }; # 9 ok($@, ""); # 10 ok($_, "Hiya :)"); # Traditional Chinese eval { require T_L10N; $_ = T_L10N->get_handle("zh-tw"); $_->bindtextdomain("test", $LOCALEDIR); $_->textdomain("test"); $_ = $_->maketext("Hello, world!"); }; # 11 ok($@, ""); # 12 ok($_, "janC"); # Simplified Chinese eval { require T_L10N; $_ = T_L10N->get_handle("zh-cn"); $_->bindtextdomain("test", $LOCALEDIR); $_->textdomain("test"); $_ = $_->maketext("Hello, world!"); }; # 13 ok($@, ""); # 14 ok($_, "Һá"); Locale-Maketext-Lexicon-1.00/t/3-big-endian.t000755 000765 000024 00000002413 12306052703 021407 0ustar00clintonstaff000000 000000 #! /usr/bin/perl -w # Test the big endian MO files # Copyright (c) 2003 imacat. All rights reserved. This program is free # software; you can redistribute it and/or modify it under the same terms # as Perl itself. use strict; use Test; BEGIN { plan(tests => 0), exit unless eval { require Encode::compat; 1 } or eval { require Encode; 1 } } BEGIN { plan tests => 6 } use FindBin; use File::Spec::Functions qw(catdir); use lib $FindBin::Bin; use vars qw($LOCALEDIR); $LOCALEDIR = catdir($FindBin::Bin, "locale"); # Check reading big-endian PO files # English eval { require T_L10N; $_ = T_L10N->get_handle("en"); $_->bindtextdomain("test_be", $LOCALEDIR); $_->textdomain("test_be"); $_ = $_->maketext("Hello, world!"); }; # 1 ok($@, ""); # 2 ok($_, "Hiya :)"); # Traditional Chinese eval { require T_L10N; $_ = T_L10N->get_handle("zh-tw"); $_->bindtextdomain("test_be", $LOCALEDIR); $_->textdomain("test_be"); $_ = $_->maketext("Hello, world!"); }; # 3 ok($@, ""); # 4 ok($_, "janC"); # Simplified Chinese eval { require T_L10N; $_ = T_L10N->get_handle("zh-cn"); $_->bindtextdomain("test_be", $LOCALEDIR); $_->textdomain("test_be"); $_ = $_->maketext("Hello, world!"); }; # 5 ok($@, ""); # 6 ok($_, "Һá"); Locale-Maketext-Lexicon-1.00/t/4-encodings.t000755 000765 000024 00000006642 12306052703 021374 0ustar00clintonstaff000000 000000 #! /usr/bin/perl -w # Test suite for the different encodings # Copyright (c) 2003 imacat. All rights reserved. This program is free # software; you can redistribute it and/or modify it under the same terms # as Perl itself. use strict; use Test; BEGIN { %ENV = (); plan(tests => 0), exit unless eval { require Encode::compat; 1 } or eval { require Encode; 1 } } BEGIN { plan tests => 22 } use FindBin; use File::Spec::Functions qw(catdir); use lib $FindBin::Bin; use vars qw($LOCALEDIR); $LOCALEDIR = catdir($FindBin::Bin, "locale"); # Different encodings # English # Find the default encoding eval { require T_L10N; $_ = T_L10N->get_handle("en"); $_->bindtextdomain("test", $LOCALEDIR); $_->textdomain("test"); $_ = $_->encoding; }; # 1 ok($@, ""); # 2 ok($_, "US-ASCII"); # Traditional Chinese # Find the default encoding eval { require T_L10N; $_ = T_L10N->get_handle("zh-tw"); $_->bindtextdomain("test", $LOCALEDIR); $_->textdomain("test"); $_ = $_->encoding; }; # 3 ok($@, ""); # 4 ok($_, "Big5"); # Turn to Big5 eval { require T_L10N; $_ = T_L10N->get_handle("zh-tw"); $_->bindtextdomain("test", $LOCALEDIR); $_->textdomain("test"); $_->encoding("Big5"); $_ = $_->maketext("Hello, world!"); }; # 5 ok($@, ""); # 6 ok($_, "janC"); # Turn to UTF-8 eval { require T_L10N; $_ = T_L10N->get_handle("zh-tw"); $_->bindtextdomain("test", $LOCALEDIR); $_->textdomain("test"); $_->encoding("UTF-8"); $_ = $_->maketext("Hello, world!"); }; # 7 ok($@, ""); # 8 ok($_, "大家好。"); # Turn to UTF-16LE eval { require T_L10N; $_ = T_L10N->get_handle("zh-tw"); $_->bindtextdomain("test", $LOCALEDIR); $_->textdomain("test"); $_->encoding("UTF-16LE"); $_ = $_->maketext("Hello, world!"); }; # 9 ok($@, ""); # 10 ok($_, "'Y[}Y0"); # Find the default encoding, in UTF-8 eval { require T_L10N; $_ = T_L10N->get_handle("zh-tw"); $_->bindtextdomain("test_utf8", $LOCALEDIR); $_->textdomain("test_utf8"); $_ = $_->encoding; }; # 11 ok($@, ""); # 12 ok($_, "UTF-8"); # Turn to UTF-8 eval { require T_L10N; $_ = T_L10N->get_handle("zh-tw"); $_->bindtextdomain("test_utf8", $LOCALEDIR); $_->textdomain("test_utf8"); $_->encoding("UTF-8"); $_ = $_->maketext("Hello, world!"); }; # 13 ok($@, ""); # 14 ok($_, "大家好。"); # Turn to Big5 eval { require T_L10N; $_ = T_L10N->get_handle("zh-tw"); $_->bindtextdomain("test_utf8", $LOCALEDIR); $_->textdomain("test_utf8"); $_->encoding("Big5"); $_ = $_->maketext("Hello, world!"); }; # 15 ok($@, ""); # 16 ok($_, "janC"); # Turn to UTF-16LE eval { require T_L10N; $_ = T_L10N->get_handle("zh-tw"); $_->bindtextdomain("test_utf8", $LOCALEDIR); $_->textdomain("test_utf8"); $_->encoding("UTF-16LE"); $_ = $_->maketext("Hello, world!"); }; # 17 ok($@, ""); # 18 ok($_, "'Y[}Y0"); # Find the default encoding # Simplified Chinese eval { require T_L10N; $_ = T_L10N->get_handle("zh-cn"); $_->bindtextdomain("test_utf8", $LOCALEDIR); $_->textdomain("test_utf8"); $_ = $_->encoding; }; # 19 ok($@, ""); # 20 ok($_, "UTF-8"); # Turn to GB2312 eval { require T_L10N; $_ = T_L10N->get_handle("zh-cn"); $_->bindtextdomain("test_utf8", $LOCALEDIR); $_->textdomain("test_utf8"); $_->encoding("GB2312"); $_ = $_->maketext("Hello, world!"); }; # 21 ok($@, ""); # 22 ok($_, "Һá"); Locale-Maketext-Lexicon-1.00/t/5-extract.t000644 000765 000024 00000055003 12306052703 021066 0ustar00clintonstaff000000 000000 #! /usr/bin/perl -w use lib '../lib'; use strict; use Test::More tests => 86; use_ok('Locale::Maketext::Extract'); my $Ext = Locale::Maketext::Extract->new(); isa_ok( $Ext => 'Locale::Maketext::Extract' ); #### BEGIN WRAPPING TESTS ############ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "wrap off" ); _('string'); _('string'); __EXAMPLE__ #: :1 :2 msgid "string" msgstr "" __EXPECTED__ $Ext->{wrap} = 1; write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "wrap on" ); _('string'); _('string'); __EXAMPLE__ #: :1 #: :2 msgid "string" msgstr "" __EXPECTED__ #### END WRAPPING TESTS ############ $Ext->{wrap} = 0; #### BEGIN HTML::Mason (aka Mason 1) TESTS ############ SKIP: { skip( 'HTML::Mason unavailable', 6 ) unless eval { require HTML::Mason }; $Ext = Locale::Maketext::Extract->new( plugins => { mason => '*' } ); write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "HTML::Mason simple" ); <&|/l&>string1 <&|/loc&>string2 __EXAMPLE__ #: :1 msgid "string1" msgstr "" #: :2 msgid "string2" msgstr "" __EXPECTED__ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "HTML::Mason simple with spaces" ); <&| /l&>string1 <&|/l &>string2 <&| /l &>string3 <&| /loc&>string4 <&|/loc &>string5 <&| /loc &>string6 __EXAMPLE__ #: :1 msgid "string1" msgstr "" #: :2 msgid "string2" msgstr "" #: :3 msgid "string3" msgstr "" #: :4 msgid "string4" msgstr "" #: :5 msgid "string5" msgstr "" #: :6 msgid "string6" msgstr "" __EXPECTED__ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "HTML::Mason one argument" ); <&|/l,arg1=>value1&>string1 <&|/loc,arg1=>value1&>string2 __EXAMPLE__ #. (arg1=>value1) #: :1 msgid "string1" msgstr "" #. (arg1=>value1) #: :2 msgid "string2" msgstr "" __EXPECTED__ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "HTML::Mason one argument with spaces" ); <&|/l, arg1=>value1&>string1 <&|/loc, arg1=>value1&>string2 <&|/l ,arg1=>value1&>string3 <&|/loc ,arg1=>value1&>string4 <&|/l , arg1=>value1&>string5 <&|/loc , arg1=>value1&>string6 <&| /l , arg1=>value1 &>string7 <&| /loc , arg1=>value1 &>string8 __EXAMPLE__ #. (arg1=>value1) #: :1 msgid "string1" msgstr "" #. (arg1=>value1) #: :2 msgid "string2" msgstr "" #. (arg1=>value1) #: :3 msgid "string3" msgstr "" #. (arg1=>value1) #: :4 msgid "string4" msgstr "" #. (arg1=>value1) #: :5 msgid "string5" msgstr "" #. (arg1=>value1) #: :6 msgid "string6" msgstr "" #. (arg1=>value1) #: :7 msgid "string7" msgstr "" #. (arg1=>value1) #: :8 msgid "string8" msgstr "" __EXPECTED__ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "HTML::Mason two arguments" ); <&|/l,arg1=>value1,arg2=>value2&>string1 <&|/loc,arg1=>value1,arg2=>value2&>string2 __EXAMPLE__ #. (arg1=>value1,arg2=>value2) #: :1 msgid "string1" msgstr "" #. (arg1=>value1,arg2=>value2) #: :2 msgid "string2" msgstr "" __EXPECTED__ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "HTML::Mason two arguments with spaces" ); <&|/l ,arg1=>value1,arg2=>value2&>string1 <&|/loc ,arg1=>value1,arg2=>value2&>string2 <&|/l , arg1=>value1,arg2=>value2&>string3 <&|/loc , arg1=>value1,arg2=>value2&>string4 <&|/l , arg1=>value1, arg2=>value2&>string5 <&|/loc , arg1=>value1, arg2=>value2&>string6 <&| /l , arg1=>value1, arg2=>value2 &>string7 <&| /loc , arg1=>value1, arg2=>value2 &>string8 __EXAMPLE__ #. (arg1=>value1,arg2=>value2) #: :1 msgid "string1" msgstr "" #. (arg1=>value1,arg2=>value2) #: :2 msgid "string2" msgstr "" #. (arg1=>value1,arg2=>value2) #: :3 msgid "string3" msgstr "" #. (arg1=>value1,arg2=>value2) #: :4 msgid "string4" msgstr "" #. (arg1=>value1, arg2=>value2) #: :5 msgid "string5" msgstr "" #. (arg1=>value1, arg2=>value2) #: :6 msgid "string6" msgstr "" #. (arg1=>value1, arg2=>value2) #: :7 msgid "string7" msgstr "" #. (arg1=>value1, arg2=>value2) #: :8 msgid "string8" msgstr "" __EXPECTED__ } #### END HTML::Mason (aka Mason 1) TESTS ############ #### BEGIN Mason (aka Mason 2) TESTS ############ SKIP: { skip( 'Mason unavailable', 6 ) unless eval { require Mason }; $Ext = Locale::Maketext::Extract->new( plugins => { mason => '*' } ); write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "Mason simple" ); <%$.fl {%>string1 <%$.floc {%>string2 <%$self->fl {%>string3 <%$self->floc {%>string4 __EXAMPLE__ #: :1 msgid "string1" msgstr "" #: :2 msgid "string2" msgstr "" #: :3 msgid "string3" msgstr "" #: :4 msgid "string4" msgstr "" __EXPECTED__ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "Mason simple with spaces" ); <% $.fl {%>string1 <% $.floc {%>string2 <% $self->fl {%>string3 <% $self->floc {%>string4 <% $.fl { %>string5 <% $.floc { %>string6 <% $self->fl { %>string7 <% $self->floc { %>string8 __EXAMPLE__ #: :1 msgid "string1" msgstr "" #: :2 msgid "string2" msgstr "" #: :3 msgid "string3" msgstr "" #: :4 msgid "string4" msgstr "" #: :5 msgid "string5" msgstr "" #: :6 msgid "string6" msgstr "" #: :7 msgid "string7" msgstr "" #: :8 msgid "string8" msgstr "" __EXPECTED__ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "Mason one argument" ); <%$.fl(arg1=>value1){%>string1 <%$.floc(arg1=>value1){%>string2 <%$self->fl(arg1=>value1){%>string3 <%$self->floc(arg1=>value1){%>string4 __EXAMPLE__ #. (arg1=>value1) #: :1 msgid "string1" msgstr "" #. (arg1=>value1) #: :2 msgid "string2" msgstr "" #. (arg1=>value1) #: :3 msgid "string3" msgstr "" #. (arg1=>value1) #: :4 msgid "string4" msgstr "" __EXPECTED__ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "Mason one argument with spaces" ); <% $.fl(arg1=>value1){%>string1 <% $.floc(arg1=>value1){%>string2 <% $.fl(arg1=>value1) {%>string3 <% $.floc(arg1=>value1) {%>string4 <% $.fl(arg1=>value1) { %>string5 <% $.floc(arg1=>value1) { %>string6 __EXAMPLE__ #. (arg1=>value1) #: :1 msgid "string1" msgstr "" #. (arg1=>value1) #: :2 msgid "string2" msgstr "" #. (arg1=>value1) #: :3 msgid "string3" msgstr "" #. (arg1=>value1) #: :4 msgid "string4" msgstr "" #. (arg1=>value1) #: :5 msgid "string5" msgstr "" #. (arg1=>value1) #: :6 msgid "string6" msgstr "" __EXPECTED__ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "Mason two arguments" ); <% $.fl(arg1=>value1,arg2=>value2){%>string1 <% $.floc(arg1=>value1,arg2=>value2){%>string2 <%$self->fl(arg1=>value1,arg2=>value2){%>string3 <%$self->floc(arg1=>value1,arg2=>value2){%>string4 __EXAMPLE__ #. (arg1=>value1,arg2=>value2) #: :1 msgid "string1" msgstr "" #. (arg1=>value1,arg2=>value2) #: :2 msgid "string2" msgstr "" #. (arg1=>value1,arg2=>value2) #: :3 msgid "string3" msgstr "" #. (arg1=>value1,arg2=>value2) #: :4 msgid "string4" msgstr "" __EXPECTED__ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "Mason two arguments with spaces" ); <%$.fl(arg1=>value1,arg2=>value2){%>string1 <%$.floc(arg1=>value1,arg2=>value2){%>string2 <% $.fl (arg1=>value1,arg2=>value2){%>string3 <% $.floc (arg1=>value1,arg2=>value2){%>string4 <% $.fl (arg1=>value1, arg2=>value2){%>string5 <% $.floc (arg1=>value1, arg2=>value2){%>string6 <% $.fl (arg1=>value1, arg2=>value2) {%>string7 <% $.floc (arg1=>value1, arg2=>value2) {%>string8 <% $.fl (arg1=>value1, arg2=>value2) { %>string9 <% $.floc (arg1=>value1, arg2=>value2) { %>string10 __EXAMPLE__ #. (arg1=>value1,arg2=>value2) #: :1 msgid "string1" msgstr "" #. (arg1=>value1, arg2=>value2) #: :10 msgid "string10" msgstr "" #. (arg1=>value1,arg2=>value2) #: :2 msgid "string2" msgstr "" #. (arg1=>value1,arg2=>value2) #: :3 msgid "string3" msgstr "" #. (arg1=>value1,arg2=>value2) #: :4 msgid "string4" msgstr "" #. (arg1=>value1, arg2=>value2) #: :5 msgid "string5" msgstr "" #. (arg1=>value1, arg2=>value2) #: :6 msgid "string6" msgstr "" #. (arg1=>value1, arg2=>value2) #: :7 msgid "string7" msgstr "" #. (arg1=>value1, arg2=>value2) #: :8 msgid "string8" msgstr "" #. (arg1=>value1, arg2=>value2) #: :9 msgid "string9" msgstr "" __EXPECTED__ } #### END Mason (aka Mason 2) TESTS ############ #### BEGIN FORMFU TESTS ############ SKIP: { skip( 'YAML.pm unavailable', 5 ) unless eval { require YAML }; $Ext = Locale::Maketext::Extract->new( plugins => { formfu => '*' } ); extract_ok( " content_loc: foo bar\n" => "foo bar", "html-formfu 1" ); write_po_ok( <<"__YAML__", <<"__PO__", 'html-formfu 2' ); --- content_loc: foo bar name: something else value_loc: something else as well __YAML__ #: :2 msgid "foo bar" msgstr "" #: :4 msgid "something else as well" msgstr "" __PO__ write_po_ok( <<"__YAML__" => <<"__PO__", 'html-formfu 3' ); --- content_loc: foo bar name: something else --- value_loc: something else as well __YAML__ #: :2 msgid "foo bar" msgstr "" #: :5 msgid "something else as well" msgstr "" __PO__ write_po_ok( <<"__YAML__" => <<"__PO__", 'html-formfu 4' ); --- name: {content_loc: foo, other: bar, value_loc: baz } value_loc: other __YAML__ #: :2 msgid "baz" msgstr "" #: :2 msgid "foo" msgstr "" #: :3 msgid "other" msgstr "" __PO__ write_po_ok( <<"__YAML__" => <<"__PO__", 'html-formfu 5' ); --- name: {content_loc: foo, other: bar, value_loc: baz } list: - { content_loc: hash1 } - more: { content_loc: hash2 } - and_more: - content_loc: nest_1 - { value_loc: nest_2 } - content_loc: - foo - bar - content_loc: [foo, bar] - content_loc: {foo: bar} value_loc: other __YAML__ #: :2 msgid "baz" msgstr "" #. (bar) #: :12 :2 :9 msgid "foo" msgstr "" #: :4 msgid "hash1" msgstr "" #: :5 msgid "hash2" msgstr "" #: :7 msgid "nest_1" msgstr "" #: :8 msgid "nest_2" msgstr "" #: :14 msgid "other" msgstr "" __PO__ } #### END FORMFU TESTS ############ #### BEGIN TT TESTS ############ SKIP: { skip( 'Template.pm unavailable', 50 ) unless eval { require Template }; $Ext = Locale::Maketext::Extract->new( plugins => { tt2 => '*' } ); extract_ok( <<'__EXAMPLE__' => 'foo bar baz', 'trim the string (tt)' ); [% |loc -%] foo bar baz [%- END %] __EXAMPLE__ write_po_ok( q([% l(string) %]) => '', 'TT l function - no string' ); write_po_ok( q([% l('string') %]) => <<'__EXAMPLE__', 'TT l function - no arg' ); #: :1 msgid "string" msgstr "" __EXAMPLE__ write_po_ok( q([% l('string',arg) %]) => <<'__EXAMPLE__', 'TT l function - variable arg' ); #. (arg) #: :1 msgid "string" msgstr "" __EXAMPLE__ write_po_ok( q([% l('string','arg') %]) => <<'__EXAMPLE__', 'TT l function - literal arg' ); #. ("arg") #: :1 msgid "string" msgstr "" __EXAMPLE__ write_po_ok( q([% string | l %]) => '', 'TT l inline filter - no string' ); write_po_ok( q([% 'string' | l %]) => <<'__EXAMPLE__', 'TT l inline filter - no arg' ); #: :1 msgid "string" msgstr "" __EXAMPLE__ write_po_ok( q([% 'string' | l('arg') %]) => <<'__EXAMPLE__', 'TT l inline filter - literal arg' ); #. ("arg") #: :1 msgid "string" msgstr "" __EXAMPLE__ write_po_ok( q([% 'string' | l(arg) %]) => <<'__EXAMPLE__', 'TT l inline filter - variable arg' ); #. (arg) #: :1 msgid "string" msgstr "" __EXAMPLE__ write_po_ok( q([% |l %][% string %][% END %]) => '', 'TT l block filter - no string' ); SKIP: { skip "Can't handle directive embedded in text blocks", 1; write_po_ok( q([% |l %] string [% var %][% END %]) => '', 'TT l block filter - embedded directive' ); } write_po_ok( q([% |l %]string[% END %]) => <<'__EXAMPLE__', 'TT l block filter - no arg' ); #: :1 msgid "string" msgstr "" __EXAMPLE__ write_po_ok( q([% |l('arg') %]string[% END %]) => <<'__EXAMPLE__', 'TT l block filter - literal arg' ); #. ("arg") #: :1 msgid "string" msgstr "" __EXAMPLE__ write_po_ok( q([% |l(arg) %]string[% END %]) => <<'__EXAMPLE__', 'TT l block filter - variable arg' ); #. (arg) #: :1 msgid "string" msgstr "" __EXAMPLE__ write_po_ok( q([% FILTER l(arg) %]string[% END %]) => <<'__EXAMPLE__', 'TT block FILTER - variable arg' ); #. (arg) #: :1 msgid "string" msgstr "" __EXAMPLE__ write_po_ok( q([% loc('string',arg) %]) => <<'__EXAMPLE__', 'TT loc function - variable arg' ); #. (arg) #: :1 msgid "string" msgstr "" __EXAMPLE__ write_po_ok( q([% 'string' | loc('arg') %]) => <<'__EXAMPLE__', 'TT loc inline filter - literal arg' ); #. ("arg") #: :1 msgid "string" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT multiline filter' ); [% | l(arg1,arg2) %] my string [% END %] __TT__ #. (arg1, arg2) #: :1 msgid "" "\n" "my string\n" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT multiline filter with chomp' ); [%- | l(arg1,arg2) -%] my string [%- END -%] __TT__ #. (arg1, arg2) #: :3 msgid "my string" msgstr "" __EXAMPLE__ extract_ok( q([% l('catted ' _ 'string') %]) => "catted string", "TT catted string" ); extract_ok( q([% l('catted ' _ string) %]) => "", "TT catted dir 1" ); extract_ok( q([% l('catted ' _ string) %]) => "", "TT catted dir 2" ); extract_ok( q([% l("embedded ${string}") %]) => "", "TT embedded string 1" ); extract_ok( q([% l("embedded \${string}") %]) => 'embedded ${string}', "TT embedded string 2" ); extract_ok( q([% l('embedded ${string}') %]) => 'embedded ${string}', "TT embedded string 3" ); write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 1' ); [% l('my \ string', 'my \ string') %] [% l('my \\ string', 'my \\ string') %] [% l("my \\ string", "my \\ string") %] __TT__ #. ("my \\ string") #: :1 :2 :3 msgid "my \\ string" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 2' ); [% l('my str\'ing','my str\'ing') %] __TT__ #. ("my str'ing") #: :1 msgid "my str'ing" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 3' ); [% l('my string"','my string"') %] __TT__ #. ("my string\"") #: :1 msgid "my string\"" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 4' ); [% l("my string'","my string'") %] __TT__ #. ("my string'") #: :1 msgid "my string'" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 5' ); [% l("my \nstring","my \nstring") %] __TT__ #. ("my \nstring") #: :1 msgid "" "my \n" "string" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 6' ); [% l('my \nstring','my \nstring') %] __TT__ #. ("my \\nstring") #: :1 msgid "my \\nstring" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 7' ); [% 'my \ string' | l('my \ string') %] [% 'my \\ string' | l('my \\ string') %] [% "my \\ string" | l("my \\ string") %] __TT__ #. ("my \\ string") #: :1 :2 :3 msgid "my \\ string" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 8' ); [% 'my str\'ing' | l('my str\'ing') %] __TT__ #. ("my str'ing") #: :1 msgid "my str'ing" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 9' ); [% 'my string"' | l('my string"') %] __TT__ #. ("my string\"") #: :1 msgid "my string\"" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 10' ); [% "my string'" |l("my string'") %] __TT__ #. ("my string'") #: :1 msgid "my string'" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 11' ); [% "my \nstring" |l("my \nstring") %] __TT__ #. ("my \nstring") #: :0 msgid "" "my \n" "string" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 12' ); [% 'my \nstring' |l('my \nstring') %] __TT__ #. ("my \\nstring") #: :1 msgid "my \\nstring" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 13' ); [% | l('my \ string') %]my \ string[% END %] [% | l('my \\ string') %]my \\ string[% END %] __TT__ #. ("my \\ string") #: :1 msgid "my \\ string" msgstr "" #. ("my \\ string") #: :2 msgid "my \\\\ string" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 14' ); [% | l('my str\'ing') %]my str'ing[% END %] __TT__ #. ("my str'ing") #: :1 msgid "my str'ing" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 15' ); [% | l('my str\'ing') %]my str\'ing[% END %] __TT__ #. ("my str'ing") #: :1 msgid "my str\\'ing" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 16' ); [% | l("my str\"ing") %]my str"ing[% END %] __TT__ #. ("my str\"ing") #: :1 msgid "my str\"ing" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 17' ); [% | l("my str\"ing") %]my str\"ing[% END %] __TT__ #. ("my str\"ing") #: :1 msgid "my str\\\"ing" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 18' ); [% |l("my \nstring") %]my string[% END %] __TT__ #. ("my \nstring") #: :1 msgid "" "my\n" "string" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT quoted - 19' ); [% |l('my \nstring') %]my \nstring[% END %] __TT__ #. ("my \\nstring") #: :1 msgid "my \\nstring" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT key values' ); [% l('string', key1=>'value',key2=>value, key3 => value.method) %] __TT__ #. ({ 'key1' => 'value', 'key2' => value, 'key3' => value.method }) #: :1 msgid "string" msgstr "" __EXAMPLE__ write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'TT complex args' ); [% l('string',b.method.$var(arg),c('arg').method.5) %] __TT__ #. (b.method.$var(arg), c("arg").method.5) #: :1 msgid "string" msgstr "" __EXAMPLE__ # Mojo tests extract_ok( q([% c.l('Hello, world!') %]) => "Hello, world!", "Mojolicious c.l syntax is supported correctly", ); write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'Mojolicious and c.l filter syntax' ); [% 'my string' | c.l %] __TT__ #: :1 msgid "my string" msgstr "" __EXAMPLE__ extract_ok( q([% c.loc('Hello, world!') %]) => "Hello, world!", "Mojolicious c.loc syntax is supported correctly", ); write_po_ok( <<'__TT__' => <<'__EXAMPLE__', 'Mojolicious and c.loc filter syntax' ); [% 'my string' | c.loc %] __TT__ #: :1 msgid "my string" msgstr "" __EXAMPLE__ #### END TT TESTS ############ } #### BEGIN YAML TESTS ############ SKIP: { skip( 'YAML.pm unavailable', 9 ) unless eval { require YAML }; $Ext = Locale::Maketext::Extract->new( plugins => { yaml => '*' } ); extract_ok( qq(key: _"string"\n) => "string", "YAML double quotes" ); extract_ok( qq(key: _'string'\n) => "string", "YAML single quotes" ); extract_ok( qq(key: _"str"ing"\n) => 'str"ing', "YAML embedded double quote" ); extract_ok( qq( key: { s1: _"string_1", s2: _'string_2', s3: _'string'3'}\n) => q(string'3string_1string_2), 'YAML inline hash' ); extract_ok( qq( - _"string_1"\n - _'string_2'\n - _'string'3'\n) => q(string'3string_1string_2), 'YAML array' ); extract_ok( qq(key: [ _"string_1", _'string_2', _'string'3' ]\n) => q(string'3string_1string_2), 'YAML Inline arrays' ); write_po_ok( qq(---\nkey: _"string"\n---\nkey2: _"string2"\n\n\n\n) => <<'__EXAMPLE__', 'YAML multiple docs' ); #: :2 msgid "string" msgstr "" #: :4 msgid "string2" msgstr "" __EXAMPLE__ write_po_ok( <<__YAML__ => <<'__EXAMPLE__', 'YAML folded/block scalars' ); --- key: > _'My folded scalar' key2: |- _'My block scalar ' __YAML__ #: :5 msgid "" "My block\n" "scalar\n" msgstr "" #: :2 msgid "My folded scalar" msgstr "" __EXAMPLE__ write_po_ok( <<__YAML__ => <<'__EXAMPLE__', 'YAML nested' ); --- foo: bar: - _'first' - baz: > _'second' boo: |- _'My block scalar ' bla: [ _'inline_seq' , _'inline_seq2' ] __YAML__ #: :7 msgid "" "My block\n" "scalar\n" msgstr "" #: :4 msgid "first" msgstr "" #: :11 msgid "inline_seq" msgstr "" #: :11 msgid "inline_seq2" msgstr "" #: :5 msgid "second" msgstr "" __EXAMPLE__ } #### END YAML TESTS ############ #### BEGIN HAML TESTS ########## SKIP: { skip( 'HAML unavailable', 6 ) unless eval { require Text::Haml }; $Ext = Locale::Maketext::Extract->new( plugins => { haml => '*' } ); extract_ok( '%a{:href=>"#"}= "[+] " . l("string")' => "string", "HAML double quotes." ); extract_ok( '%a{:href=>"#"}= "[+] " . l("str\"ing")' => "str\"ing", "HAML double quotes with escaped \"." ); extract_ok( q|%a{:href=>"#"}= "[+] " . l('string')| => "string", "HAML single quotes." ); extract_ok( q|%a{:href=>"#"}= "[+] " . l('[_1] plus [_1] equals [_2].', 'two', 'five')| => "%1 plus %1 equals %2.", "HAML string with args." ); extract_ok( '- stash(title => l("My Title"))' => "My Title", "HAML Perl block."); write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "HAML file" ); !!! 5 %html %head %meta{:charset => "utf-8"} %title title %link{:rel=>"stylesheet", :href=>"/css/style.css"} %script{:type=>"text/javascript", :src=>"/js/jquery-1.8.2.min.js"} %body %ul#nav %li %a{:href=>"#"}= l("Home") %li %a{:href=>"#"}= "[+] " . l("About") %li %a{:href=>"#"}= "[+] " . l('[_1] plus [_1] equals [_2].', 'two', 'five') __EXAMPLE__ #. ('two', 'five') #: :1 msgid "%1 plus %1 equals %2." msgstr "" #: :1 msgid "About" msgstr "" #: :1 msgid "Home" msgstr "" __EXPECTED__ } #### END HAML TESTS ############ sub extract_ok { my ( $text, $expected, $info, $verbatim ) = @_; $Ext->extract( '' => $text ); $Ext->compile($verbatim); my %lexicon = %{ $Ext->lexicon }; my $result = join( '', map { $_ => $lexicon{$_} } sort keys %lexicon ); is( $result, $expected, $info ); $Ext->clear; } sub write_po_ok { my ( $text, $expected, $info, $verbatim ) = @_; my $po_file = 't/5-extract.po'; # create .po $Ext->extract( '' => $text ); $Ext->compile($verbatim); $Ext->write_po($po_file); # read .po open( my $po_handle, '<', $po_file ) or die("Cannot open $po_file: $!"); local $/ = undef; my $result = <$po_handle>; close($po_handle); unlink($po_file) or die("Cannot unlink $po_file: $!"); # cut the header from result my $start_expected = length( $Ext->header ); $start_expected++ if ( $start_expected < length($result) ); # check result vs expected is( substr( $result, $start_expected ), $expected, $info ); $Ext->clear; } Locale-Maketext-Lexicon-1.00/t/51-perlextract.t000644 000765 000024 00000016256 12306052703 022041 0ustar00clintonstaff000000 000000 #! /usr/bin/perl -w use lib '../lib'; use strict; use Test::More tests => 89; use_ok('Locale::Maketext::Extract'); my $Ext = Locale::Maketext::Extract->new( plugins => { 'Locale::Maketext::Extract::Plugin::Perl' => '*' } ); # Standard Perl parser run_tests('perl - '); SKIP: { # PPI parser skip( 'PPI unavailable', 44 ) unless eval { require PPI }; $Ext = Locale::Maketext::Extract->new( plugins => { 'Locale::Maketext::Extract::Plugin::PPI' => '*' } ); run_tests('ppi - '); } sub run_tests { my $prefix = shift; isa_ok( $Ext => 'Locale::Maketext::Extract' ); #### BEGIN PERL TESTS ############ extract_ok( '_("123")' => 123, $prefix . 'Simple extraction' ); extract_ok( '_("[_1] is happy")' => '%1 is happy', $prefix . '[_1] to %1' ); extract_ok( '_("%1 is happy")' => '%1 is happy', $prefix . '%1 verbatim', 1 ); extract_ok( '_("[*,_1] counts")' => '%*(%1) counts', $prefix . '[*,_1] to %*(%1)' ); extract_ok( '_("%*(%1) counts")' => '%*(%1) counts', $prefix . '%*(%1) verbatim', 1 ); extract_ok( '_("[*,_1,_2] counts")' => '%*(%1,%2) counts', $prefix . '[*,_1,_2] to %*(%1,%2)' ); extract_ok( '_("[*,_1,_2] counts")' => '[*,_1,_2] counts', $prefix . '[*,_1,_2] verbatim', 1 ); extract_ok( q(_('foo\$bar')) => 'foo\\$bar', $prefix . 'Escaped \$ in q' ); extract_ok( q(_("foo\$bar")) => 'foo$bar', $prefix . 'Normalized \$ in qq' ); extract_ok( q(_('foo\x20bar')) => 'foo\\x20bar', $prefix . 'Escaped \x in q' ); extract_ok( q(_("foo\x20bar")) => 'foo bar', $prefix . 'Normalized \x in qq' ); extract_ok( q(_('foo\nbar')) => 'foo\\nbar', $prefix . 'Escaped \n in qq' ); extract_ok( q(_("foo\nbar")) => "foo\nbar", $prefix . 'Normalized \n in qq' ); extract_ok( qq(_("foo\nbar")) => "foo\nbar", $prefix . 'Normalized literal \n in qq' ); extract_ok( q(_("foo\nbar")) => "foo\nbar", $prefix . 'Trailing \n in qq' ); extract_ok( qq(_("foobar\n")) => "foobar\n", $prefix . 'Trailing literal \n in qq' ); extract_ok( q(_('foo\bar')) => 'foo\\bar', $prefix . 'Escaped \ in q' ); extract_ok( q(_('foo\\\\bar')) => 'foo\\bar', $prefix . 'Normalized \\\\ in q' ); extract_ok( q(_("foo\bar")) => "foo\bar", $prefix . 'Interpolated \b in qq' ); extract_ok( q(l( 'foo "bar" baz' );) => 'foo "bar" baz', $prefix . 'Recognizes l() as a localization function' ); extract_ok( q([% loc( 'foo "bar" baz' ) %]) => 'foo "bar" baz', $prefix . 'Escaped double quote in text' ); extract_ok( q( _(q{foo bar})) => "foo bar", $prefix . 'No escapes' ); extract_ok( q(_(q{foo\bar})) => 'foo\\bar', $prefix . 'Escaped \ in q' ); extract_ok( q(_(q{foo\\\\bar})) => 'foo\\bar', $prefix . 'Normalized \\\\ in q' ); extract_ok( q(_(qq{foo\bar})) => "foo\bar", $prefix . 'Interpolated \b in qq' ); extract_ok( q(my $x = loc('I "think" you\'re a cow.') . "\n";) => 'I "think" you\'re a cow.', $prefix . "Handle escaped single quotes" ); extract_ok( q(my $x = loc("I'll poke you like a \"cow\" man.") . "\n";) => 'I\'ll poke you like a "cow" man.', $prefix . "Handle escaped double quotes" ); extract_ok( q(_("","car")) => '', $prefix . 'ignore empty string' ); extract_ok( q(_("0")) => '', $prefix . 'ignore zero' ); extract_ok( <<'__EXAMPLE__' => "123\n", "Simple extraction (heredoc)" ); _(<<__LOC__); 123 __LOC__ __EXAMPLE__ extract_ok( <<'__EXAMPLE__' => "foo\\\$bar\\\'baz\n", "No escaped of \$ and \' in singlequoted terminator (heredoc)" ); _(<<'__LOC__'); foo\$bar\'baz __LOC__ __EXAMPLE__ extract_ok( <<'__EXAMPLE__' => "foo\$bar\n", "Normalized \$ in doublequoted terminator (heredoc)" ); _(<<"__LOC__"); foo\$bar __LOC__ __EXAMPLE__ extract_ok( <<'__EXAMPLE__' => "foo\nbar\n", "multilines (heredoc)" ); _(<<__LOC__); foo bar __LOC__ __EXAMPLE__ extract_ok( <<'__EXAMPLE__' => "example\n", "null identifier (heredoc)" ); _(<<""); example __EXAMPLE__ extract_ok( <<'__EXAMPLE__' => "example\n", "end() after the heredoc (heredoc)" ); _(<<__LOC__ example __LOC__ ); __EXAMPLE__ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "null identifier with end after the heredoc (heredoc)" ); _(<<"" example ); __EXAMPLE__ #: :1 msgid "example\n" msgstr "" __EXPECTED__ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "q with multilines with args" ); _(q{example %1 with multilines },20); __EXAMPLE__ #. (20) #: :1 msgid "" "example %1\n" "with multilines\n" msgstr "" __EXPECTED__ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "null terminator with multilines with args (heredoc)" ); _(<<"", 15) example %1 with multilines __EXAMPLE__ #. (15) #: :1 msgid "" "example %1\n" "with multilines\n" msgstr "" __EXPECTED__ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "null terminator with end after the heredoc with args (heredoc)" ); _(<<"", 10) example %1 __EXAMPLE__ #. (10) #: :1 msgid "example %1\n" msgstr "" __EXPECTED__ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "two _() calls (heredoc)" ); _(<<"", 10) example1 %1 _(<<"", 5) example2 %1 __EXAMPLE__ #. (10) #: :1 msgid "example1 %1\n" msgstr "" #. (5) #: :4 msgid "example2 %1\n" msgstr "" __EXPECTED__ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "concat (heredoc)" ); _('exam'.<<"", 10) ple1 %1 __EXAMPLE__ #. (10) #: :1 msgid "example1 %1\n" msgstr "" __EXPECTED__ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "two _() calls with concat over multiline (heredoc)" ); _('example' . <<"", 10) 1 %1 _(<<"", 5) example2 %1 __EXAMPLE__ #. (10) #: :1 msgid "example1 %1\n" msgstr "" #. (5) #: :5 msgid "example2 %1\n" msgstr "" __EXPECTED__ write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "i can concat the world!" ); _( '\$foo' ."\$bar" .<<'' \$baz ) __EXAMPLE__ #: :2 msgid "\\$foo$bar\\$baz\n" msgstr "" __EXPECTED__ #### END PERL TESTS ############ } sub extract_ok { my ( $text, $expected, $info, $verbatim ) = @_; $Ext->extract( '' => $text ); $Ext->compile($verbatim); my $result = join( '', %{ $Ext->lexicon } ); is( $result, $expected, $info ); $Ext->clear; } sub write_po_ok { my ( $text, $expected, $info, $verbatim ) = @_; my $po_file = 't/5-extract.po'; # create .po $Ext->extract( '' => $text ); $Ext->compile($verbatim); $Ext->write_po($po_file); # read .po open( my $po_handle, '<', $po_file ) or die("Cannot open $po_file: $!"); local $/ = undef; my $result = <$po_handle>; close($po_handle); unlink($po_file) or die("Cannot unlink $po_file: $!"); # cut the header from result my $start_expected = length( $Ext->header ); $start_expected++ if ( $start_expected < length($result) ); # check result vs expected is( substr( $result, $start_expected ), $expected, $info ); $Ext->clear; } Locale-Maketext-Lexicon-1.00/t/52-extractpluginselection.t000644 000765 000024 00000003156 12306052703 024277 0ustar00clintonstaff000000 000000 #! /usr/bin/perl -w use lib '../lib'; use strict; my ( $tests, %test_cases ); BEGIN { $tests = 9; %test_cases = ( 'test.pl' => ['Perl'], 'test.pm' => ['Perl'], 'test.cgi' => ['Perl'], ); eval { require Template; %test_cases = ( %test_cases, 'test.tt' => ['TT2'], 'test.tt2' => ['TT2'], 'test.html' => ['TT2'], 'test.tt.*' => ['TT2'], 'test.tt2.*' => ['TT2'], ); $tests += 10; }; eval { require YAML::Loader; %test_cases = ( %test_cases, 'test.yaml' => [ 'YAML', 'FormFu' ], 'test.yml' => [ 'YAML', 'FormFu' ], 'test.conf' => [ 'YAML', 'FormFu' ], ); $tests += 9; }; } use Test::More tests => $tests; use_ok('Locale::Maketext::Extract'); my $Ext = Locale::Maketext::Extract->new; isa_ok( $Ext => 'Locale::Maketext::Extract' ); while ( my ( $filename, $expected ) = each %test_cases ) { my @plugins = $Ext->_plugins_specifically_for_file($filename); cmp_ok( scalar(@plugins), '==', scalar( @{$expected} ), "Number of plugins suitable for use with $filename match." ); foreach my $name ( @{$expected} ) { my $present = grep { "Locale::Maketext::Extract::Plugin::$name" eq ref $_ } @plugins; ok( $present, "Got all expected plugins for $filename." ); } } my @plugins = $Ext->_plugins_specifically_for_file('test.idk'); cmp_ok( scalar(@plugins), '==', 0, 'No specific plugins for unknown file type.' ); Locale-Maketext-Lexicon-1.00/t/55-runextract.t000644 000765 000024 00000001316 12306052703 021676 0ustar00clintonstaff000000 000000 #! /usr/bin/perl -w use lib '../lib'; use strict; use Test::More tests => 2; # test if the xgettext '-f' parameter stripts newlines from the filenames # http://bugs.debian.org/307777 use_ok('Locale::Maketext::Extract::Run'); my $inputfile = "$$.in"; my $listfile = "$$.list"; my $outfile = "$$.out"; open(F, ">$inputfile") or die("create $inputfile failed: $!"); print F "loc('test')"; close F; open(F, ">$listfile") or die("create $inputfile failed: $!"); print F "$inputfile\n/dev/null"; close F; Locale::Maketext::Extract::Run::xgettext('-f', $listfile, '-o', $outfile); ok(-s $outfile, "non-empty output for Locale::Maketext::Extract::Run::xgettext"); unlink $_ for ($inputfile, $listfile, $outfile); Locale-Maketext-Lexicon-1.00/t/6-gettext.t000755 000765 000024 00000011711 12306052703 021102 0ustar00clintonstaff000000 000000 #!/usr/bin/perl -w use strict; use Test::More tests => 30; package Hello::I18N; use Test::More; use Tie::Hash; my $warned; $SIG{__WARN__} = sub { $warned++ }; use_ok(base => 'Locale::Maketext'); use_ok( 'Locale::Maketext::Lexicon' => { en => ['Auto'], fr => ['Tie' => [ 'Tie::StdHash' ]], de => ['Gettext' => \*::DATA], zh_tw => ['Gettext' => 't/messages.mo'], zh_cn => ['Msgcat' => 't/gencat.m'], zh_hk => [ 'Msgcat' => 't/gencat.m', 'Gettext' => 't/messages.po', ], ru => ['Gettext' => 't/notexist.po'], _style => 'gettext', }, ); ok(!$warned, 'no warnings on blank lines'); Locale::Maketext::Lexicon->import({ de_de => ['Gettext' => \*::DATA], ru => ['Gettext' => 't/notexist.po'], _use_fuzzy => 1, }); package main; ################################################################ ok(my $lh = Hello::I18N->get_handle('en-us'), 'Auto - get_handle'); is( $lh->maketext('Heute die Welt'), 'Heute die Welt', 'Auto - autofilling' ); ################################################################ ok($lh = Hello::I18N->get_handle('de'), 'Gettext - get_handle'); is( $lh->maketext('Hello, World!'), 'Hallo, Welt!', 'Gettext - simple case' ); is( $lh->maketext('You have %*(%1,piece) of mail.', 10), 'Sie haben 10 Poststuecken.', 'Gettext - complex case' ); is( $lh->maketext('%1 %2 %*', 1, 2, 3), '123 2 1', 'Gettext - asterisk interpolation' ); is( $lh->maketext('%1%2%*', 1, 2, 3), '12321', 'Gettext - concatenated variables' ); is( $lh->maketext('%1()', 10), '10()', 'Gettext - correct parens' ); is( $lh->maketext('__Content-Type'), 'text/plain; charset=ISO-8859-1', 'Gettext - metadata' ); is( $lh->maketext('%1()', 10), '10()', 'Gettext - correct parens' ); is( $lh->maketext("\n\nKnowledge\nAnd\nNature\n\n"), "\n\n". "Ich wuenschte recht gelehrt zu werden,\n". "Und moechte gern, was auf der Erden\n". "Und in dem Himmel ist, erfassen,\n". "Die Wissenschaft und die Natur.\n\n", 'Gettext - multiline' ); is( eval { $lh->maketext("The Hitchhiker's Guide to the Galaxy") }, undef, 'Gettext - fuzzy entries are ignored' ); ok($lh = Hello::I18N->get_handle('de_de'), 'Gettext - get_handle on DATA again'); is( eval { $lh->maketext("The Hitchhiker's Guide to the Galaxy") }, 'Der Fuehrer des Trampers zur Galaxie', 'Gettext - fuzzy entries are recognized with _use_fuzzy' ); ################################################################ SKIP: { skip("no msgunfmt available", 2) unless `msgunfmt -V` and !$?; ok($lh = Hello::I18N->get_handle('zh_tw'), 'Gettext - get_handle'); is( $lh->maketext('This is a test'), '這是測試', 'Gettext - MO File' ); } ################################################################ ok($lh = Hello::I18N->get_handle('fr'), 'Tie - get_handle'); $Hello::I18N::fr::Lexicon{"Good morning"} = 'Bon jour'; $Hello::I18N::fr::Lexicon{"Good morning, [_1]"} = 'Bon jour, [_1]'; is( $lh->maketext('Good morning'), 'Bon jour', 'Tie - simple case' ); is( $lh->maketext('Good morning, %1', 'Sean'), 'Bon jour, Sean', 'Tie - complex case' ); ################################################################ ok($lh = Hello::I18N->get_handle('zh_cn'), 'Msgcat - get_handle'); is( $lh->maketext(1, 1), 'First string', 'Msgcat - simple case' ); is( $lh->maketext(1, 2), 'Second string', 'Msgcat - continued string' ); is( $lh->maketext(1, 3), 'Third string', 'Msgcat - quote character' ); is( $lh->maketext(1, 4), 'Fourth string', 'Msgcat - quote character + continued string' ); ################################################################ ok($lh = Hello::I18N->get_handle('zh_hk'), 'Multiple lexicons - get_handle'); is( $lh->maketext(1, 1), 'First string', 'Multiple lexicons - first' ); is( $lh->maketext('This is a test'), '這是測試', 'Multiple lexicons - second' ); __DATA__ msgid "" msgstr "" "Project-Id-Version: Test App 0.01\n" "POT-Creation-Date: 2002-05-02 11:36+0800\n" "PO-Revision-Date: 2002-05-13 02:00+0800\n" "Last-Translator: \n" "Language-Team: German \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=ISO-8859-1\n" "Content-Transfer-Encoding: 8bit\n" #: Hello.pm:10 msgid "Hello, World!" msgstr "Hallo, Welt!" #: Hello.pm:11 msgid "You have %*(%1,piece) of mail." msgstr "Sie haben %*(%1,Poststueck,Poststuecken)." #: Hello.pm:12 msgid "%1()" msgstr "%1()" #: Hello.pm:13 msgid "%1 %2 %*" msgstr "%* %2 %1" #: Hello.pm:14 msgid "%1%2%*" msgstr "%*%2%1" #: Hello.pm:15 msgid "" "\n" "\n" "Knowledge\n" "And\n" "Nature\n" "\n" msgstr "" "\n" "\n" "Ich wuenschte recht gelehrt zu werden,\n" "Und moechte gern, was auf der Erden\n" "Und in dem Himmel ist, erfassen,\n" "Die Wissenschaft und die Natur.\n" "\n" #: Hello.pm:16 #, big, furry, fuzzy msgid "The Hitchhiker's Guide to the Galaxy" msgstr "Der Fuehrer des Trampers zur Galaxie" Locale-Maketext-Lexicon-1.00/t/61-badcharset.t000644 000765 000024 00000001014 12306052703 021567 0ustar00clintonstaff000000 000000 #!/usr/bin/perl -w use strict; use Test::More tests => 1; require Locale::Maketext::Lexicon; package MyApp::I18N::i_default; # Need below to fake the loading of the po file our %Lexicon = ( _AUTO => 1 ); package main; eval " package MyApp::I18N; use base 'Locale::Maketext'; Locale::Maketext::Lexicon->import({ 'i-default' => [ 'Gettext' => 't/badcharset.po' ], _decode => 1, _encoding => undef, }); "; like( $@, qr/Unknown encoding 'CHARSET'/, "Caught bad encoding error" ); Locale-Maketext-Lexicon-1.00/t/7-roundtrip.t000644 000765 000024 00000002710 12306052703 021441 0ustar00clintonstaff000000 000000 #!/usr/bin/perl -w # # Check that comments in PO files are correctly parsed # use strict; use Test::More tests => 11; use_ok('Locale::Maketext::Extract'); my %msgids = ( comment => 'A random string to check that comments work', fuzzy => 'Fuzzy flag', marker => 'Fuzzy plus marker %1' ); my $lex = Locale::Maketext::Extract->new(); ok( $lex, 'Locale::Maketext::Extract object created' ); $lex->read_po('t/comments.po'); # Here '#' and newlines are kept together with the comment # Don't know if it's correct or elegant is( $lex->msg_comment( $msgids{comment} ), 'Some user comment' . "\n" ); ok( $lex->msg_fuzzy( $msgids{fuzzy} ), 'Read fuzzy' ); ok( $lex->msg_fuzzy( $msgids{marker} ), 'Read marker' ); $lex->write_po( 't/comments_out.po', 1 ); $lex->clear(); is( $lex->msg_comment( $msgids{comment} ), undef, 'Comment should be gone with clear()' ); ok( !$lex->msg_fuzzy( $msgids{fuzzy} ), 'Fuzzy cleared' ); # Read back the new po file and check that # the comment is readable again $lex->read_po('t/comments_out.po'); is( $lex->msg_comment( $msgids{comment} ), 'Some user comment' . "\n" ); ok( $lex->msg_fuzzy( $msgids{fuzzy} ), 'Read fuzzy' ); my $po; { local ( *INPUT, $/ ); open( INPUT, 't/comments_out.po' ) || die "can't open 't/comments_out.po': $!"; $po = ; } ok( $po =~ m/#, fuzzy, perl-maketext-format\nmsgid "Fuzzy plus marker %1"/, 'Marker added' ); ok( unlink('t/comments_out.po') ); Locale-Maketext-Lexicon-1.00/t/8-plugin-args.t000644 000765 000024 00000004145 12306052703 021650 0ustar00clintonstaff000000 000000 #!/usr/bin/perl -w # # Check that the command line plugin args are parsed correctly # use strict; use Test::More tests => 12; use_ok('Locale::Maketext::Extract::Run'); test( undef, { warnings => undef,wrap => 0 }, 'no options' ); test( ['yaml'], { warnings => 1, wrap => 0, plugins => { yaml => [] } }, 'builtin - no file types' ); test( ['yaml=*'], { warnings => 1, wrap => 0, plugins => { yaml => ['*'] } }, 'builtin - all file types' ); test( ['yaml=yml'], { warnings => 1, wrap => 0, plugins => { yaml => ['yml'] } }, 'builtin - one file types' ); test( ['yaml=yaml,yml'], { warnings => 1, wrap => 0, plugins => { yaml => [ 'yaml', 'yml' ] } }, 'builtin - two file types' ); test( ['yaml=yaml,yml,conf'], { warnings => 1, wrap => 0, plugins => { yaml => [ 'yaml', 'yml', 'conf' ] } }, 'builtin - three file types' ); test( ['yaml=yaml,*,conf'], { warnings => 1, wrap => 0, plugins => { yaml => ['*'] } }, 'builtin - all plus file types' ); test( ['yaml=.yaml,.conf'], { warnings => 1, wrap => 0, plugins => { yaml => [ 'yaml', 'conf' ] } }, 'builtin - trim leading period' ); test( ['My::Module=.yaml,.conf'], { warnings => 1, wrap => 0, plugins => { 'My::Module' => [ 'yaml', 'conf' ] } }, 'custom - trim leading period' ); test_fail( ['y~aml=..yaml,.conf'], q(Couldn't understand plugin option 'y~aml=..yaml,.conf'), 'Bad plugin' ); test_fail( ['yaml=..yaml,.conf'], q(Couldn't understand '..yaml' in plugin 'yaml=..yaml,.conf'), 'Bad filetypes' ); sub test { my $P = shift; my $options = Locale::Maketext::Extract::Run->_parse_extract_options( { P => $P } ); delete $options->{verbose}; is_deeply( $options, shift, shift ); } sub test_fail { my $P = shift; my $match = shift; eval { my $options = Locale::Maketext::Extract::Run->_parse_extract_options( { P => $P } ); }; like( $@, qr/^\Q$match\E/, shift ); } Locale-Maketext-Lexicon-1.00/t/9-bug-import-for-subclasses.t000644 000765 000024 00000002232 12306052703 024432 0ustar00clintonstaff000000 000000 #!/usr/bin/perl -w use strict; use Test::More tests => 4; package Hello::I18N; use base qw/Locale::Maketext/; package Hello::I18N::zh_tw; use base qw/Hello::I18N/; use Locale::Maketext::Lexicon ( Gettext => 't/messages.mo', ); package Hello::I18N::bzh_bzh; use base qw/Hello::I18N/; use Locale::Maketext::Lexicon ( Gettext => \*::DATA, _use_fuzzy => 1); package main; ok(my $lh = Hello::I18N->get_handle('zh-tw'), 'got handle'); is( $lh->maketext('This is a test'), '這是測試', 'translated' ); ok($lh = Hello::I18N->get_handle('bzh_BZH'), 'Gettext - get_handle on DATA again'); is( eval { $lh->maketext("See you another time!") }, "D'ur wech all !", 'Gettext - fuzzy recognized: _use_fuzzy has been set' ); __DATA__ msgid "" msgstr "" "Project-Id-Version: Test App 0.01\n" "POT-Creation-Date: 2006-06-13 11:36+0800\n" "PO-Revision-Date: 2006-06-13 02:00+0800\n" "Last-Translator: \n" "Language-Team: German \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=ISO-8859-1\n" "Content-Transfer-Encoding: 8bit\n" #: Hello.pm:16 #, big, furry, fuzzy msgid "See you another time!" msgstr "D'ur wech all !" Locale-Maketext-Lexicon-1.00/t/91-pod_test.t000644 000765 000024 00000000201 12306052703 021310 0ustar00clintonstaff000000 000000 use Test::More; eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok(); Locale-Maketext-Lexicon-1.00/t/badcharset.po000644 000765 000024 00000000415 12306052703 021522 0ustar00clintonstaff000000 000000 msgid "" msgstr "" "Last-Translator: Audrey Tang \n" "Language-Team: Chinese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" msgid "This is a test" msgstr "這是測試"Locale-Maketext-Lexicon-1.00/t/comments.po000644 000765 000024 00000001216 12306052703 021247 0ustar00clintonstaff000000 000000 msgid "" msgstr "" "Project-Id-Version: Test App 0.01\n" "POT-Creation-Date: 2008-08-01 14:20+0200\n" "PO-Revision-Date: 2008-08-01 14:21+0200\n" "Last-Translator: \n" "Language-Team: Italian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" # Some user comment #: comments.t:1 msgid "A random string to check that comments work" msgstr "Una stringa casuale per controllare che i commenti funzionino" #: comments.t:2 #, fuzzy msgid "Fuzzy flag" msgstr "Fuzzy flag trans" #: comments.t:3 #, fuzzy msgid "Fuzzy plus marker %1" msgstr "Fuzzy plus marker %1 trans" Locale-Maketext-Lexicon-1.00/t/gencat.m000644 000765 000024 00000000276 12306052703 020506 0ustar00clintonstaff000000 000000 $ by Audrey Tang $set 1 # $Id: //member/autrijus/Locale-Maketext-Lexicon/t/gencat.m#1 $ 1 First string 2 Second \ str\ ing $quote X 3 XThird stringX 4 XFourth X\ XstringX Locale-Maketext-Lexicon-1.00/t/lib/000755 000765 000024 00000000000 12306052703 017630 5ustar00clintonstaff000000 000000 Locale-Maketext-Lexicon-1.00/t/locale/000755 000765 000024 00000000000 12306052703 020321 5ustar00clintonstaff000000 000000 Locale-Maketext-Lexicon-1.00/t/messages.mo000644 000765 000024 00000000454 12306052703 021231 0ustar00clintonstaff000000 000000 ,<PQ` This is a testLast-Translator: Autrijus Tang Language-Team: Chinese MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 這是測試Locale-Maketext-Lexicon-1.00/t/messages.po000644 000765 000024 00000000414 12306052703 021230 0ustar00clintonstaff000000 000000 msgid "" msgstr "" "Last-Translator: Audrey Tang \n" "Language-Team: Chinese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" msgid "This is a test" msgstr "這是測試" Locale-Maketext-Lexicon-1.00/t/preload.t000644 000765 000024 00000001031 12306052703 020670 0ustar00clintonstaff000000 000000 #!/usr/bin/perl -w use strict; use warnings; use Test::More tests => 4; package Hello::I18N; use Test::More; use_ok( base => 'Locale::Maketext' ); use_ok( 'Locale::Maketext::Lexicon' => { zh_hk => [ 'Gettext' => 't/messages.po' ], _preload => 1, }, ); package main; my $hash; { no warnings 'once'; $hash = \%Hello::I18N::zh_hk::Lexicon; } ok( keys %$hash, "Ok, hash is there and has some info" ); { local $TODO = "No idea why hash is not tied"; ok( tied %$hash, "hash is still tied" ); } Locale-Maketext-Lexicon-1.00/t/release-eol.t000644 000765 000024 00000000476 12306052703 021453 0ustar00clintonstaff000000 000000 BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use strict; use warnings; use Test::More; eval 'use Test::EOL'; plan skip_all => 'Test::EOL required' if $@; all_perl_files_ok({ trailing_whitespace => 1 }); Locale-Maketext-Lexicon-1.00/t/release-pod-syntax.t000644 000765 000024 00000000456 12306052703 023000 0ustar00clintonstaff000000 000000 #!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use Test::More; use Test::Pod 1.41; all_pod_files_ok(); Locale-Maketext-Lexicon-1.00/t/T_L10N.pm000644 000765 000024 00000003235 12306052703 020360 0ustar00clintonstaff000000 000000 # Test localization class and its subclasses # Copyright (c) 2003 imacat. All rights reserved. This program is free # software; you can redistribute it and/or modify it under the same terms # as Perl itself. package T_L10N; use strict; use FindBin; use File::Spec; use base qw(Locale::Maketext); my (%Domains, $Domain); sub bindtextdomain { my ($self, $domain, $dir) = @_; return $Domains{$domain} unless $dir; $Domains{$domain} = $dir; require Locale::Maketext::Lexicon; Locale::Maketext::Lexicon->import({ '*' => [ Gettext => File::Spec->catdir( $dir, qw(* LC_MESSAGES), "$domain.mo" ) ], _decode => 1, }); } sub textdomain { my ($self, $domain) = @_; $Domain = $domain if $domain; return $Domain; } sub readmo { my ($self, $file) = @_; local ($/, *FH); open FH, $file; binmode(FH); require Locale::Maketext::Lexicon::Gettext; my $hashref = Locale::Maketext::Lexicon::Gettext::parse_mo(); delete @{$hashref}{grep /^__/, keys %$hashref}; return Locale::Maketext::Lexicon::Gettext->input_encoding, %$hashref; } sub encoding { my ($self, $encoding) = @_; if ($encoding) { $self->{CUR_ENC} = $encoding; } elsif ( !$self->{CUR_ENC} ) { $self->{CUR_ENC} = $1 if $self->SUPER::maketext('__Content-Type') =~ /\bcharset=\s*([-\w]+)/i; } $self->{CUR_ENC}; } sub maketext { my $self = shift; require Encode::compat if ($] == 5.006001); require Encode; Encode::encode($self->encoding, $self->SUPER::maketext(@_)); } 1; package T_L10N::en; use base qw(T_L10N); 1; package T_L10N::zh_tw; use base qw(T_L10N); 1; package T_L10N::zh_cn; use base qw(T_L10N); 1; Locale-Maketext-Lexicon-1.00/t/locale/en/000755 000765 000024 00000000000 12306052703 020723 5ustar00clintonstaff000000 000000 Locale-Maketext-Lexicon-1.00/t/locale/zh_CN/000755 000765 000024 00000000000 12306052703 021322 5ustar00clintonstaff000000 000000 Locale-Maketext-Lexicon-1.00/t/locale/zh_TW/000755 000765 000024 00000000000 12306052703 021354 5ustar00clintonstaff000000 000000 Locale-Maketext-Lexicon-1.00/t/locale/zh_TW/LC_MESSAGES/000755 000765 000024 00000000000 12306052703 023141 5ustar00clintonstaff000000 000000 Locale-Maketext-Lexicon-1.00/t/locale/zh_TW/LC_MESSAGES/test.mo000644 000765 000024 00000000707 12306052703 024461 0ustar00clintonstaff000000 000000 ,<P Q^_Hello, world!Project-Id-Version: test 1.0 POT-Creation-Date: 2003-04-24 21:52+0800 PO-Revision-Date: 2003-04-24 21:52+0800 Last-Translator: imacat Language-Team: Traditional Chinese MIME-Version: 1.0 Content-Type: text/plain; charset=Big5 Content-Transfer-Encoding: 8bit Plural-Forms: nplurals=1; plural=0; janCLocale-Maketext-Lexicon-1.00/t/locale/zh_TW/LC_MESSAGES/test_be.mo000644 000765 000024 00000000712 12306052703 025123 0ustar00clintonstaff000000 000000 ,<P Qa_Hello, world!Project-Id-Version: test_be 1.0 POT-Creation-Date: 2003-04-24 21:52+0800 PO-Revision-Date: 2003-04-24 21:52+0800 Last-Translator: imacat Language-Team: Traditional Chinese MIME-Version: 1.0 Content-Type: text/plain; charset=Big5 Content-Transfer-Encoding: 8bit Plural-Forms: nplurals=1; plural=0; janCLocale-Maketext-Lexicon-1.00/t/locale/zh_TW/LC_MESSAGES/test_utf8.mo000644 000765 000024 00000000721 12306052703 025423 0ustar00clintonstaff000000 000000 ,<P Qd_ Hello, world!Project-Id-Version: test_utf8 1.0 POT-Creation-Date: 2003-04-24 21:52+0800 PO-Revision-Date: 2003-04-24 21:52+0800 Last-Translator: imacat Language-Team: Traditional Chinese MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plural-Forms: nplurals=1; plural=0; 大家好。Locale-Maketext-Lexicon-1.00/t/locale/zh_CN/LC_MESSAGES/000755 000765 000024 00000000000 12306052703 023107 5ustar00clintonstaff000000 000000 Locale-Maketext-Lexicon-1.00/t/locale/zh_CN/LC_MESSAGES/test.mo000644 000765 000024 00000000711 12306052703 024422 0ustar00clintonstaff000000 000000 ,<P Q`_Hello, world!Project-Id-Version: test 1.0 POT-Creation-Date: 2003-04-24 21:52+0800 PO-Revision-Date: 2003-04-24 21:52+0800 Last-Translator: imacat Language-Team: Traditional Chinese MIME-Version: 1.0 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 8bit Plural-Forms: nplurals=1; plural=0; ҺáLocale-Maketext-Lexicon-1.00/t/locale/zh_CN/LC_MESSAGES/test_be.mo000644 000765 000024 00000000714 12306052703 025073 0ustar00clintonstaff000000 000000 ,<P Qc_Hello, world!Project-Id-Version: test_be 1.0 POT-Creation-Date: 2003-04-24 21:52+0800 PO-Revision-Date: 2003-04-24 21:52+0800 Last-Translator: imacat Language-Team: Traditional Chinese MIME-Version: 1.0 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 8bit Plural-Forms: nplurals=1; plural=0; ҺáLocale-Maketext-Lexicon-1.00/t/locale/zh_CN/LC_MESSAGES/test_utf8.mo000644 000765 000024 00000000721 12306052703 025371 0ustar00clintonstaff000000 000000 ,<P Qd_ Hello, world!Project-Id-Version: test_utf8 1.0 POT-Creation-Date: 2003-04-24 21:52+0800 PO-Revision-Date: 2003-04-24 21:52+0800 Last-Translator: imacat Language-Team: Traditional Chinese MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plural-Forms: nplurals=1; plural=0; 大家好。Locale-Maketext-Lexicon-1.00/t/locale/en/LC_MESSAGES/000755 000765 000024 00000000000 12306052703 022510 5ustar00clintonstaff000000 000000 Locale-Maketext-Lexicon-1.00/t/locale/en/LC_MESSAGES/test.mo000644 000765 000024 00000000676 12306052703 024035 0ustar00clintonstaff000000 000000 ,<P QV_Hello, world!Project-Id-Version: test 1.0 POT-Creation-Date: 2003-04-24 21:52+0800 PO-Revision-Date: 2003-04-24 21:52+0800 Last-Translator: imacat Language-Team: English MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit Plural-Forms: nplurals=1; plural=0; Hiya :)Locale-Maketext-Lexicon-1.00/t/locale/en/LC_MESSAGES/test_be.mo000644 000765 000024 00000000701 12306052703 024470 0ustar00clintonstaff000000 000000 ,<P QY_Hello, world!Project-Id-Version: test_be 1.0 POT-Creation-Date: 2003-04-24 21:52+0800 PO-Revision-Date: 2003-04-24 21:52+0800 Last-Translator: imacat Language-Team: English MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit Plural-Forms: nplurals=1; plural=0; Hiya :)Locale-Maketext-Lexicon-1.00/t/locale/en/LC_MESSAGES/test_utf8.mo000644 000765 000024 00000000700 12306052703 024767 0ustar00clintonstaff000000 000000 ,<P QX_Hello, world!Project-Id-Version: test_utf8 1.0 POT-Creation-Date: 2003-04-24 21:52+0800 PO-Revision-Date: 2003-04-24 21:52+0800 Last-Translator: imacat Language-Team: English MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plural-Forms: nplurals=1; plural=0; Hiya :)Locale-Maketext-Lexicon-1.00/t/lib/Myi18n/000755 000765 000024 00000000000 12306052703 020715 5ustar00clintonstaff000000 000000 Locale-Maketext-Lexicon-1.00/t/lib/Myi18n.pm000644 000765 000024 00000000253 12306052703 021253 0ustar00clintonstaff000000 000000 package Myi18n; use base 'Locale::Maketext'; use Locale::Maketext::Lexicon { 'en' => [ Gettext => 'en.po' ], _style => 'gettext', }; 1 Locale-Maketext-Lexicon-1.00/t/lib/Myi18n/en.po000644 000765 000024 00000000606 12306052703 021661 0ustar00clintonstaff000000 000000 msgid "" msgstr "" "Project-Id-Version: Test App 0.01\n" "POT-Creation-Date: 2008-08-01 14:20+0200\n" "PO-Revision-Date: 2008-08-01 14:21+0200\n" "Last-Translator: \n" "Language-Team: Italian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" msgid "Test relative langfiles" msgstr "Relative works!" Locale-Maketext-Lexicon-1.00/script/xgettext.pl000644 000765 000024 00000014641 12306052703 022342 0ustar00clintonstaff000000 000000 #!/usr/bin/perl use strict; use Locale::Maketext::Extract::Run 'xgettext'; if (@ARGV) { xgettext(@ARGV); } else { system(qq[perldoc "$0"]); } # PODNAME: xgettext.pl # ABSTRACT: Extract translatable strings from source __END__ =pod =encoding UTF-8 =head1 NAME xgettext.pl - Extract translatable strings from source =head1 VERSION version 1.00 =head1 SYNOPSIS B [I