tir, 09 02 2010 kl. 23:49 +0100, skrev David Bateman:
> > The md5 check sums are generated with the command admin/octlang tag
> > FILENAME, where FILENAME is the name of the file (without extension).
> >
> > http://octave.sourceforge.net/translation.html
> >
> >
> But note that the script octlang works from a local copy of the
> docstrings of octave in the octave forge repository and someone has to
> keep those up to date as the MD5 tag that is generated is the MD5 tag of
> english version of the docstring. The above page explains this as well.
I'm having some troubles with replicating the work in an m-file. The
basic problem is that it is really hard to debug, when all you have is
an md5 checksum. I fear the reason why I can't make things work is that
a single space in the help text, can change the md5 checksum, but I have
no idea what is going on, when I can only look at the md5 checksum.
Anyway, I'm attaching the code I got so far in case anybody want to work
on this. It is a somewhat low priority for me at the moment, so I'd
appreciate any help.
Søren
## Copyright (C) 2010 Søren Hauberg
##
## 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; see the file COPYING. If not, see
## <http://www.gnu.org/licenses/>.
function [text, format] = get_localized_help_text (name, language)
## Check input
if (nargin != 2 || !ischar (name) || !ischar (language))
error ("get_localized_help_text: input must be two strings");
endif
## Constants
texinfo = "-*- texinfo -*-";
## Get original help text
[orig_text, orig_format] = get_help_text (name);
text = orig_text;
format = orig_format;
## Can we find the translation? (XXX: the path here is just a temporary hardcoded path)
translated_file = fullfile (language, "help", "octave", sprintf ("%s.%s", name, language));
if (exist (translated_file, "file"))
fid = fopen (translated_file, "r");
if (fid >= 0)
## Read translation
header = fgetl (fid);
trans_text = char (fread (fid, Inf, "char").');
fclose (fid);
## Determine format
if (strncmp (trans_text, texinfo, numel (texinfo)))
trans_format = "texinfo";
trans_text = trans_text (numel (texinfo)+2:end);
else
trans_format = "plain text";
endif
## Calculate md5 checksum and compare with header
try
## The header is valid Octave code that defines the variable 'md5'.
## We explicitly add a semi-colon to ensure no output is produced.
eval (strcat (header, ";"));
orig_md5 = md5sum (orig_text, true);
if (isequal (md5, orig_md5))
text = trans_text;
format = trans_format;
endif
catch
## Something went wrong with the header evaluation, so we treat the translation
## as being broken.
end_try_catch
endif
endif
endfunction
------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev