Merge branch 'b-3.6.1' of ../kivitendo-erp_20220811
[kivitendo-erp.git] / doc / html / ch04s05.html
index 320e189..cc2d124 100644 (file)
 <html><head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-   <title>4.5. Die kivitendo-Test-Suite</title><link rel="stylesheet" type="text/css" href="style.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.1-RC2"><link rel="home" href="index.html" title="kivitendo 3.3.0: Installation, Konfiguration, Entwicklung"><link rel="up" href="ch04.html" title="Kapitel 4. Entwicklerdokumentation"><link rel="prev" href="ch04s04.html" title="4.4. Translations and languages"><link rel="next" href="ch04s06.html" title="4.6. Stil-Richtlinien"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">4.5. Die kivitendo-Test-Suite</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch04s04.html">Zurück</a>&nbsp;</td><th width="60%" align="center">Kapitel 4. Entwicklerdokumentation</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="ch04s06.html">Weiter</a></td></tr></table><hr></div><div class="sect1" title="4.5. Die kivitendo-Test-Suite"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="devel.testsuite"></a>4.5. Die kivitendo-Test-Suite</h2></div></div></div><div class="sect2" title="4.5.1. Einführung"><div class="titlepage"><div><div><h3 class="title"><a name="devel.testsuite.intro"></a>4.5.1. Einführung</h3></div></div></div><p>kivitendo enthält eine Suite für automatisierte Tests. Sie basiert auf dem Standard-Perl-Modul <code class="literal">Test::More</code>.</p><p>Die grundlegenden Fakten sind:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Alle Tests liegen im Unterverzeichnis <code class="filename">t/</code>.</p></li><li class="listitem"><p>Ein Script (bzw. ein Test) in <code class="filename">t/</code> enthält einen oder mehrere Testfälle.</p></li><li class="listitem"><p>Alle Dateinamen von Tests enden auf <code class="literal">.t</code>. Es sind selbstständig ausführbare Perl-Scripte.</p></li><li class="listitem"><p>Die Test-Suite besteht aus der Gesamtheit aller Tests, sprich aller Scripte in <code class="filename">t/</code>, deren
-          Dateiname auf <code class="literal">.t</code> endet.</p></li></ul></div></div><div class="sect2" title="4.5.2. Voraussetzungen"><div class="titlepage"><div><div><h3 class="title"><a name="devel.testsuite.prerequisites"></a>4.5.2. Voraussetzungen</h3></div></div></div><p>Für die Ausführung werden neben den für kivitendo eh schon benötigten Module noch weitere Perl-Module benötigt. Diese sind:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
-                     <code class="literal">Test::Deep</code> (Debian-Paketname: <code class="literal">libtest-deep-perl</code>; Fedora Core:
-          <code class="literal">perl-Test-Deep</code>; openSUSE: <code class="literal">perl-Test-Deep</code>)</p></li><li class="listitem"><p>
-                     <code class="literal">Test::Exception</code> (Debian-Paketname: <code class="literal">libtest-exception-perl</code>; Fedora Core:
-          <code class="literal">perl-Test-Exception</code>; openSUSE: <code class="literal">perl-Test-Exception</code>)</p></li><li class="listitem"><p>
-                     <code class="literal">Test::Output</code> (Debian-Paketname: <code class="literal">libtest-output-perl</code>; Fedora Core:
-          <code class="literal">perl-Test-Output</code>; openSUSE: <code class="literal">perl-Test-Output</code>)</p></li><li class="listitem"><p>
-                     <code class="literal">Test::Harness</code> 3.0.0 oder höher. Dieses Modul ist ab Perl 5.10.1 Bestandteil der
-          Perl-Distribution und kann für frühere Versionen aus dem <a class="ulink" href="http://www.cpan.org" target="_top">CPAN</a> bezogen
-          werden.</p></li><li class="listitem"><p>
-                     <code class="literal">LWP::Simple</code> aus dem Paket <code class="literal">libwww-perl</code> (Debian-Panetname:
-          <code class="literal">libwww-perl</code>; Fedora Core: <code class="literal">perl-libwww-perl</code>; openSUSE:
-          <code class="literal">perl-libwww-perl</code>)</p></li><li class="listitem"><p>
-                     <code class="literal">URI::Find</code> (Debian-Panetname: <code class="literal">liburi-find-perl</code>; Fedora Core:
-          <code class="literal">perl-URI-Find</code>; openSUSE: <code class="literal">perl-URI-Find</code>)</p></li></ul></div><p>Weitere Voraussetzung ist, dass die Testsuite ihre eigene Datenbank anlegen kann, um Produktivdaten nicht zu gefährden. Dazu
-        müssen in der Konfigurationsdatei im Abschnit <code class="literal">testing/database</code> Datenbankverbindungsparameter angegeben
-        werden. Der hier angegebene Benutzer muss weiterhin das Recht haben, Datenbanken anzulegen und zu löschen.</p></div><div class="sect2" title="4.5.3. Existierende Tests ausführen"><div class="titlepage"><div><div><h3 class="title"><a name="devel.testsuite.execution"></a>4.5.3. 
-          Existierende Tests ausführen
-        </h3></div></div></div><p>Es gibt mehrere Möglichkeiten zum Ausführen der Tests: entweder, man lässt alle Tests auf einmal ausführen, oder man führt
-        gezielt einzelne Scripte aus. Für beide Fälle gibt es das Helferscript <code class="filename">t/test.pl</code>.</p><p>Will man die komplette Test-Suite ausführen, so muss man einfach nur <code class="filename">t/test.pl</code> ohne weitere Parameter aus
-        dem kivitendo-Basisverzeichnis heraus ausführen.</p><p>Um einzelne Test-Scripte auszuführen, übergibt man deren Namen an <code class="filename">t/test.pl</code>. Beispielsweise:</p><pre class="programlisting">t/test.pl t/form/format_amount.t t/background_job/known_jobs.t</pre></div><div class="sect2" title="4.5.4. Bedeutung der verschiedenen Test-Scripte"><div class="titlepage"><div><div><h3 class="title"><a name="devel.testsuite.meaning_of_scripts"></a>4.5.4. 
-          Bedeutung der verschiedenen Test-Scripte
-        </h3></div></div></div><p>Die Test-Suite umfasst Tests sowohl für Funktionen als auch für Programmierstil. Einige besonders zu erwähnende, weil auch
-        während der Entwicklung nützliche Tests sind:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
-                     <code class="filename">t/001compile.t</code> -- compiliert alle Quelldateien und bricht bei Fehlern sofort ab</p></li><li class="listitem"><p>
-                     <code class="filename">t/002goodperl.t</code> -- überprüft alle Perl-Dateien auf Anwesenheit von '<code class="literal">use strict</code>'-Anweisungen</p></li><li class="listitem"><p>
-                     <code class="filename">t/003safesys.t</code> -- überprüft Aufrufe von <code class="function">system()</code> und <code class="function">exec()</code> auf Gültigkeit</p></li><li class="listitem"><p>
-                     <code class="filename">t/005no_tabs.t</code> -- überprüft, ob Dateien Tab-Zeichen enthalten</p></li><li class="listitem"><p>
-                     <code class="filename">t/006spelling.t</code> -- sucht nach häufigen Rechtschreibfehlern</p></li><li class="listitem"><p>
-                     <code class="filename">t/011pod.t</code> -- überprüft die Syntax von Dokumentation im POD-Format auf Gültigkeit</p></li></ul></div><p>Weitere Test-Scripte überprüfen primär die Funktionsweise einzelner Funktionen und Module.</p></div><div class="sect2" title="4.5.5. Neue Test-Scripte erstellen"><div class="titlepage"><div><div><h3 class="title"><a name="devel.testsuite.create_new"></a>4.5.5. 
-          Neue Test-Scripte erstellen
-        </h3></div></div></div><p>Es wird sehr gern gesehen, wenn neue Funktionalität auch gleich mit einem Test-Script abgesichert wird. Auch bestehende
-        Funktion darf und soll ausdrücklich nachträglich mit Test-Scripten abgesichert werden.</p><div class="sect3" title="4.5.5.1. Ideen für neue Test-Scripte, die keine konkreten Funktionen testen"><div class="titlepage"><div><div><h4 class="title"><a name="devel.testsuite.ideas_for_non_function_tests"></a>4.5.5.1. 
-            Ideen für neue Test-Scripte, die keine konkreten Funktionen testen
-          </h4></div></div></div><p> Ideen, die abgesehen von Funktionen noch nicht umgesetzt wurden:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Überprüfung auf fehlende symbolische Links</p></li><li class="listitem"><p>Suche nach Nicht-ASCII-Zeichen in Perl-Code-Dateien (mit gewissen Einschränkungen wie das Erlauben von deutschen Umlauten)</p></li><li class="listitem"><p>Test auf DOS-Zeilenenden (\r\n anstelle von nur \n)</p></li><li class="listitem"><p>Überprüfung auf Leerzeichen am Ende von Zeilen</p></li><li class="listitem"><p>Test, ob alle zu übersetzenden Strings in <code class="filename">locale/de/all</code> vorhanden sind</p></li><li class="listitem"><p>Test, ob alle Webseiten-Templates in <code class="filename">templates/webpages</code> mit vom Perl-Modul <code class="literal">Template</code> compiliert werden können</p></li></ul></div></div><div class="sect3" title="4.5.5.2. Konvention für Verzeichnis- und Dateinamen"><div class="titlepage"><div><div><h4 class="title"><a name="devel.testsuite.directory_and_test_names"></a>4.5.5.2. 
-            Konvention für Verzeichnis- und Dateinamen
-          </h4></div></div></div><p>Es gibt momentan eine wenige Richtlinien, wie Test-Scripte zu benennen sind. Bitte die folgenden Punkte als Richtlinie betrachten und ihnen soweit es geht folgen:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Die Dateiendung muss <code class="filename">.t</code> lauten.</p></li><li class="listitem"><p>Namen sind englisch, komplett klein geschrieben und einzelne Wörter mit Unterstrichten getrennt (beispielsweise
-            <code class="filename">bad_function_params.t</code>).</p></li><li class="listitem"><p>Unterverzeichnisse sollten grob nach dem Themenbereich benannt sein, mit dem sich die Scripte darin befassen
-            (beispielsweise <code class="filename">background_jobs</code> für Tests rund um Hintergrund-Jobs).</p></li><li class="listitem"><p>Test-Scripte sollten einen überschaubaren Bereich von Funktionalität testen, der logisch zusammenhängend ist
-            (z.B. nur Tests für eine einzelne Funktion in einem Modul). Lieber mehrere Test-Scripte schreiben.</p></li></ul></div></div><div class="sect3" title="4.5.5.3. Minimales Skelett für eigene Scripte"><div class="titlepage"><div><div><h4 class="title"><a name="devel.testsuite.minimal_example"></a>4.5.5.3. 
-            Minimales Skelett für eigene Scripte
-          </h4></div></div></div><p>Der folgenden Programmcode enthält das kleinstmögliche Testscript und kann als Ausgangspunkt für eigene Tests verwendet werden:</p><pre class="programlisting">use Test::More tests =&gt; 0;
+   <title>4.5. Translations and languages</title><link rel="stylesheet" type="text/css" href="style.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.1-RC2"><link rel="home" href="index.html" title="kivitendo 3.6.1: Installation, Konfiguration, Entwicklung"><link rel="up" href="ch04.html" title="Kapitel 4. Entwicklerdokumentation"><link rel="prev" href="ch04s04.html" title="4.4. SQL-Upgradedateien"><link rel="next" href="ch04s06.html" title="4.6. Die kivitendo-Test-Suite"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">4.5. Translations and languages</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch04s04.html">Zurück</a>&nbsp;</td><th width="60%" align="center">Kapitel 4. Entwicklerdokumentation</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="ch04s06.html">Weiter</a></td></tr></table><hr></div><div class="sect1" title="4.5. Translations and languages"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="translations-languages"></a>4.5. Translations and languages</h2></div></div></div><div class="sect2" title="4.5.1. Introduction"><div class="titlepage"><div><div><h3 class="title"><a name="translations-languages.introduction"></a>4.5.1. Introduction</h3></div></div></div><div class="note" title="Anmerkung" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Anmerkung]" src="system/docbook-xsl/images/note.png"></td><th align="left">Anmerkung</th></tr><tr><td align="left" valign="top"><p>Dieser Abschnitt ist in Englisch geschrieben, um
+          internationalen Übersetzern die Arbeit zu erleichtern.</p></td></tr></table></div><p>This section describes how localization packages in kivitendo
+        are built. Currently the only language fully supported is German, and
+        since most of the internal messages are held in English the English
+        version is usable too.</p></div><div class="sect2" title="4.5.2. Character set"><div class="titlepage"><div><div><h3 class="title"><a name="translations-languages.character-set"></a>4.5.2. Character set</h3></div></div></div><p>All files included in a language pack must use UTF-8 as their
+        encoding.</p></div><div class="sect2" title="4.5.3. File structure"><div class="titlepage"><div><div><h3 class="title"><a name="translations-languages.file-structure"></a>4.5.3. File structure</h3></div></div></div><p>The structure of locales in kivitendo is:</p><pre class="programlisting">kivitendo/locale/&lt;langcode&gt;/</pre><p>where &lt;langcode&gt; stands for an abbreviation of the
+        language package. The builtin packages use two letter <a class="ulink" href="http://en.wikipedia.org/wiki/ISO_639-1" target="_top">ISO 639-1</a> codes,
+        but the actual name is not relevant for the program and can easily be
+        extended to <a class="ulink" href="http://en.wikipedia.org/wiki/IETF_language_tag" target="_top">IETF language
+        tags</a> (i.e. "en_GB"). In fact the original language packages
+        from SQL Ledger are named in this way.</p><p>In such a language directory the following files are
+        recognized:</p><div class="variablelist"><dl><dt><span class="term">LANGUAGE</span></dt><dd><p>This file is mandatory.</p><p>The <code class="filename">LANGUAGE</code> file contains the self
+              descripted name of the language. It should contain a native
+              representation first, and in parenthesis an english translation
+              after that. Example:</p><pre class="programlisting">Deutsch (German)</pre></dd><dt><span class="term">all</span></dt><dd><p>This file is mandatory.</p><p>The central translation file. It is essentially an inline
+              Perl script autogenerated by <span class="command"><strong>locales.pl</strong></span>. To
+              generate it, generate the directory and the two files mentioned
+              above, and execute the following command:</p><pre class="programlisting">scripts/locales.pl &lt;langcode&gt;</pre><p>Otherwise you can simply copy one of the other languages.
+              You will be told how many are missing like this:</p><pre class="programlisting">$ scripts/locales.pl en
+English - 0.6% - 2015/2028 missing</pre><p>A file named "<code class="filename">missing</code>" will be
+              generated and can be edited. You can also edit the
+              "<code class="filename">all</code>" file directly. Edit everything you
+              like to fit the target language and execute
+              <span class="command"><strong>locales.pl</strong></span> again. See how the missing words
+              get fewer.</p></dd><dt><span class="term">Num2text</span></dt><dd><p>Legacy code from SQL Ledger. It provides a means for
+              numbers to be converted into natural language, like
+              <code class="literal">1523 =&gt; one thousand five hundred twenty
+              three</code>. If you want to provide it, it must be inlinable
+              Perl code which provides a <code class="function">num2text</code> sub. If
+              an <code class="function">init</code> sub exists it will be executed
+              first.</p><p>Only used in the check and receipt printing module.</p></dd><dt><span class="term">special_chars</span></dt><dd><p>kivitendo comes with a lot of interfaces to different
+              formats, some of which are rather picky with their accepted
+              charset. The <code class="filename">special_chars</code> file contains a
+              listing of chars not suited for different file format and
+              provides substitutions. It is written in "Simple Ini" style,
+              containing a block for every file format.</p><p>First entry should be the order of substitution for
+              entries as a whitespace separated list. All entries are
+              interpolated, so <code class="literal">\n</code>, <code class="literal">\x20</code>
+              and <code class="literal">\\</code> all work.</p><p>After that every entry is a special char that should be
+              translated when writing text into such a file.</p><p>Example:</p><pre class="programlisting">[Template/XML]
+order=&amp; &lt; &gt; \n
+&amp;=&amp;amp;
+&lt;=&amp;lt;
+&gt;=&amp;gt;
+\n=&lt;br&gt;</pre><p>Note the importance of the order in this example.
+              Substituting &lt; and &gt; befor &amp; would lead to $gt; become
+              &amp;amp;gt;</p><p>For a list of valid formats, see the German
+              <code class="filename">special_chars</code> entry. As of this writing the
+              following are recognized:</p><pre class="programlisting">HTML
+URL@HTML
+Template/HTML
+Template/XML
+Template/LaTeX
+Template/OpenDocument
+filenames</pre><p>The last of which is very machine dependent. Remember that
+              a lot of characters are forbidden by some filesystems, for
+              example MS Windows doesn't like ':' in its files where Linux
+              doesn't mind that. If you want the files created with your
+              language pack to be portable, find all chars that could cause
+              trouble.</p></dd><dt><span class="term">missing</span></dt><dd><p>This file is not a part of the language package
+              itself.</p><p>This is a file generated by
+              <span class="command"><strong>scripts/locales.pl</strong></span> while processing your
+              locales. It's only to have the missing entries singled out and
+              does not belong to a language package.</p></dd><dt><span class="term">lost</span></dt><dd><p>This file is not a part of the language package
+              itself.</p><p>Another file generated by
+              <span class="command"><strong>scripts/locales.pl</strong></span>. If for any reason a
+              translation does not appear anymore and can be deleted, it gets
+              moved here. The last 50 or so entries deleted are saved here in
+              case you made a typo, so that you don't have to translate
+              everything again. If a tranlsation is missing, the lost file is
+              checked first. If you maintain a language package, you might
+              want to keep this safe somewhere.</p></dd><dt><span class="term">more/all</span></dt><dd><p>This subdir and file is not a part of the language package
+              itself.</p><p>If the directory more exists and contains a file called
+              all it will be parsed in addition to the mandatory all (see
+              above). The file is useful if you want to change some
+              translations for the current installation without conflicting
+              further upgrades. The file is not autogenerated and has the same
+              format as the all, but needs another key (more_texts). See the
+              german translation for an example or copy the following code:
+              </p><pre class="programlisting">
+#!/usr/bin/perl
+# -*- coding: utf-8; -*-
+# vim: fenc=utf-8
 
-use lib 't';
+use utf8;
 
-use Support::TestSetup;
+# These are additional texts for custom translations.
+# The format is the same as for the normal file all, only
+# with another key (more_texts instead of texts).
+# The file has the form of 'english text'  =&gt; 'foreign text',
 
-Support::TestSetup::login();</pre><p>Wird eine vollständig initialisierte kivitendo-Umgebung benötigt (Stichwort: alle globalen Variablen wie
-          <code class="varname">$::auth</code>, <code class="varname">$::form</code> oder <code class="varname">$::lxdebug</code>), so muss in der Konfigurationsdatei
-          <code class="filename">config/kivitendo.conf</code> im Abschnitt <code class="literal">testing.login</code> ein gültiger Login-Name eingetragen
-          sein. Dieser wird für die Datenbankverbindung benötigt.</p><p>Wir keine vollständig initialisierte Umgebung benötigt, so kann die letzte Zeile <code class="code">Support::TestSetup::login();</code>
-          weggelassen werden, was die Ausführungszeit des Scripts leicht verringert.</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch04s04.html">Zurück</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="ch04.html">Nach oben</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="ch04s06.html">Weiter</a></td></tr><tr><td width="40%" align="left" valign="top">4.4. Translations and languages&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Zum Anfang</a></td><td width="40%" align="right" valign="top">&nbsp;4.6. Stil-Richtlinien</td></tr></table></div></body></html>
\ No newline at end of file
+$self-&gt;{more_texts} = {
+
+  'Ship via'                    =&gt; 'Terms of delivery',
+  'Shipping Point'              =&gt; 'Delivery time',
+}
+              </pre><p>
+                     </p></dd></dl></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch04s04.html">Zurück</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="ch04.html">Nach oben</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="ch04s06.html">Weiter</a></td></tr><tr><td width="40%" align="left" valign="top">4.4. SQL-Upgradedateien&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Zum Anfang</a></td><td width="40%" align="right" valign="top">&nbsp;4.6. Die kivitendo-Test-Suite</td></tr></table></div></body></html>
\ No newline at end of file