Hi,
I create a small script which reads the error-detail.txt file and prints in stdout a .po file. I am attaching the script and an error-detail.txt file for testing.


This simple script reads records like the following from error-detail.txt file:
 name: X509_V_ERR_AKID_SKID_MISMATCH
 detail: "%ssl_error_descr: %ssl_subject"
 descr: "Authority and subject key identifier mismatch"

And produces the following output (it produces two records one for detail one for descr):
#: error-details.txt+X509_V_ERR_AKID_SKID_MISMATCH.detail:115
msgid  "%ssl_error_descr: %ssl_subject"
msgstr  "%ssl_error_descr: %ssl_subject"

#: error-details.txt+X509_V_ERR_AKID_SKID_MISMATCH.descr:115
msgid  "Authority and subject key identifier mismatch"
msgstr  "Authority and subject key identifier mismatch"


In the case the input record has multi-lined "detail" or "descr" fields like the following:

name: X509_V_ERR_KEYUSAGE_NO_CERTSIGN
detail: "%ssl_error_descr: %ssl_subject"
descr: "Key usage does not include
 certificate signing"

the script produces msgstr fields with "\n" character to represent newlines:

 #: error-details.txt+X509_V_ERR_KEYUSAGE_NO_CERTSIGN.detail:124
msgid  "%ssl_error_descr: %ssl_subject"
msgstr  "%ssl_error_descr: %ssl_subject"

#: error-details.txt+X509_V_ERR_KEYUSAGE_NO_CERTSIGN.descr:124
msgid  "Key usage does not include\n certificate signing"
msgstr  "Key usage does not include\n certificate signing"



From what I can understand a translator will use a program like the poedit to read the above output and produce a new file for a language. For example the error-details.txt.el.po file. My question is, how this new file will be converted to an error-detail.txt file? Do we need a new script which does the conversion from msgid/msgstr records to error-detail.txt records?

Regards,
   Christos


On 05/23/2011 02:50 PM, Amos Jeffries wrote:
On 23/05/11 19:43, Tsantilas Christos wrote:
On 05/22/2011 06:28 AM, Amos Jeffries wrote:


I believe It is easy to create a perl script which creates (or add
to an
existing) the above po file.

....
Christos:
I would like to ensure that we have a converter able to make this file
translatable before it goes too far though.

Is it important? I am trying to imagine possible translations in greek.
For most of the SSL errors details the translation will be more
confusing than helping.

Configuring the SSL error details messages has sense in cases where the
cache administrator wants to provide more comments or informations about
an error, for example "... this is mean ... so for your safety ... blah
blah blah"


It was the whole point of this feature I thought.

The raw detail is unfriendly in any language. The point of translation
is that non-English readers find the English version particularly bad to
understand.

We are free to re-phrase the jargon into something the users viewing it
are likely to understand for our distributed default.

Amos
#!/usr/bin/perl -w

use warnings;
use strict;

# This script read the error-details.txt error details template, and prints to the
# std output the  contents of a possible .po file.
#
# This file consist of records like the following:
#
#  name: X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT
#  detail: "SSL Certficate error: certificate issuer (CA) not known: %ssl_ca_name"
#  descr: "Unable to get issuer certificate"
#
# The records separated with an empty line.
# Comments starting with '#' supported.

my $File;
my $mode;

if (! ($File = shift @ARGV) ) {
    printf STDERR  "Usage: \n ".$0." error-detail-file\n\n";
    exit -1;
}

if (!open(IN, "<$File")) {
    printf STDERR "Can not open file %s\n", $File;
    exit -1;
}

my $lineNumber=0;
while(<IN>) {
    my($line) = $_;
    $lineNumber=$lineNumber+1;

    if ($line =~ /^\#.*/ ) {
#        print "Ignore comment: ".$line;
        next;
    }
    elsif ($line =~ /^\s*$/ ) {
#        print "Empty line!".$line;
        next;
    }
    my($rec) = "";
    my($lineOffset) = 0;
    do {
        $rec = $rec.$line;
        $line = <IN>;
        $lineOffset=$lineOffset+1;
    } while($line && $line !~ /^\s*$/);

    processRecord($rec, $lineNumber);
    $lineNumber= $lineNumber + $lineOffset;
}
exit(0);


sub processRecord
{
    my($rec, $lnumber) = @_;

#    print "Rec on $File:$lnumber:\n".$rec."--\n";
#    print "#: $File:$lnumber\n";
    my(@lines) = split /\n/, $rec;

    my($currentField) = "";
    my %currentRec;
    my $offset = 0;
    foreach (@lines) {
        my($l) = $_;
        if ($l =~ /^name:(.*)/) {
            $currentRec{"name"} = trim($1);
            $currentField = "name";
        }
        elsif ( $l =~ /^detail:(.*)/ ) {
            $currentRec{"detail"} = $1;
            $currentField = "detail";
        }
        elsif ($l =~ /^descr:(.*)/) {
            $currentRec{"descr"} = $1;
            $currentField = "descr";
        }
        elsif($l = ~ /^\s+(.*)/  && defined($currentRec{$currentField})) {
            $currentRec{$currentField}= $currentRec{$currentField}."\\n ".$1;
        }
    }
    print "#: $File+".$currentRec{"name"}.".detail:$lnumber\n";
    print    "msgid ".$currentRec{"detail"}."\n";
    print    "msgstr ".$currentRec{"detail"}."\n";
    print "\n";
    print "#: $File+".$currentRec{"name"}.".descr:$lnumber\n";
    print    "msgid ".$currentRec{"descr"}."\n";
    print    "msgstr ".$currentRec{"descr"}."\n";
    print "\n";
}

sub trim
{
    my $string = shift;
    $string =~ s/^\s+//;
    $string =~ s/\s+$//;
    return $string;
}
# a comment
name: X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT
detail: "SSL Certficate error: certificate issuer (CA) not known: %ssl_ca_name"
descr: "Unable to get issuer certificate"

#a second comment
name: X509_V_ERR_UNABLE_TO_GET_CRL
detail: "%ssl_error_descr: %ssl_subject"
descr: "Unable to get certificate CRL"

name: X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE
detail: "%ssl_error_descr: %ssl_subject"
descr: "Unable to decrypt certificate's signature"

name: X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE
detail: "%ssl_error_descr: %ssl_subject"
descr: "Unable to decrypt CRL's signature"

name: X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY
detail: "Unable to decode issuer (CA) public key: %ssl_ca_name"
descr: "Unable to decode issuer public key"

name: X509_V_ERR_CERT_SIGNATURE_FAILURE
detail: "%ssl_error_descr: %ssl_subject"
descr: "Certificate signature failure"

name: X509_V_ERR_CRL_SIGNATURE_FAILURE
detail: "%ssl_error_descr: %ssl_subject"
descr: "CRL signature failure"

name: X509_V_ERR_CERT_NOT_YET_VALID
detail: "SSL Certficate is not valid before: %ssl_notbefore"
descr: "Certificate is not yet valid"

name: X509_V_ERR_CERT_HAS_EXPIRED
detail: "SSL Certificate expired on: %ssl_notafter"
descr: "Certificate has expired"

name: X509_V_ERR_CRL_NOT_YET_VALID
detail: "%ssl_error_descr: %ssl_subject"
descr: "CRL is not yet valid"

name: X509_V_ERR_CRL_HAS_EXPIRED
detail: "%ssl_error_descr: %ssl_subject"
descr: "CRL has expired"

name: X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD
detail: "SSL Certificate has invalid start date (the 'not before' field): 
%ssl_subject"
descr: "Format error in certificate's notBefore field"

name: X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD
detail: "SSL Certificate has invalid expiration date (the 'not after' field): 
%ssl_subject"
descr: "Format error in certificate's notAfter field"

name: X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD
detail: "%ssl_error_descr: %ssl_subject"
descr: "Format error in CRL's lastUpdate field"

name: X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD
detail: "%ssl_error_descr: %ssl_subject"
descr: "Format error in CRL's nextUpdate field"

name: X509_V_ERR_OUT_OF_MEM
detail: "%ssl_error_descr"
descr: "Out of memory"

name: X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT
detail: "Self-signed SSL Certificate: %ssl_subject"
descr: "Self signed certificate"

name: X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN
detail: "Self-signed SSL Certificate in chain: %ssl_subject"
descr: "Self signed certificate in certificate chain"

name: X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY
detail: "SSL Certficate error: certificate issuer (CA) not known: %ssl_ca_name"
descr: "Unable to get local issuer certificate"

name: X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE
detail: "%ssl_error_descr: %ssl_subject"
descr: "Unable to verify the first certificate"

name: X509_V_ERR_CERT_CHAIN_TOO_LONG
detail: "%ssl_error_descr: %ssl_subject"
descr: "Certificate chain too long"

name: X509_V_ERR_CERT_REVOKED
detail: "%ssl_error_descr: %ssl_subject"
descr: "Certificate revoked"

name: X509_V_ERR_INVALID_CA
detail: "%ssl_error_descr: %ssl_ca_name"
descr: "Invalid CA certificate"

name: X509_V_ERR_PATH_LENGTH_EXCEEDED
detail: "%ssl_error_descr: %ssl_subject"
descr: "Path length constraint exceeded"

name: X509_V_ERR_INVALID_PURPOSE
detail: "%ssl_error_descr: %ssl_subject"
descr: "Unsupported certificate purpose"

name: X509_V_ERR_CERT_UNTRUSTED
detail: "%ssl_error_descr: %ssl_subject"
descr: "Certificate not trusted"

name: X509_V_ERR_CERT_REJECTED
detail: "%ssl_error_descr: %ssl_subject"
descr: "Certificate rejected"

name: X509_V_ERR_SUBJECT_ISSUER_MISMATCH
detail: "%ssl_error_descr: %ssl_ca_name"
descr: "Subject issuer mismatch"

name: X509_V_ERR_AKID_SKID_MISMATCH
detail: "%ssl_error_descr: %ssl_subject"
descr: "Authority and subject key identifier mismatch"

name: X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH
detail: "%ssl_error_descr: %ssl_ca_name"
descr: "Authority and issuer 
        serial number mismatch"

name: X509_V_ERR_KEYUSAGE_NO_CERTSIGN
detail: "%ssl_error_descr: %ssl_subject"
descr: "Key usage does not include
 certificate signing"

name: X509_V_ERR_APPLICATION_VERIFICATION
detail: "%ssl_error_descr: %ssl_subject"
descr: "Application verification failure"

Reply via email to