web: German translation of donate.org and i18n procdonate.cgi
authorWerner Koch <wk@gnupg.org>
Sun, 14 May 2017 10:36:40 +0000 (12:36 +0200)
committerWerner Koch <wk@gnupg.org>
Sun, 14 May 2017 10:36:40 +0000 (12:36 +0200)
cgi/procdonate.cgi
web/donate/checkout-cc.org
web/donate/donate.de.org [new file with mode: 0644]

index bd1d061..8e272b7 100755 (executable)
@@ -33,6 +33,7 @@ my $q  = new CGI;
 # This is a multi-purpose CGI.  The mode decides what to do.
 my $mode = $q->param("mode");
 my $sessid = $q->param("sessid");
+my $lang = $q->param("lang");
 
 # Variables used in the template pages.
 my $amount = "";
@@ -69,6 +70,7 @@ sub complete_sepa ();
 sub write_template ($) {
     my $fname = shift;
 
+    my $tname;
     my $errorpanel = $errorstr;
     my $err_amount = '';
     my $err_name = '';
@@ -97,8 +99,9 @@ sub write_template ($) {
     my $publishname;
     my $check_paytype = 'none';
     my $stripe_data_email = '';
-    my $stripe_data_label_value = 'Make one-time donation';
+    my $stripe_data_label_value;
     my $xamount;
+    my $stripelocale;
 
     # Avoid broken HTML attributes.
     $amount =~ s/\x22/\x27/g;
@@ -123,6 +126,10 @@ sub write_template ($) {
 
     # No need to clean $euroamount.
 
+    # Check whether a translated template is available.
+    $tname = $htdocs . $fname;
+    $tname =~ s/\.html$/.$lang.html/;
+    if ( not -f $tname ) { $tname = $htdocs . $fname; }
 
     # Create a formatted message.
     $message_fmt = $message;
@@ -177,18 +184,59 @@ sub write_template ($) {
         $stripe_data_email = '';
         $recur_none    = ' selected="selected"';
         $recur_text    = '';
+
+        if ($lang eq 'de') {
+            $stripe_data_label_value = 'Einmalig spenden';
+        } elsif ($lang eq 'ja') {
+            $stripe_data_label_value = 'Make one-time donation';
+        } else {
+            $stripe_data_label_value = 'Make one-time donation';
+        }
+
     } elsif ( $recur =~ /12/ ) {
         $recur_month   = ' selected="selected"';
-        $recur_text    = 'monthly';
-        $stripe_data_label_value = 'Donate monthly';
+
+        if ($lang eq 'de') {
+            $recur_text    = 'monatlich';
+            $stripe_data_label_value = 'Monatlich spenden';
+        } elsif ($lang eq 'ja') {
+            $recur_text    = 'monthly';
+            $stripe_data_label_value = 'Donate monthly';
+        } else {
+            $recur_text    = 'monthly';
+            $stripe_data_label_value = 'Donate monthly';
+        }
+
     } elsif ( $recur =~ /4/ ) {
         $recur_quarter = ' selected="selected"';
-        $recur_text    = 'quarterly';
-        $stripe_data_label_value = 'Donate quarterly';
+
+        if ($lang eq 'de') {
+            $recur_text    = 'vierteljährlich';
+            $stripe_data_label_value = 'Vierteljährlich spenden';
+        } elsif ($lang eq 'ja') {
+            $recur_text    = 'quarterly';
+            $stripe_data_label_value = 'Donate quarterly';
+        } else {
+            $recur_text    = 'quarterly';
+            $stripe_data_label_value = 'Donate quarterly';
+        }
+
     } elsif ( $recur =~ /1/ ) {
         $recur_year    = ' selected="selected"';
-        $recur_text    = 'yearly';
-        $stripe_data_label_value = 'Donate yearly';
+
+        if ($lang eq 'de') {
+            $recur_text    = 'jährlich';
+            $stripe_data_label_value = 'Jährlich spenden';
+        } elsif ($lang eq 'ja') {
+            $recur_text    = 'yearly';
+            $stripe_data_label_value = 'Donate yearly';
+        } else {
+            $recur_text    = 'yearly';
+            $stripe_data_label_value = 'Donate yearly';
+        }
+
+    } else { # invalid
+        $stripe_data_label_value = '';
     }
 
     if ( $paytype eq "cc" ) {
@@ -206,15 +254,30 @@ sub write_template ($) {
         $publishname = 'Yes';
     }
 
+
+
+    # Set a specific locale.
+    if ($lang eq 'de')    { $stripelocale = "de"; }
+    elsif ($lang eq 'ja') { $stripelocale = "ja"; }
+    elsif ($lang eq 'en') { $stripelocale = "en"; }
+    else                  { $stripelocale = "auto"; }
+
+
     # Build error strings.
     foreach (keys %errdict)
     {
+        my $fieldname;
+
+        if ($lang eq 'de')    { $fieldname = "Feld $_: ";  }
+        elsif ($lang eq 'ja') { $fieldname = "Field $_: "; }
+        else                  { $fieldname = "Field $_: "; }
+
         if    (/amount/) { $err_amount = $error_marker; }
         elsif (/name/)   { $err_name   = $error_marker; }
         elsif (/mail/)   { $err_mail   = $error_marker; }
         elsif (/paytype/){ $err_paytype = $error_marker; }
 
-        $errorpanel = $errorpanel . "Field $_: " . $errdict{$_} . "<br/>\n"
+        $errorpanel = $errorpanel . $fieldname . $errdict{$_} . "<br/>\n"
     }
     if ( $errorpanel ne '' )
     {
@@ -223,7 +286,7 @@ sub write_template ($) {
     }
 
 
-    open TEMPLATE, $htdocs . $fname;
+    open TEMPLATE, $tname;
     while (<TEMPLATE>) {
         if ( /<!--/ )
         {
@@ -235,6 +298,7 @@ sub write_template ($) {
         || s/(\x22\x2f>)?<!--AMT_OTHER-->/$amt_other\1/
         || s/(\x22\x2f>)?<!--EUROAMOUNT-->/$euroamount\1/
         || s/(\x22\x2f>)?<!--STRIPEPUBKEY-->/$stripepubkey\1/
+        || s/(\x22\x2f>)?<!--STRIPELOCALE-->/$stripelocale\1/
         || s/(\x22\x2f>)?<!--STRIPEAMOUNT-->/$stripeamount\1/
         || s/(\x22\x2f>)?<!--CURRENCY-->/$currency\1/
         || s/(\x22\x2f>)?<!--NAME-->/$name\1/
@@ -426,6 +490,7 @@ sub check_donation ()
     my %data;
     my %sepa;
     my $anyerr = 0;
+    my $msg;
 
     $amount = $q->param("amount");
     if ($amount eq 'other') {
@@ -460,16 +525,40 @@ sub check_donation ()
     # processing fees and our own costs for bookkeeping we need to ask
     # for a minimum amount.
     if ( (not $anyerr) and ($euroamount < 4.00) ) {
-        $errdict{"amount"} = 'Sorry, due to overhead costs we do' .
-                             ' not accept donations of less than 4 Euro.';
+
+        if ($lang eq 'de') {
+            $msg= 'Um unsere Verwaltungskosten niedrig zu halten,'
+                . 'können wir leider Spenden unter 4 Euro annehmen.';
+        } elsif ($lang eq 'ja') {
+            $msg = 'Sorry, due to overhead costs we do'
+                . ' not accept donations of less than 4 Euro.';
+        }
+        else {
+            $msg = 'Sorry, due to overhead costs we do'
+                . ' not accept donations of less than 4 Euro.';
+        }
+
+        $errdict{"amount"} = $msg;
         $anyerr = 1;
     }
 
     # Check the payment type
     $paytype = $q->param("paytype");
     if ( $paytype ne "cc" and $paytype ne "pp" and $paytype ne "se" ) {
-        $errdict{"paytype"} = 'No payment type selected.' .
-                              ' Use "Credit Card", "PayPal", or "SEPA".';
+
+        if ($lang eq 'de') {
+            $msg= 'Keine Zahlungsart angegeben.'
+                . ' Bitte "Kreditkarte", "PayPal" oder "SEPA" auswählen.';
+        } elsif ($lang eq 'ja') {
+            $msg= 'No payment type selected.'
+                . ' Use "Credit Card", "PayPal", or "SEPA".';
+        }
+        else {
+            $msg= 'No payment type selected.'
+                . ' Use "Credit Card", "PayPal", or "SEPA".';
+        }
+
+        $errdict{"paytype"} = $msg;
         $anyerr = 1;
     }
 
@@ -575,16 +664,53 @@ sub complete_stripe_checkout ()
     # Print thanks
     $recur = $stripe{"Recur"};
     if ( $recur =~ /12/ ) {
-        $recur_text    = 'Monthly';
+        if ($lang eq 'de')    { $recur_text = 'monatlich'; }
+        elsif ($lang eq 'ja') { $recur_text = 'Monthly'; }
+        else                  { $recur_text = 'Monthly'; }
     } elsif ( $recur =~ /4/ ) {
-        $recur_text    = 'Quarterly';
+        if ($lang eq 'de')    { $recur_text = 'vierteljährlich'; }
+        elsif ($lang eq 'ja') { $recur_text = 'Quarterly'; }
+        else                  { $recur_text = 'Quarterly'; }
     } elsif ( $recur =~ /1/ ) {
-        $recur_text    = 'Yearly';
+        if ($lang eq 'de')    { $recur_text = 'jährlich'; }
+        elsif ($lang eq 'ja') { $recur_text = 'Yearly'; }
+        else                  { $recur_text = 'Yearly'; }
     } else {
-        $recur_text    = 'Just once';
-    }
-
-    $message = <<EOF;
+        if ($lang eq 'de')    { $recur_text = 'nein'; }
+        elsif ($lang eq 'ja') { $recur_text = 'Just once'; }
+        else                  { $recur_text = 'Just once'; }
+    }
+
+    if ($lang eq 'de') {
+        $message = <<EOF;
+Betrag ......: $stripe{"Amount"} $stripe{"Currency"}
+Dauerauftrag : $recur_text
+Beschreibung : $stripe{"Desc"}
+Kartennr. ...: *$stripe{"Last4"}
+Dienstleister: Stripe
+Charge-Id ...: $stripe{"Charge-Id"}
+Zeitstempel .: $stripe{"_timestamp"}
+Email .......: $stripe{"Email"}
+EOF
+        if ($stripe{"account-id"} ne '') {
+            $message = $message . "Spender-ID ..: " . $stripe{"account-id"};
+        }
+    } elsif ($lang eq 'ja') {
+        $message = <<EOF;
+Amount ....: $stripe{"Amount"} $stripe{"Currency"}
+Recurring .: $recur_text
+Desc ......: $stripe{"Desc"}
+Cardno.....: *$stripe{"Last4"}
+Processor .: Stripe
+Charge-Id .: $stripe{"Charge-Id"}
+Timestamp .: $stripe{"_timestamp"}
+Email .....: $stripe{"Email"}
+EOF
+        if ($stripe{"account-id"} ne '') {
+            $message = $message . "Account-Id : " . $stripe{"account-id"};
+        }
+    } else {
+         $message = <<EOF;
 Amount ....: $stripe{"Amount"} $stripe{"Currency"}
 Recurring .: $recur_text
 Desc ......: $stripe{"Desc"}
@@ -594,9 +720,11 @@ Charge-Id .: $stripe{"Charge-Id"}
 Timestamp .: $stripe{"_timestamp"}
 Email .....: $stripe{"Email"}
 EOF
-    if ($stripe{"account-id"} ne '') {
-        $message = $message . "Account-Id : " . $stripe{"account-id"};
+        if ($stripe{"account-id"} ne '') {
+            $message = $message . "Account-Id : " . $stripe{"account-id"};
+        }
     }
+
     if ($stripe{"Live"} eq 'f') {
         $message = $message . "\n!!! TEST TRANSACTION !!!";
     }
index c2809eb..c81f577 100644 (file)
@@ -66,6 +66,7 @@ Information on your intended donation:
         data-image="/share/gnupg-badge-128x128.png"
         data-name="GnuPG"
         data-description="Donation to the GnuPG project"
+        data-locale="<!--STRIPELOCALE-->"
         data-amount="<!--STRIPEAMOUNT-->"
         data-currency="<!--CURRENCY-->"
         data-panel-label="Donate {{amount}} <!--RECUR_TEXT-->"
diff --git a/web/donate/donate.de.org b/web/donate/donate.de.org
new file mode 100644 (file)
index 0000000..9ba501b
--- /dev/null
@@ -0,0 +1,246 @@
+#+TITLE: GnuPG - Spenden
+#+STARTUP: showall
+#+SETUPFILE: "../share/setup.inc"
+#
+# Note: Do not use relative links because this page is also used as a
+#       template from cgi-bin/.  Using https://www.gnupg.org/... is
+#       fine as it is stripped before publishing.
+
+#+BEGIN_HTML
+<!--custom-page-->  <!-- this disables all standard processing. -->
+       <!-- bootstrap core and site css -->
+       <link href="/share/3rdparty/bootstrap/bootstrap-gnupg.css" rel="stylesheet">
+       <link href="/share/campaign/campaign.css" rel="stylesheet">
+
+       <script defer src="/share/3rdparty/jquery/jquery.min.js"></script>
+       <script defer src="/share/3rdparty/bootstrap/bootstrap.min.js"></script>
+       <script defer src="/share/3rdparty/bootstrap/carousel.js"></script>
+       <script defer src="/share/3rdparty/bs-autohidingnavbar.js"></script>
+       <script defer src="/share/3rdparty/bcswipe.js"></script>
+       <script defer src="/share/campaign/campaign.js"></script>
+
+</head>
+<body lang="de">
+  <!-- Fixed navbar -->
+  <nav class="navbar navbar-default navbar-fixed-top">
+    <div class="container">
+
+      <div class="navbar-header">
+        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
+          <span class="sr-only">Toggle navigation</span>
+          <span class="icon-bar"></span>
+          <span class="icon-bar"></span>
+          <span class="icon-bar"></span>
+        </button>
+        <img class="navbar-brand" alt="GnuPG" src="/share/gnupg-lock-white-250x250.png">
+      </div>
+
+      <div id="navbar" class="navbar-collapse collapse">
+        <ul class="nav navbar-nav">
+          <li><a href="/donate">Back</a></li>
+        </ul>
+      </div><!--/.nav-collapse -->
+    </div>
+  </nav>
+
+  <div class="camp-gutter container">
+    <div class="row">
+      <div class="col-md-8 col-md-offset-2">
+        <h1>Support GnuPG</h1>
+        <p>To process your donation we need to collect some information. This information is only used for the purpose of the donation and no data will ever be send to any entity not directly involved in the donation process. Not giving a name makes the donation “anonymous” in that the name won’t be listed on the public thank you page.</p>
+        <p>You can also send us <b>Bitcoin</b>. Our address is <a href="bitcoin:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"><small><tt>xxxxxxxxxxxxxxxxx&shy;xxxxxxxxxxxxxxxxx</tt></small></a>.</p>
+      </div>
+    </div>
+
+               <div class="row">
+                       <div class="col-md-8 col-md-offset-2">
+                               <!--ERRORPANEL-->
+                       </div>
+               </div>
+
+
+    <form class="form-horizontal" role="form"
+          action="/cgi-bin/procdonate.cgi" method="POST">
+      <input type="hidden" name="mode" value="main">
+      <input type="hidden" name="lang" value="de">
+
+      <!-- Predefined amounts -->
+      <div class="form-group">
+        <label for="inputType" class="col-md-2 control-label">
+                                       Betrag <!--ERR_AMOUNT-->
+                               </label>
+        <div class="col-md-6">
+          <label class="radio-inline">
+            <input type="radio" name="amount" id="amount500"
+                   value="500" /><!--CHK_AMT500--> 500&thinsp;€
+          </label>
+
+          <label class="radio-inline">
+            <input type="radio" name="amount" id="amount200"
+                   value="200" /><!--CHK_AMT200--> 200&thinsp;€
+          </label>
+
+          <label class="radio-inline">
+            <input type="radio" name="amount" id="amount100"
+                   value="100" /><!--CHK_AMT100--> 100&thinsp;€
+          </label>
+
+          <label class="radio-inline">
+            <input type="radio" name="amount" id="amount50"
+                   value="50" /><!--CHK_AMT50--> 50&thinsp;€
+          </label>
+
+          <label class="radio-inline">
+            <input type="radio" name="amount" id="amount20"
+                   value="20" /><!--CHK_AMT20--> 20&thinsp;€
+          </label>
+
+          <label class="radio-inline">
+            <input type="radio" name="amount" id="amount10"
+                   value="10" /><!--CHK_AMT10--> 10&thinsp;€
+          </label>
+
+          <label class="radio-inline">
+            <input type="radio" name="amount" id="amount5"
+                   value="5" /><!--CHK_AMT5--> 5&thinsp;€
+          </label>
+        </div>
+      </div>
+
+      <!-- Custom amounts -->
+      <div class="form-group">
+        <div class="col-md-offset-2 col-md-6">
+          <div class="form-group row">
+            <div class="col-md-2">
+              <div class="radio">
+                <label for="amount_radio_other">
+                  <input type="radio" id="amount_radio_other" name="amount"
+                         value="other" /><!--CHK_AMTX-->
+                  other
+                </label>
+              </div>
+            </div>
+            <div class="col-md-4">
+              <input type="text" class="form-control"
+                     name="amountother" id="amountother" placeholder=""
+                     value=""/><!--AMT_OTHER-->
+                                               </div>
+            <div class="col-md-4">
+              <select class="form-control" name="currency" id="currency">
+                <option value="EUR" selected="selected"><!--SEL_EUR-->Euro</option>
+                <option value="USD" ><!--SEL_USD-->US Dollar</option>
+                <option value="GBP" ><!--SEL_GBP-->British Pound</option>
+                <option value="JPY" ><!--SEL_JPY-->Yen</option>
+              </select>
+            </div>
+          </div>
+          <span class="help-block">Choosing “other” allows to donate
+                in other currencies.</span>
+        </div>
+      </div>
+
+      <!-- Recurring -->
+      <div class="form-group">
+        <label for="recur" class="col-md-2 control-label">Dauerauftrag</label>
+        <div class="col-md-2">
+          <select class="form-control" name="recur">
+            <option value="0"
+            selected="selected"><!--RECUR_NONE-->neun</option>
+            <option value="12" ><!--RECUR_MONTH-->monatlich</option>
+            <option value="4" ><!--RECUR_QUARTER-->vierteljährlich</option>
+            <option value="1" ><!--RECUR_YEAR-->jährlich</option>
+          </select>
+        </div>
+      </div>
+
+      <!-- Pay using -->
+      <div class="form-group">
+        <label for="paytype" class="col-md-2 control-label">
+                                       Pay using <!--ERR_PAYTYPE-->
+                               </label>
+        <div class="col-md-6">
+          <div class="radio">
+            <label>
+              <input type="radio" name="paytype" id="cc"
+                     value="cc" /><!--CHECK_CC-->
+              Kreditkarte
+            </label>
+          </div>
+          <div class="radio">
+            <label>
+              <input type="radio" name="paytype" id="pp"
+                     value="pp" /><!--CHECK_PP-->
+              PayPal
+            </label>
+          </div>
+          <div class="radio">
+            <label>
+              <input type="radio" name="paytype" id="se"
+                     value="se" /><!--CHECK_SE-->
+              Überweisung
+            </label>
+          </div>
+        </div>
+      </div>
+
+      <!-- Name -->
+      <div class="form-group">
+        <label for="name" class="col-md-2 control-label">
+          Name <!--ERR_NAME-->
+          <p class="text-muted"><small>(optional)</small></p>
+        </label>
+        <div class="col-md-6">
+          <input type="text" class="form-control" name="name"
+                 id="f_name" placeholder="Name (optional)"
+                 value=""/><!--NAME-->
+          <span class="help-block">
+            If you want to be listed on the
+             <a href="https://www.gnupg.org/donate/kudos.html"
+                >list of donors</a>, please enter your name as
+             it shall appear there.
+          </span>
+        </div>
+      </div>
+
+      <!-- Email -->
+      <div class="form-group">
+        <label for="mail" class="col-md-2 control-label">
+          Email <!--ERR_MAIL-->
+          <p class="text-muted"><small>(optional)</small></p>
+        </label>
+        <div class="col-md-6">
+          <input type="email" class="form-control" name="mail"
+                 id="f_mail" placeholder="Email (optional)"
+                 value=""/><!--MAIL-->
+          <span class="help-block">
+            In case of payment problems we may want to contact you,
+            thus please enter your e-mail address.
+          </span>
+        </div>
+      </div>
+
+      <!-- Message -->
+      <div class="form-group">
+        <label for="message" class="col-md-2 control-label">
+          Message
+          <p class="text-muted"><small>(optional)</small></p>
+        </label>
+        <div class="col-md-6">
+          <textarea class="form-control" name="message" id="f_message"
+                    rows="4"
+                    ></textarea><!--MESSAGE-->
+          <span class="help-block">
+            Hier können Sie gerne eine Nachricht an uns übermitteln.
+          </span>
+        </div>
+      </div>
+      <div class="row">
+        <div class="col-md-offset-2">
+          <button type="submit" class="btn btn-primary btn-large"
+                  >Weiter zur Spendenübersicht</button>
+        </div>
+      </div>
+    </form>
+  </div>
+</body>
+#+END_HTML