cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kpiroum...@apache.org
Subject cvs commit: xml-cocoon2/src/resources/dev/i18n convert.xsl markup2messages.xsl merge.xsl simple_dict.xml
Date Tue, 24 Sep 2002 17:27:12 GMT
kpiroumian    2002/09/24 10:27:12

  Added:       src/resources/dev/i18n convert.xsl markup2messages.xsl
                        merge.xsl simple_dict.xml
  Log:
  Helper stylesheets for i18n message catalogue maintenance.
  
  Revision  Changes    Path
  1.1                  xml-cocoon2/src/resources/dev/i18n/convert.xsl
  
  Index: convert.xsl
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  <xsl:output indent="yes" method="xml"/>
  
  <!-- specify here the language of the catalogue you would like to create -->
  <xsl:param name="lang">hy</xsl:param>
  
  <xsl:template match="translations">
  	<catalogue xml:lang="{$lang}">
  		<xsl:apply-templates select="entry"/>
  	</catalogue>
  </xsl:template>
  
  <xsl:template match="entry">
  	<message key="{key}">
  		<xsl:value-of select="translation[@lang=$lang]"/>
  	</message>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon2/src/resources/dev/i18n/markup2messages.xsl
  
  Index: markup2messages.xsl
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:i18n="http://apache.org/cocoon/i18n/2.0"
  exclude-result-prefixes="i18n">
  
  <xsl:output method="xml" indent="yes" />
  
  <xsl:param name="target-locale">en</xsl:param>
  
  <xsl:template match="/">
      <catalogue>
          <xsl:attribute name="xml:lang"><xsl:value-of select="$target-locale" /></xsl:attribute>
          <xsl:apply-templates select="//i18n:text | //@i18n:attr"/>
      </catalogue>
  </xsl:template>
  
  <!-- i18n:text element processing -->
  <xsl:template match="i18n:text">
      <xsl:call-template name="create-entry">
          <xsl:with-param name="key-value">
              <xsl:choose>
                  <xsl:when test="@key"><xsl:value-of select="@key"/></xsl:when>
                  <xsl:otherwise><xsl:value-of select="text()" /></xsl:otherwise>
              </xsl:choose>
          </xsl:with-param>        
      </xsl:call-template>
  </xsl:template>
  
  <!-- i18n:attr attribute processing -->
  <xsl:template match="@i18n:attr">
      <xsl:call-template name="process-attributes">
          <xsl:with-param name="attr-list" select="." />
      </xsl:call-template>
  </xsl:template>
  
  <xsl:template name="process-attributes">
      <xsl:param name="attr-list" />
      <xsl:variable name="attr-nlist" select="concat(normalize-space($attr-list), ' ')"
/>
      <xsl:variable name="first" select="substring-before($attr-nlist, ' ')" />
      <xsl:variable name="rest" select="substring-after($attr-nlist, ' ')" />      
 
      <xsl:variable name="key-value" select="../@*[name()=$first][1]" />
      <xsl:call-template name="create-entry">
          <xsl:with-param name="key-value" select="$key-value" />
      </xsl:call-template>
      <xsl:if test="$rest">
          <xsl:call-template name="process-attributes">
              <xsl:with-param name="attr-list" select="$rest" />
          </xsl:call-template>
      </xsl:if>
  </xsl:template>
  
  <xsl:template name="create-entry">
      <xsl:param name="key-value" />
      <message key="{$key-value}"><xsl:value-of select="$key-value" /></message>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon2/src/resources/dev/i18n/merge.xsl
  
  Index: merge.xsl
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  <xsl:output indent="yes" method="xml" />
  <!--
  	Usage patterns.
  	******************
  	1. Key generation mode is used to generate a dictionary file 
  	from the existing containing only keys, empty translation nodes
  	with lang attribute equal to $new-lang and, optionaly, translation 
  	for another language - for convenience.
  	Example: $mode = keys, $new-lang=fr, $keep-lang=en
  	Result will be a dictionary template for French.
  	
  	2. Merging translations is useful when you need to add or update 
  	translations for a new or existing language. You have to create a 
  	translations file with new values and set $new-dict param.
  	
  	3. To add a new language you will need to generate a template with
  	keys, translate them, then merge with the existing dictionary.
  -->
  
  
  <!-- Modes: 
  		keys - generates a template with keys for the given language
  		merge - adds/updates translations from the given file
  -->
  <xsl:param name="mode">merge</xsl:param>
  <!-- The language to be added or used in keys mode -->
  <xsl:param name="new-lang">de</xsl:param>
  <!-- Translations for this language will be kept during key generation -->
  <xsl:param name="keep-lang"></xsl:param>
  <!-- New translations' file name - format is the same as for the dictionary -->
  <xsl:param name="new-dict">simple_dict_de.xml</xsl:param>
  
  <xsl:template match="translations">
  	<xsl:copy>
  		<xsl:choose>
  			<xsl:when test="$mode='keys'">
  				<xsl:apply-templates mode="keys" />
  			</xsl:when>
  			<xsl:otherwise>	
  				<xsl:apply-templates />
  			</xsl:otherwise>
  		</xsl:choose>
  	</xsl:copy>
  </xsl:template>
  
  <xsl:template match="entry" mode="keys">
  	<xsl:copy>
  		<xsl:apply-templates select="key | translation[@lang=$keep-lang]" />
  		<translation lang="{$new-lang}">[translate]</translation>
  	</xsl:copy>
  </xsl:template>
  
  <xsl:template match="entry" >
  	<xsl:copy>
  		<xsl:apply-templates />
  		<xsl:if test="not(translation[@lang=$new-lang])">	
  			<xsl:variable name="key" select="key/text()" />
  			<xsl:variable name="value" select="document($new-dict)/translations/entry[key=$key]/translation[@lang=$new-lang]"
/>
  			<translation lang="{$new-lang}"><xsl:value-of select="normalize-space($value)"
/></translation>
  		</xsl:if>
  	</xsl:copy>
  </xsl:template>
  
  <xsl:template match="translation[@lang=$new-lang]" >
  	<xsl:variable name="key" select="../key/text()" />
  	<xsl:variable name="value" select="document($new-dict)/translations/entry[key=$key]/translation[@lang=$new-lang]"
/>	
  	<xsl:copy>
  		<xsl:apply-templates select="@*"/>
  		<xsl:value-of select="normalize-space($value)" />
  	</xsl:copy>
  </xsl:template>
  
  <xsl:template match="@* | * | text() | processing-instruction() | comment()" priority="-1"
mode="keys">
  	<xsl:copy>
       	<xsl:apply-templates select="@* | * | text() | processing-instruction() | comment()"/>
  	</xsl:copy>
  </xsl:template>
  
  <xsl:template match="@* | * | text() | processing-instruction() | comment()" priority="-1">
  	<xsl:copy>
       	<xsl:apply-templates select="@* | * | text() | processing-instruction() | comment()"/>
  	</xsl:copy>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  
  1.1                  xml-cocoon2/src/resources/dev/i18n/simple_dict.xml
  
  Index: simple_dict.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <translations>
  	<!-- 
  	Languages:
  		en - English
  		ru - Russian
  		de - German (thanks to Jörg Prante)
  		pl - Polish (thanks to Krzysztof Zieliński)
  		es - Spanish
  		hy - Armenian.
  -->
  	<!-- Language links -->
  	<entry>
  		<key>count_title</key>
  		<translation lang="en">This page was accessed {0} times. Last at: {1}.</translation>
  		<translation lang="ru">На эту страницу заходили {0} раз(а).
В последний раз {1}.</translation>
  		<translation lang="de">Diese Seite wurde {0}mal aufgerufen. Letzter Aufruf: {1}.</translation>
  		<translation lang="pl">Ta strona była pobierana {0} razy. Ostatnio {1}</translation>
  		<translation lang="es">Esta página fue tenida acceso {0} veces. Pasado en: {1}.</translation>
  		<translation lang="hy">²Ûë ¿çÁ ³Ûó»É»É »Ý {0} ³Ý·³Ù. ì»ñçÇÝÁ
{1}.</translation>
  	</entry>
  	<entry>
  		<key>a_key</key>
  		<translation lang="en">This is a key value.</translation>
  		<translation lang="ru">Это значение по ключу.</translation>
  		<translation lang="de">Dies ist der Wert eines Schlüssels.</translation>
  		<translation lang="pl">To jest klucz.</translation>
  		<translation lang="es">Esto es un valor clave.</translation>
  		<translation lang="hy">ê³ µ³Ý³ÉÇÇ ³éÅ»ùÝ ¿£</translation>
  	</entry>
  	<entry>
  		<key>lang_id1</key>
  		<translation lang="en">ru</translation>
  		<translation lang="ru">en</translation>
  		<translation lang="de">en</translation>
  		<translation lang="pl">en</translation>
  		<translation lang="es">en</translation>
  		<translation lang="hy">en</translation>
  	</entry>
  	<entry>
  		<key>lang_id2</key>
  		<translation lang="en">de</translation>
  		<translation lang="ru">de</translation>
  		<translation lang="de">ru</translation>
  		<translation lang="pl">ru</translation>
  		<translation lang="es">ru</translation>
  		<translation lang="hy">ru</translation>
  	</entry>
  	<entry>
  		<key>lang_id3</key>
  		<translation lang="en">pl</translation>
  		<translation lang="ru">pl</translation>
  		<translation lang="de">pl</translation>
  		<translation lang="pl">de</translation>
  		<translation lang="es">de</translation>
  		<translation lang="hy">de</translation>
  	</entry>
  	<entry>
  		<key>lang_id4</key>
  		<translation lang="en">es</translation>
  		<translation lang="ru">es</translation>
  		<translation lang="de">es</translation>
  		<translation lang="pl">es</translation>
  		<translation lang="es">pl</translation>
  		<translation lang="hy">pl</translation>
  	</entry>
  	<entry>
  		<key>lang_id5</key>
  		<translation lang="en">hy</translation>
  		<translation lang="ru">hy</translation>
  		<translation lang="de">hy</translation>
  		<translation lang="pl">hy</translation>
  		<translation lang="es">hy</translation>
  		<translation lang="hy">es</translation>
  	</entry>
  	<!-- current language -->
  	<entry>
  		<key>language</key>
  		<translation lang="en">English</translation>
  		<translation lang="ru">Русский</translation>
  		<translation lang="de">Deutsch</translation>
  		<translation lang="pl">Polski</translation>
  		<translation lang="es">Español</translation>
  		<translation lang="hy">гۻñ»Ý</translation>
  	</entry>
  	<entry>
  		<key>language1</key>
  		<translation lang="en">Russian</translation>
  		<translation lang="ru">Английский</translation>
  		<translation lang="de">Englische</translation>
  		<translation lang="pl">Angielski</translation>
  		<translation lang="es">Inglés</translation>
  		<translation lang="hy">²Ý·É»ñ»Ý</translation>
  	</entry>
  	<entry>
  		<key>language2</key>
  		<translation lang="en">German</translation>
  		<translation lang="ru">Немецкий</translation>
  		<translation lang="de">Russe</translation>
  		<translation lang="pl">Rosyjski</translation>
  		<translation lang="es">Ruso</translation>
  		<translation lang="hy">èáõë»ñ»Ý</translation>
  	</entry>
  	<entry>
  		<key>language3</key>
  		<translation lang="en">Polish</translation>
  		<translation lang="ru">Польский</translation>
  		<translation lang="de">Polnisch</translation>
  		<translation lang="pl">Niemiecki</translation>
  		<translation lang="es">Alemán</translation>
  		<translation lang="hy">¶»ñٳݻñ»Ý</translation>
  	</entry>
  	<entry>
  		<key>language4</key>
  		<translation lang="en">Spanish</translation>
  		<translation lang="ru">Испанский</translation>
  		<translation lang="de">Spanisch</translation>
  		<translation lang="pl">Hiszpañski</translation>
  		<translation lang="es">Polaco</translation>
  		<translation lang="hy">Ȼѻñ»Ý</translation>
  	</entry>
  	<entry>
  		<key>language5</key>
  		<translation lang="en">Armenian</translation>
  		<translation lang="ru">Армянский</translation>
  		<translation lang="de">Armenier</translation>
  		<translation lang="pl">Armeñski</translation>
  		<translation lang="es">Armenio</translation>
  		<translation lang="hy">Æëå³Ý»ñ»Ý</translation>
  	</entry>
  	<entry>
  		<key>Hello, internationalization!</key>
  		<translation lang="en">Hello, internationalization!</translation>
  		<translation lang="ru">Привет, многоязычность!</translation>
  		<translation lang="de">Herzlich willkommen, Internationalisierung!</translation>
  		<translation lang="pl">Witam, oto przykład wielojęzycznej strony!</translation>
  		<translation lang="es">¡¡Hola!, internacionalización!</translation>
  		<translation lang="hy">´³ñ¢°, ÇÝï»ñݳóÛáݳÉáõÃÛáõÝ£</translation>
  	</entry>
  	<entry>
  		<key>Documentation link:</key>
  		<translation lang="en">See i18n documentation for details:</translation>
  		<translation lang="ru">Для дополнительной информации
по i18n смотри:</translation>
  		<translation lang="de">Näheres unter der i18n Dokumentation:</translation>
  		<translation lang="pl">Widzą i18n dokumentacja dla szczegółów:</translation>
  		<translation lang="es">Visto la documentación i18n para detalles:</translation>
  		<translation lang="hy">سÝñ³Ù³ë µ³ó³ïñáõÃÛ³Ý Ñ³Ù³ñ ݳÇñª</translation>
  	</entry>
  	<entry>
  		<key>first</key>
  		<translation lang="en">First</translation>
  		<translation lang="ru">Первый</translation>
  		<translation lang="de">Erstens</translation>
  		<translation lang="pl">Pierwszy</translation>
  		<translation lang="es">Primero</translation>
  		<translation lang="hy">²é³çÇÝ</translation>
  	</entry>
  	<entry>
  		<key>second</key>
  		<translation lang="en">Second</translation>
  		<translation lang="ru">Второй</translation>
  		<translation lang="de">Zweitens</translation>
  		<translation lang="pl">Drugi</translation>
  		<translation lang="es">Segundo</translation>
  		<translation lang="hy">ºñÏñáñ¹</translation>
  	</entry>
  	<entry>
  		<key>third</key>
  		<translation lang="en">Third</translation>
  		<translation lang="ru">Третий</translation>
  		<translation lang="de">Drittens</translation>
  		<translation lang="pl">Trzeci</translation>
  		<translation lang="es">Tercio</translation>
  		<translation lang="hy">ºññáñ¹</translation>
  	</entry>
  	<entry>
  		<key>forth</key>
  		<translation lang="en">Forth</translation>
  		<translation lang="ru">Четвертый</translation>
  		<translation lang="de">Viertens</translation>
  		<translation lang="pl">Czwarty</translation>
  		<translation lang="es">En adelante</translation>
  		<translation lang="hy">¼áñáñ¹</translation>
  	</entry>
  	<entry>
  		<key>article</key>
  		<translation lang="en">Article</translation>
  		<translation lang="ru">Статья</translation>
  		<translation lang="de">Artikel</translation>
  		<translation lang="pl">Artykuł</translation>
  		<translation lang="es">Artículo</translation>
  		<translation lang="hy">Ðá¹í³Í</translation>
  	</entry>
  	<entry>
  		<key>article_text1</key>
  		<translation lang="en">This is a i18n paragraph.</translation>
  		<translation lang="ru">Это интернационализированный абзац.</translation>
  		<translation lang="de">Dies ist ein Absatz nach i18n.</translation>
  		<translation lang="pl">To jest paragraf w i18n.</translation>
  		<translation lang="es">Esto es un párrafo i18n.</translation>
  		<translation lang="hy">ê³ ÇÝï»ñݳóÛáÝ³É å³ñ³·ñ³ý ¿£</translation>
  	</entry>
  	<entry>
  		<key>article_text2</key>
  		<translation lang="en">This is another i18n paragraph and is also a cool one.</translation>
  		<translation lang="ru">Это тоже интернационализированный
абзац и такой же классный.</translation>
  		<translation lang="de">Dies ist ein weiterer Absatz nach i18n und auch noch ein
ziemlich cooler dazu.</translation>
  		<translation lang="pl">To jest następny paragraf w i18n i jest takze fajny.</translation>
  		<translation lang="es">Esto es otro párrafo i18n y es también uno 'cool'.</translation>
  		<translation lang="hy">ê³ ÙÇ áõñÇß ÇÝï»ñݳóÛáÝ³É å³ñ³·ñ³ý
¿, ¢ ÝáõÛÝ å»ë ó»Ýïñ£</translation>
  	</entry>
  	<entry>
  		<key>copyright</key>
  		<translation lang="en">Copyright © 2001 Konstantin Piroumian. No rights are reserved.</translation>
  		<translation lang="ru">Авторские права © 2001 Константин
Пирумян. Ничто не защищено.</translation>
  		<translation lang="de">Copyright © 2001 Konstantin Piroumian. Deutsche Übersetzung
von Jörg Prante.</translation>
  		<translation lang="pl">Copyright © 2001 Konstantin Piroumian i Krzysztof Zieliński.
Żadne prawa nie są zastrzeżone:)</translation>
  		<translation lang="es">Copyright © 2001 Konstantin Piroumian. Ningunos derechos
son reservados.</translation>
  		<translation lang="hy">Copyright © 2001 Konstantin Piroumian. àãÇÝã ãÇ å³Ñå³Ýí³Í£</translation>
  	</entry>
  	<entry>
  		<key>Hello, {0}! Glad to see you!</key>
  		<translation lang="en">Hello, {0}! Glad to see you!</translation>
  		<translation lang="ru">Привет, {0}! Рад тебя видеть!</translation>
  		<translation lang="de">Hallo {0}! Schön, dich zu sehen!</translation>
  		<translation lang="pl">Witam, {0}! Miło Cię widzieć!</translation>
  		<translation lang="es">¡¡Hola!, {0}! ¡Alegre de verle!</translation>
  		<translation lang="hy">´³ñ¢¯ {0}: àõñ³Ë »Ù ù»½ ï»ëݻɣ</translation>
  	</entry>
  	<entry>
  		<key>Kot</key>
  		<translation lang="en">Tomcat</translation>
  		<translation lang="ru">Кот</translation>
  		<translation lang="de">Tomcat</translation>
  		<translation lang="pl">Tomcat</translation>
  		<translation lang="es">Gato</translation>
  		<translation lang="hy">γïáõ</translation>
  	</entry>
  	<entry>
  		<key>none</key>
  		<translation lang="en">None</translation>
  		<translation lang="ru">Никто</translation>
  		<translation lang="de">nichts</translation>
  		<translation lang="pl">Nic</translation>
  		<translation lang="es">Ninguno</translation>
  		<translation lang="hy">àã áù</translation>
  	</entry>
  	<entry>
  		<key>one</key>
  		<translation lang="en">one</translation>
  		<translation lang="ru">раз</translation>
  		<translation lang="de">eins</translation>
  		<translation lang="pl">raz</translation>
  		<translation lang="es">un</translation>
  		<translation lang="hy">Ù»Ï</translation>
  	</entry>
  	<entry>
  		<key>two</key>
  		<translation lang="en">two</translation>
  		<translation lang="ru">два</translation>
  		<translation lang="de">zwei</translation>
  		<translation lang="pl">dwa</translation>
  		<translation lang="es">dos</translation>
  		<translation lang="hy">»ñÏáõë</translation>
  	</entry>
  </translations>
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message