<commit_before><?xml version="1.0" encoding="US-ASCII" ?>
<!--
 -*- mode: Fundamental; tab-width: 4; -*-
 ex:ts=4

 $Id$
-->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<!-- Define parameters -->
	<xsl:param name="package_name" />
	<xsl:param name="locale"       />
	<xsl:param name="log_file"     />

	<!-- Perform includes -->
	<xsl:include href="shared.xslt"         />
	<xsl:include href="../xml_to_java.xslt" />

	<!-- Set output method -->
	<xsl:output method="text" />

	<xsl:template match="translation-bundle">
		<xsl:variable name="classname">
			<xsl:text>TranslationBundle_</xsl:text>
			<xsl:value-of select="$locale" />
		</xsl:variable>

		<xsl:text>package </xsl:text>
		<xsl:value-of select="$package_name" />
		<xsl:text><![CDATA[;

import org.xins.util.MandatoryArgumentChecker;
import org.xins.util.text.FastStringBuffer;

/**
 * Translation bundle for the <em>]]></xsl:text>

		<xsl:value-of select="$locale" />

		<xsl:text><![CDATA[</em> locale.
 *
 * @see Log
 */
public final class ]]></xsl:text>
		<xsl:value-of select="$classname" />
		<xsl:text><![CDATA[ extends TranslationBundle {

   //-------------------------------------------------------------------------
   // Class fields
   //-------------------------------------------------------------------------

   //-------------------------------------------------------------------------
   // Class functions
   //-------------------------------------------------------------------------

   /**
    * The one and only instance of this class.
    */
   public static final ]]></xsl:text>
		<xsl:value-of select="$classname" />
		<xsl:text> SINGLETON = new </xsl:text>
		<xsl:value-of select="$classname" />
		<xsl:text><![CDATA[();

   //-------------------------------------------------------------------------
   // Constructors
   //-------------------------------------------------------------------------

   /**
    * Constructor for this class. Intentionally made <code>private</code>,
    * since no instances of this class should be created. Instead, the class
    * functions should be used.
    */
   private ]]></xsl:text>
		<xsl:value-of select="$classname" />
		<xsl:text>() {
      super("</xsl:text>
		<xsl:value-of select="$locale" />
		<xsl:text>");
   }


   //-------------------------------------------------------------------------
   // Fields
   //-------------------------------------------------------------------------

   //-------------------------------------------------------------------------
   // Methods
   //-------------------------------------------------------------------------</xsl:text>

		<xsl:for-each select="translation">
			<xsl:variable name="entry" select="@entry" />

			<xsl:text>

   public String translation_</xsl:text>
			<xsl:value-of select="$entry" />
			<xsl:text>(</xsl:text>
			<xsl:apply-templates select="document($log_file)/log/group/entry[@id = $entry]/param" mode="method-argument" />
			<xsl:text>) {</xsl:text>
			<xsl:choose>
				<xsl:when test="count(value-of-param) &lt; 1">
					<xsl:text>
      return "</xsl:text>
					<xsl:call-template name="xml_to_java_string">
						<xsl:with-param name="text" select="text()" />
					</xsl:call-template>
					<xsl:text>";</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>
      FastStringBuffer buffer = new FastStringBuffer(205);</xsl:text>
					<xsl:apply-templates />
					<xsl:text>
      return buffer.toString();</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
			<xsl:text>
   }</xsl:text>
		</xsl:for-each>

		<xsl:text>
}
</xsl:text>
	</xsl:template>

	<xsl:template match="translation/value-of-param">
		<xsl:text>
      buffer.append(</xsl:text>
		<xsl:value-of select="@name" />
		<xsl:text>);</xsl:text>
	</xsl:template>

	<xsl:template match="translation/value-of-param[@format='quoted']">
		<xsl:text>
      if (</xsl:text>
		<xsl:value-of select="@name" />
		<xsl:text> == null) {
         buffer.append("(null)");
      } else {
         buffer.append('"');
         buffer.append(</xsl:text>
		<xsl:value-of select="@name" />
		<xsl:text>);
         buffer.append('"');
      }</xsl:text>
	</xsl:template>

	<xsl:template match="translation/text()">
		<xsl:choose>
			<xsl:when test="string-length(.) &lt; 1"></xsl:when>
			<xsl:when test="string-length(.) = 1">
				<xsl:text><commit_msg>Fixed.<commit_after><?xml version="1.0" encoding="US-ASCII" ?>
<!--
 -*- mode: Fundamental; tab-width: 4; -*-
 ex:ts=4

 $Id$
-->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<!-- Define parameters -->
	<xsl:param name="package_name" />
	<xsl:param name="locale"       />
	<xsl:param name="log_file"     />

	<!-- Perform includes -->
	<xsl:include href="shared.xslt"         />
	<xsl:include href="../xml_to_java.xslt" />

	<!-- Set output method -->
	<xsl:output method="text" />

	<xsl:template match="translation-bundle">
		<xsl:variable name="classname">
			<xsl:text>TranslationBundle_</xsl:text>
			<xsl:value-of select="$locale" />
		</xsl:variable>

		<xsl:text>package </xsl:text>
		<xsl:value-of select="$package_name" />
		<xsl:text><![CDATA[;

import org.xins.util.MandatoryArgumentChecker;
import org.xins.util.text.FastStringBuffer;

/**
 * Translation bundle for the <em>]]></xsl:text>

		<xsl:value-of select="$locale" />

		<xsl:text><![CDATA[</em> locale.
 *
 * @see Log
 */
public final class ]]></xsl:text>
		<xsl:value-of select="$classname" />
		<xsl:text><![CDATA[ extends TranslationBundle {

   //-------------------------------------------------------------------------
   // Class fields
   //-------------------------------------------------------------------------

   //-------------------------------------------------------------------------
   // Class functions
   //-------------------------------------------------------------------------

   /**
    * The one and only instance of this class.
    */
   public static final ]]></xsl:text>
		<xsl:value-of select="$classname" />
		<xsl:text> SINGLETON = new </xsl:text>
		<xsl:value-of select="$classname" />
		<xsl:text><![CDATA[();

   //-------------------------------------------------------------------------
   // Constructors
   //-------------------------------------------------------------------------

   /**
    * Constructor for this class. Intentionally made <code>private</code>,
    * since no instances of this class should be created. Instead, the class
    * functions should be used.
    */
   private ]]></xsl:text>
		<xsl:value-of select="$classname" />
		<xsl:text>() {
      super("</xsl:text>
		<xsl:value-of select="$locale" />
		<xsl:text>");
   }


   //-------------------------------------------------------------------------
   // Fields
   //-------------------------------------------------------------------------

   //-------------------------------------------------------------------------
   // Methods
   //-------------------------------------------------------------------------</xsl:text>

		<xsl:for-each select="translation">
			<xsl:variable name="entry" select="@entry" />

			<xsl:text>

   public String translation_</xsl:text>
			<xsl:value-of select="$entry" />
			<xsl:text>(</xsl:text>
			<xsl:apply-templates select="document($log_file)/log/group/entry[@id = $entry]/param" mode="method-argument" />
			<xsl:text>) {</xsl:text>
			<xsl:choose>
				<xsl:when test="count(value-of-param) &lt; 1">
					<xsl:text>
      return "</xsl:text>
					<xsl:call-template name="xml_to_java_string">
						<xsl:with-param name="text" select="text()" />
					</xsl:call-template>
					<xsl:text>";</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>
      FastStringBuffer buffer = new FastStringBuffer(205);</xsl:text>
					<xsl:apply-templates />
					<xsl:text>
      return buffer.toString();</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
			<xsl:text>
   }</xsl:text>
		</xsl:for-each>

		<xsl:text>
}
</xsl:text>
	</xsl:template>

	<xsl:template match="translation/value-of-param">
		<xsl:variable name="entry" select="../@entry" />
		<xsl:variable name="param-name" select="@name" />
		<xsl:variable name="param-type" select="document($log_file)/log/group/entry[@id = $entry]/param[@name=$param-name]/@type" />
		<xsl:variable name="param-nullable" select="document($log_file)/log/group/entry[@id = $entry]/param[@name=$param-name]/@nullable" />

		<xsl:text>
      buffer.append(</xsl:text>
		<xsl:choose>
			<xsl:when test="($param-type = 'object') and ($param-nullable = 'false')">
				<xsl:value-of select="@name" />
				<xsl:text>.toString()</xsl:text>
			</xsl:when>
			<xsl:when test="$param-type = 'object'">
				<xsl:text>(</xsl:text>
				<xsl:value-of select="@name" />
				<xsl:text>== null) ? "(null)" : </xsl:text>
				<xsl:value-of select="@name" />
				<xsl:text>.toString()</xsl:text>
			</xsl:when>
			<xsl:when test="$param-nullable = 'false'">
				<xsl:value-of select="@name" />
			</xsl:when>
			<xsl:otherwise>
				<xsl:text>(</xsl:text>
				<xsl:value-of select="@name" />
				<xsl:text>== null) ? "(null)" : </xsl:text>
				<xsl:value-of select="@name" />
			</xsl:otherwise>
		</xsl:choose>
		<xsl:text>);</xsl:text>
	</xsl:template>

	<xsl:template match="translation/value-of-param[@format='quoted']">
		<xsl:text>
      if (</xsl:text>
		<xsl:value-of select="@name" />
		<xsl:text> == null) {
         buffer.append("(null)");
      } else {
         buffer.append('"');
         buffer.append(</xsl:text>
		<xsl:value-of select="@name" />
		<xsl:text>);
         buffer.append('"');
      }</xsl:text>
	</xsl:template>

	<xsl:template match="translation/text()">
		<xsl:choose>
			<xsl:when test="string-length(.) &lt; 1"></xsl:when>
			<xsl:when test="string-length(.) = 1">
				<xsl:text>
{'fraction_non_alphanumeric': 0.33514288640786644, 'fraction_numerical': 0.0034825361057052137, 'mean_word_length': 1.8583138173302107, 'pattern_counts': {'":': 0, '<': 246, '<?xml version=': 2, '>': 246, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3218576', 'n_tokens_mistral': 3576, 'n_tokens_neox': 2974, 'n_words': 492}