1# Locale::Po4a::Chooser -- Manage po4a modules 2# 3# This program is free software; you may redistribute it and/or modify it 4# under the terms of GPL (see COPYING). 5# 6# This module converts POD to PO file, so that it becomes possible to 7# translate POD formatted documentation. See gettext documentation for 8# more info about PO files. 9 10############################################################################ 11# Modules and declarations 12############################################################################ 13 14package Locale::Po4a::Chooser; 15 16use 5.006; 17use strict; 18use warnings; 19use Locale::Po4a::Common; 20 21sub new { 22 my ($module) = shift; 23 my (%options) = @_; 24 25 die wrap_mod( "po4a::chooser", gettext("Please provide a module name") ) 26 unless defined $module; 27 28 my $modname; 29 if ( $module eq 'kernelhelp' ) { 30 $modname = 'KernelHelp'; 31 } elsif ( $module eq 'newsdebian' ) { 32 $modname = 'NewsDebian'; 33 } elsif ( $module eq 'latex' ) { 34 $modname = 'LaTeX'; 35 } elsif ( $module eq 'bibtex' ) { 36 $modname = 'BibTex'; 37 } elsif ( $module eq 'tex' ) { 38 $modname = 'TeX'; 39 } elsif ( $module eq 'asciidoc' ) { 40 $modname = 'AsciiDoc'; 41 } elsif ( $module eq 'Rd' || $module eq 'rubydoc' ) { 42 $modname = 'RubyDoc'; 43 } else { 44 $modname = ucfirst($module); 45 } 46 if ( !UNIVERSAL::can( "Locale::Po4a::$modname", 'new' ) ) { 47 eval qq{use Locale::Po4a::$modname}; 48 if ($@) { 49 my $error = $@; 50 warn wrap_msg( gettext("Unknown format type: %s."), $module ); 51 warn wrap_mod( "po4a::chooser", gettext("Module loading error: %s"), $error ) 52 unless defined $options{'quiet'}; 53 list(1); 54 } 55 } 56 return "Locale::Po4a::$modname"->new(%options); 57} 58 59sub list { 60 warn wrap_msg( 61 gettext("List of valid formats:") 62 63 # ."\n - ".gettext("bibtex: BibTex bibliography format.") 64 . "\n - " 65 . gettext("asciidoc: AsciiDoc format.") 66 . "\n - " 67 . gettext("dia: uncompressed Dia diagrams.") 68 . "\n - " 69 . gettext("docbook: DocBook XML.") 70 . "\n - " 71 . gettext("guide: Gentoo Linux's XML documentation format.") 72 . "\n - " 73 . gettext("ini: INI format.") 74 . "\n - " 75 . gettext("kernelhelp: Help messages of each kernel compilation option.") 76 . "\n - " 77 . gettext("latex: LaTeX format.") 78 . "\n - " 79 . gettext("man: Good old manual page format.") 80 . "\n - " 81 . gettext("pod: Perl Online Documentation format.") 82 . "\n - " 83 . gettext("rubydoc: Ruby Documentation (RD) format.") 84 . "\n - " 85 . gettext("sgml: either DebianDoc or DocBook DTD.") 86 . "\n - " 87 . gettext("texinfo: The info page format.") 88 . "\n - " 89 . gettext("tex: generic TeX documents (see also latex).") 90 . "\n - " 91 . gettext("text: simple text document.") 92 . "\n - " 93 . gettext("wml: WML documents.") 94 . "\n - " 95 . gettext("xhtml: XHTML documents.") 96 . "\n - " 97 . gettext("xml: generic XML documents (see also docbook).") 98 . "\n - " 99 . gettext("yaml: YAML documents.") 100 ); 101 exit shift; 102} 103############################################################################## 104# Module return value and documentation 105############################################################################## 106 1071; 108__END__ 109 110=encoding UTF-8 111 112=head1 NAME 113 114Locale::Po4a::Chooser - manage po4a modules 115 116=head1 DESCRIPTION 117 118Locale::Po4a::Chooser is a module to manage po4a modules. Previously, all po4a 119binaries used to know all po4a modules (pod, man, sgml, etc). This made the 120addition of a new module boring, because you had to make sure that the documentation is synchronized 121in all modules, and that each of them can access the new module. 122 123Now, you just have to call the Locale::Po4a::Chooser::new() function, 124passing the name of module as argument. 125 126The function Locale::Po4a::Chooser::list() lists the available 127formats, and exits with the value passed as argument. So, we call 128Locale::Po4a::Chooser::list(0) when requested for the list of 129formats, and Locale::Po4a::Chooser::list(1) when passed an invalid 130format name. 131 132=head1 SEE ALSO 133 134=over 4 135 136=item About po4a: 137 138L<Locale::Po4a::Po(3pm)>, 139L<Locale::Po4a::TransTractor(3pm)>, 140L<po4a(7)|po4a.7> 141 142=item About modules: 143 144L<Locale::Po4a::Dia(3pm)>, 145L<Locale::Po4a::Docbook(3pm)>, 146L<Locale::Po4a::Guide(3pm)>, 147L<Locale::Po4a::Halibut(3pm)>, 148L<Locale::Po4a::Ini(3pm)>, 149L<Locale::Po4a::KernelHelp(3pm)>, 150L<Locale::Po4a::LaTeX(3pm)>, 151L<Locale::Po4a::Man(3pm)>, 152L<Locale::Po4a::Pod(3pm)>, 153L<Locale::Po4a::RubyDoc(3pm)>, 154L<Locale::Po4a::Sgml(3pm)>, 155L<Locale::Po4a::TeX(3pm)>, 156L<Locale::Po4a::Texinfo(3pm)>, 157L<Locale::Po4a::Text(3pm)>, 158L<Locale::Po4a::Wml(3pm)>. 159L<Locale::Po4a::Xhtml(3pm)>, 160L<Locale::Po4a::Xml(3pm)>, 161L<Locale::Po4a::Wml(3pm)>, 162L<Locale::Po4a::Yaml(3pm)>. 163 164=back 165 166=head1 AUTHORS 167 168 Denis Barbier <barbier@linuxfr.org> 169 Martin Quinson (mquinson#debian.org) 170 171=head1 COPYRIGHT AND LICENSE 172 173Copyright © 2002-2005, 2014, 2017 SPI, Inc. 174 175This program is free software; you may redistribute it and/or modify it 176under the terms of GPL (see the COPYING file). 177 178=cut 179