/[suikacvs]/test/html-webhacc/mkcatalog.pl
Suika

Contents of /test/html-webhacc/mkcatalog.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Mon Jul 21 12:56:34 2008 UTC (15 years, 9 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +22 -3 lines
File MIME type: text/plain
++ ChangeLog	21 Jul 2008 12:51:50 -0000
	* .htaccess: error-description-source.xml is in UTF-8
	actually.

	* Makefile: Rule to make Japanese language catalog file
	is added.

	* cc-script.js: Line and column numbers are now taken
	from data-* attributes, not from textContent.

	* cc.cgi: Tentative support for Japanese/English conneg.
	(load_text_catalog, get_text): Removed (catalog text selection
	is now handled by WebHACC::Output).

	* error-description-source.xml: Catalog entries in new
	format are added.  Old catalog element is removed.

	* mkcatalog.pl: Support for non-English languages.
	Drop support for old catalog element.  Add support
	for new cat element.

	* mkdescription.pl: Drop support for old catalog element.
	Add support for new cat element.

2008-07-21  Wakaba  <wakaba@suika.fam.cx>

++ html/WebHACC/Language/ChangeLog	21 Jul 2008 12:56:30 -0000
	* DOM.pm (generate_structure_dump_section): Use catalog
	for human-readable texts.
	(generate_table_section): Use catalog for human readable texts.

2008-07-21  Wakaba  <wakaba@suika.fam.cx>

++ html/WebHACC/ChangeLog	21 Jul 2008 12:55:41 -0000
	* Input.pm: Most human-readable texts are now handled by
	catalog.
	(id_prefix): Support for nested subdocuments.

	* Output.pm (start_section, dt, xref): Section/item names and
	link labels are now handled by catalog.
	(load_text_catalog, nl_text): New methods.
	(html_header): Application name is moved to catalog.

	* Result.pm (add_error): Important error properties are
	now exposed to client-side script as data-* attributes.
	Labels are now handled by catalog.  Error descriptions
	are now taken from catalog as it were.

2008-07-21  Wakaba  <wakaba@suika.fam.cx>

1 #!/usr/bin/perl
2 use strict;
3 use encoding 'us-ascii', STDOUT => 'utf-8';
4
5 use lib qw[/home/httpd/html/www/markup/html/whatpm
6 /home/wakaba/work/manakai2/lib];
7
8 my $HTML_NS = q<http://www.w3.org/1999/xhtml>;
9 my $SRC_NS = q<http://suika.fam.cx/~wakaba/archive/2007/wdcc-desc/>;
10 my $XML_NS = q<http://www.w3.org/XML/1998/namespace>;
11
12 require Message::DOM::DOMImplementation;
13 my $dom = Message::DOM::DOMImplementation->new;
14
15 my $doc;
16 {
17 my $source_file_name = shift or die "$0: No source file specified\n";
18 open my $source_file, '<', $source_file_name
19 or die "$0: $source_file_name: $!";
20 require Message::DOM::XMLParserTemp;
21 $doc = Message::DOM::XMLParserTemp->parse_byte_stream
22 ($source_file => $dom, undef, charset => 'utf-8');
23 $doc->manakai_is_html (1);
24 }
25
26 my $target_lang = shift || 'en';
27 my @node = (@{$doc->child_nodes});
28 while (@node) {
29 my $node = shift @node;
30 if ($node->node_type == $node->ELEMENT_NODE) {
31 if ($node->namespace_uri eq $HTML_NS) {
32 unshift @node, @{$node->child_nodes};
33 } elsif ($node->namespace_uri eq $SRC_NS) {
34 if ($node->manakai_local_name eq 'item') {
35 my $message;
36 for (@{$node->child_nodes}) {
37 if ($_->node_type == $_->ELEMENT_NODE and
38 $_->namespace_uri eq $SRC_NS) {
39 if ($_->manakai_local_name eq 'message') {
40 if ($_->get_attribute_ns ($XML_NS, 'lang') eq $target_lang) {
41 $message = $_;
42 next;
43 } else {
44 $message ||= $_;
45 }
46 }
47 }
48 }
49
50 my $entry = [];
51 push @$entry, $node->get_attribute_ns (undef, 'name');
52 my $level = $node->get_attribute_ns (undef, 'level');
53 $entry->[-1] = $level . ':' . $entry->[-1] if defined $level;
54 push @$entry, $node->get_attribute_ns (undef, 'class');
55 push @$entry, $message->inner_html;
56 s/\s+/ /g for @$entry;
57 print join ';', @$entry;
58 print "\n";
59 } elsif ($node->manakai_local_name eq 'cat') {
60 my $name = $node->get_attribute_ns (undef, 'name');
61 my $text;
62 for my $el (@{$node->child_nodes}) {
63 next unless $el->node_type == $el->ELEMENT_NODE;
64 next unless $el->manakai_local_name eq 'text';
65 my $ns = $el->namespace_uri;
66 next unless defined $ns and $ns eq $SRC_NS;
67
68 my $lang = $el->get_attribute_ns ($XML_NS, 'lang');
69 $text = $el->inner_html;
70 if ($lang eq $target_lang) {
71 last;
72 }
73 }
74 if (defined $text) {
75 my $entry = [$name, undef, $text];
76 s/\s+/ /g for @$entry;
77 print join ';', @$entry;
78 print "\n";
79 }
80 } else {
81 warn "$0: ", $node->manakai_local_name, " is not supported\n";
82 }
83 }
84 }
85 }

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24