/*
* cook - file construction tool
* Copyright (C) 2002, 2007, 2008, 2010 Peter Miller
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
* .
*/
all,I =
[fromto %0%.y %0%.yacc.c,I [match_mask %0%.y [source_files]]]
[fromto %0%.c %0%.c,I [match_mask %0%.c [source_files]]]
;
common,I =
[fromto
common/%0%.c
common/%0%.c,I
[match_mask common/%0%.c [source_files]]
]
[fromto
common/%0%.y
common/%0%.yacc.c,I
[match_mask common/%0%.y [source_files]]
];
/*
* Translate the locatization files into their binary form. This will
* be different for each architecture and operating system (in theory,
* if not in practice).
*/
internationalization:
lib/common.ok
[fromto lib/%0%.po [arch]/lib/%0%.mo
[match_mask lib/%0%.po [source_files]]
]
[fromto lib/%0%.po lib/%0%.merge
[match_mask lib/%0%.po [source_files]]
]
LICENSE
;
lib/common.ok: lib/common.pot etc/zer-len-msg.sh
{
sh [resolve etc/zer-len-msg.sh lib/common.pot];
touch [target];
}
msgcomm = msgcomm;
lib/common.pot: [prepost "lib/" ".po" [commands]]
{
[msgcomm]
--force-po
--omit-header
--sort-output
--add-location
--indent
--width\=75
-o [target]
[prepost "--dir=" "" [search_list]]
[need];
}
msgmerge = msgmerge;
lib/%0%.merge: lib/%0%.po lib/%.po
{
[msgmerge]
--indent
--sort-output
--width\=75
-v -v
--no-location
--force-po
-o [target]
[resolve lib/%0%.po lib/%.po]
;
/*
* There should be no differences.
* If there are, this next command will show them.
*/
diff -b -u [resolve lib/%0%.po] [target];
/*
* we only need the timestamp
*/
> [target];
}
[arch]/lib/%0%.mo: lib/%0%.po: lib/%0common.po
etc/msgfmt.sh
set ['if' [not [defined baseline]] 'then' shallow]
{
/*
* This only works for GNU gettext (and Solaris).
* The SunOS msgfmt program does not grok the -o option.
*/
sh [resolve etc/msgfmt.sh]
--msgfmt\=[msgfmt]
--msgcat\=[msgcat]
--output\=[target]
[resolve lib/%0%.po lib/%0common.po]
;
}
xgettext = xgettext;
/*
* These files act as a "header files" to check the lib/%0%.po files
* against. There should not be any extras or omitions.
*/
lib/common.po: [all,I] [prepost "lib/en/LC_MESSAGES/" ".po" [commands]]
{
/*
* The author only speaks English, so the master translation is
* "en", hence lib/en/LC_MESSAGES/....po are the files intended.
*/
[xgettext]
--sort-output
--indent
--omit-header
--add-location
--force-po
--width\=75
-o [target]
[prepost "--dir=" "" [search_list]]
[prepost "--exclude-file=lib/en/LC_MESSAGES/" ".po" [commands]]
--language\=PO
[all,I];
}
lib/%.po: [%,I]: lib/en/LC_MESSAGES/common.po
{
/*
* The author only speaks English, so the master translation is
* "en", hence lib/en/LC_MESSAGES/common.po is the file
* intended.
*/
[xgettext]
--sort-output
--indent
--omit-header
--add-location
--force-po
-o [target]
[prepost "--dir=" "" [search_list]]
--exclude-file\=lib/en/LC_MESSAGES/common.po
--language\=PO
[%,I];
}
%0%.c,I: %0%.c
set no-cascade
{
[xgettext]
--sort-output
--indent
--omit-header
--force-po
--add-location
-o [target]
--msgstr-prefix\=
--msgstr-suffix\=
--keyword\=i18n
--keyword\=error_intl
--keyword\=fatal_intl
--keyword\=verbose_intl
--keyword\=subst_intl
--keyword\=fngrprnt_error
--keyword\=lex_error
--keyword\=lex_warning
[prepost "--dir=" "" [search_list]]
%0%.c;
}
/*
* This next file is for the benefit of the Translation Project's
* email robot. (Yes, that's right, a bloody robot.)
*
* See http://www.iro.umontreal.ca/contrib/po/HTML/maintainers.html
* for more information.
*
* I particularly dislike this approach, because it is incredibly
* short sighted. This approach fails to take into account that
* you may want to have translations of manual pages and other
* documentation, AS WELL AS translations of error messages.
*
* Would it make sense to ask authors to catenate all of
* ther man pages together, and have a po/PACKAGE.man file?
* No, of course not. Would it make sense to ask authors to
* catenate all of their other documentation together, and
* have a po/PACKAGE.latex file? No, of course not. Well then,
* why on Earth does it make sense to catenate together all of
* the messages into a po/PACKAGE.pot file? Betch.
*
* And then, to add insult to injury, it wastes space in the tarball.
*
* My project uses a directory tree
* lib/
* /
* LC_MESSAGES/
* all of the various .po files go here
* man/
* all of the man pages go here
* user-guide/
* all of the files which make the
* user guide go here.
* /
* and so on...
*
* As you can see, this can accomodate translated .po files,
* AND ALSO any other documentation, once it is translated.
*/
po/[project_short].pot: [match_mask lib/en/LC_MESSAGES/%.po [source_files]]
{
msgcat
--use-first
--indent
--sort-output
--width\=75
-o [target]
[resolve
/*
* Put common.po at the start, it has an informative
* comment at the beginning (which gets bound to
* "", and is subject a the --use-first clause).
*/
lib/en/LC_MESSAGES/common.po
[stringset
[need]
-
lib/en/LC_MESSAGES/common.po
]
];
}