httpd-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernardino" <berpl...@terra.com.br>
Subject Re: Web site translation
Date Tue, 30 Nov 2004 11:23:53 GMT
Por favor não me mandem mais mensagens. B

----- Original Message -----
From: "Yoshiki Hayashi" <yoshiki@xemacs.org>
To: <docs@httpd.apache.org>
Cc: <dev@httpd.apache.org>
Sent: Monday, November 29, 2004 7:49 AM
Subject: Re: Web site translation


André Malo <nd@perlig.de> writes:

> * Justin Erenkrantz wrote:
>
>> --On Monday, November 29, 2004 11:44 AM +0900 Yoshiki Hayashi
>>
>> <yoshiki@xemacs.org> wrote:
>> > More than a year after I proposed web site translation, I
>> > finally sat down for a while and did necessary coding to add
>> > translation support.
>>
>> BTW, this might need to be discussed on dev@httpd as well.  This is going
>> to affect all developers who touch the site.
>
> In fact, I wanted to wait until we have the new layout and a better build
> system (with xslt). We also need to think about the paths of the
> translation in conclusion with the docs etc.

I didn't know you were going to replace the build system.
All I knew was CSS work and it doesn't conflict with my
change because layout is only handled by site.vsl which I
didn't really change much.

Could you elaborate on your new build system?  I've never
heard of it before.  I'd rather stick with current system
than going XSLT (I hate XSLT as a language).  If we change
the build system at all, I think it's better to consider
using projects like forrest than creating yet another
documentation system.

>> >   Does anyone object to the direction we are going? i.e.,
>> >   having translation of web site at all?
>>
>> No, not really.  However, I'm concerned about how long the translations
>> could stay out of sync.  There's going to be times when we try to post an
>> urgent notice and if the translator is asleep (or AWOL for a few weeks),
>> then that's troublesome.  One idea: perhaps when we change the English
>> version of a page, we pull all translations until the individual
>> translation is sync'd up?
>
> That could be done similar to the docs. Either a note on the top or just
> dropping outdated translation (perhaps a combination).

That's exactly what I had in mind.

>> >   Now that we have true version control software, I think
>> >   the way to go is to create a branch like Paul did.
>> >   I'm going to create
>> >   https://svn.apache.org/repos/asf/httpd/site/branches/translation
>> >   unless someone objects.
>> >   Is there any policy on how to create and use branch?
>>
>> That's fine, I guess.  However, if we have two branches going: one for
>> css deployment and translation, that could end up being nasty to merge
>> back together....
>
> One of the reasons I would wait.

As I said above, my work doesn't conflict with CSS work.
Translation focuses on contents whereas CSS does on layout.
Thanks to Velocity, those two are mostly separated.

I also don't intent to start translation on the branch.  It
should wait after the build system is moved to main branch
and it can even wait until the CSS change goes to the trunk.
It's main purpose is to give people time to look at the
build system and raise concerns and/or brush up the build
system.

Justin Erenkrantz <justin@erenkrantz.com> writes:

>>   I extended Anakia to do some new things like providing
>>   context to get available languages and getting the
>>   destination filename.  I'd like to put the source code
>>   somewhere in Subversion repository.  Where shoud I put it?
>>   https://svn.apache.org/repos/asf/httpd/site-build looks like a
>>   good candidate to me.
>
> First, you should post the source code changes either to here or dev@httpd
so
> that we can review it.  I'm not sure what exactly you changed.  Did you
change
> Velocity?  Or, just the Velocity templates that we used?  -- justin

It's both.  I extended AnakiaTask to contain additional
contexts to make some of the operation required by
translation possible.  What I have done is to add mapper
support to map *.xml to *.html.en and *.xml.ja to
*.html.ja.euc-jp etc. and add new context $language to get
list of available translations for a given file.  I also
modified template to include "Available Language:" thingy at
the bottom of the page (you can see it at
http://www.apache.org/~yoshiki/httpd-site/index.html) and
added a template and a build rule to generate typemap.

I attach the patches.  The build system change is also in my
copied working copy at cvs.apache.org:~yoshiki/httpd-site.
You need jars in there to actually try it out.


Esta mensagem foi verificada pelo E-mail Protegido Terra.
Scan engine: McAfee VirusScan / Atualizado em 24/11/2004 / Versão: 4.3.20
(10.21) - Dat 4410
Proteja o seu e-mail Terra: http://www.emailprotegido.terra.com.br/




----------------------------------------------------------------------------
----


> --- AnakiaTask.java 2004-11-29 18:46:35.000000000 +0900
> +++ HttpdSiteDoc.java 2004-11-29 09:30:12.000000000 +0900
> @@ -1,4 +1,4 @@
> -package org.apache.velocity.anakia;
> +package org.apache.httpd.docs;
>
>  /*
>   * Copyright 2001-2004 The Apache Software Foundation.
> @@ -28,6 +28,8 @@
>  import org.apache.tools.ant.DirectoryScanner;
>  import org.apache.tools.ant.Project;
>  import org.apache.tools.ant.taskdefs.MatchingTask;
> +import org.apache.tools.ant.types.Mapper;
> +import org.apache.tools.ant.util.FileNameMapper;
>
>  import org.xml.sax.SAXParseException;
>
> @@ -42,6 +44,12 @@
>  import org.apache.velocity.util.StringUtils;
>
>  import org.apache.velocity.VelocityContext;
> +import org.apache.velocity.anakia.AnakiaJDOMFactory;
> +import org.apache.velocity.anakia.OutputWrapper;
> +import org.apache.velocity.anakia.TreeWalker;
> +import org.apache.velocity.anakia.XPathTool;
> +import org.apache.velocity.anakia.Escape;
> +import org.apache.httpd.docs.Language;
>
>  /**
>   * The purpose of this Ant Task is to allow you to use
> @@ -58,7 +66,7 @@
>   * @author <a href="mailto:szegedia@freemail.hu">Attila Szegedi</a>
>   * @version $Id: AnakiaTask.java,v 1.38 2004/03/20 03:35:50 dlr Exp $
>   */
> -public class AnakiaTask extends MatchingTask
> +public class HttpdSiteDoc extends MatchingTask
>  {
>      /** <code>{@link SAXBuilder}</code> instance to use */
>      private SAXBuilder builder;
> @@ -102,10 +110,13 @@
>      /** the VelocityEngine instance to use */
>      private VelocityEngine ve = new VelocityEngine();
>
> +    /** Mapper to use. */
> +    private Mapper mapperElement = null;
> +
>      /**
>       * Constructor creates the SAXBuilder.
>       */
> -    public AnakiaTask()
> +    public HttpdSiteDoc()
>      {
>          builder = new SAXBuilder();
>          builder.setFactory(new AnakiaJDOMFactory());
> @@ -297,6 +308,18 @@
>      }
>
>      /**
> +     * Defines the mapper to map source to destination files.
> +     * @exception BuildException if more than one mapper is defined
> +     */
> +    public void addMapper(Mapper mapper) {
> +        if (mapperElement != null) {
> +            throw new BuildException("Cannot define more than one
mapper",
> +                                     getLocation());
> +        }
> +        mapperElement = mapper;
> +    }
> +
> +    /**
>       * Process an XML file using Velocity
>       */
>      private void process(File baseDir, String xmlFile, File destDir,
> @@ -310,10 +333,26 @@
>          {
>              // the current input file relative to the baseDir
>              inFile = new File(baseDir,xmlFile);
> -            // the output file relative to basedir
> -            outFile = new File(destDir,
> -                            xmlFile.substring(0,
> -                            xmlFile.lastIndexOf('.')) + extension);
> +
> +            FileNameMapper mapper = null;
> +            if (mapperElement != null) {
> +                mapper = mapperElement.getImplementation();
> +            } else {
> +                mapper = new StyleMapper();
> +            }
> +
> +            String[] outFileName = mapper.mapFileName(xmlFile);
> +            if (outFileName == null || outFileName.length == 0) {
> +                log("Skipping " + inFile + " it cannot get mapped to
output.",
> +                    Project.MSG_VERBOSE);
> +                return;
> +            } else if (outFileName == null || outFileName.length > 1) {
> +                log("Skipping " + inFile + " its mapping is ambiguos.",
> +                    Project.MSG_VERBOSE);
> +                return;
> +            }
> +
> +            outFile = new File(destDir, outFileName[0]);
>
>              // only process files that have changed
>              if (lastModifiedCheck == false ||
> @@ -355,6 +394,8 @@
>                  context.put ("xpath", new XPathTool() );
>                  context.put ("escape", new Escape() );
>                  context.put ("date", new java.util.Date() );
> +                context.put ("fileName", outFile.getName());
> +                context.put ("language", new
Language(inFile.toString()));
>
>                  // only put this into the context if it exists.
>                  if (projectDocument != null)
> @@ -470,4 +511,24 @@
>              }
>          }
>      }
> +
> +
> +    /**
> +     * Mapper implementation of the "traditional" way &lt;xslt&gt;
> +     * mapped filenames.
> +     *
> +     * <p>If the file has an extension, chop it off.  Append whatever
> +     * the user has specified as extension or ".html".</p>
> +     */
> +    private class StyleMapper implements FileNameMapper {
> +        public void setFrom(String from) {}
> +        public void setTo(String to) {}
> +        public String[] mapFileName(String xmlFile) {
> +            int dotPos = xmlFile.lastIndexOf('.');
> +            if (dotPos > 0) {
> +                xmlFile = xmlFile.substring(0, dotPos);
> +            }
> +            return new String[] {xmlFile + extension};
> +        }
> +    }
>  }
> --- /dev/null 2004-09-06 10:55:55.000000000 +0900
> +++ Language.java 2004-11-29 11:10:28.000000000 +0900
> @@ -0,0 +1,67 @@
> +package org.apache.httpd.docs;
> +
> +/*
> + * Copyright 2004 The Apache Software Foundation.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License")
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +import java.util.Vector;
> +import java.io.File;
> +
> +/**
> + * This class is to get available languages for a given file.
> + * It assumes the files follow the pattern *.xml.?? where ?? is
> + * a two letter language code.  If the language code is omitted,
> + * it is assumed to be in English.
> + */
> +public class Language
> +{
> +  public Language(String path) {
> +    this.path = path;
> +  }
> +
> +  public Vector availableLanguages() {
> +    Vector codes = new Vector();
> +    File file = new File(path);
> +
> +    String fileName = file.getName();
> +    int extensionIndex = fileName.lastIndexOf(".xml");
> +    if (extensionIndex != -1) {
> +      fileName = fileName.substring(0, extensionIndex + 4);
> +    }
> +
> +    File parentDir = file.getParentFile();
> +
> +    if (parentDir == null)
> +      return codes;
> +
> +    String[] files = parentDir.list();
> +
> +    for (int i = 0; i < files.length; i++) {
> +      if (files[i].startsWith(fileName)) {
> + if (files[i].equals(fileName)) {
> +   codes.add("en");
> + } else {
> +   String code = files[i].substring(fileName.length() + 1);
> +   if (code.length() == 2) {
> +     codes.add(code);
> +   }
> + }
> +      }
> +    }
> +    return codes;
> +  }
> +
> +  private String path;
> +}
>


----------------------------------------------------------------------------
----


> Index: build.xml
> ===================================================================
> --- build.xml (revision 106705)
> +++ build.xml (working copy)
> @@ -12,24 +12,24 @@
>      </path>
>
>      <target name="prepare">
> -        <available classname="org.apache.velocity.anakia.AnakiaTask"
> -            property="AnakiaTask.present">
> +        <available classname="org.apache.httpd.docs.HttpdSiteDoc"
> +            property="HttpdSiteDoc.present">
>              <classpath refid="classpath"/>
>          </available>
>      </target>
>
> -    <target depends="prepare" name="prepare-error"
unless="AnakiaTask.present">
> +    <target depends="prepare" name="prepare-error"
unless="HttpdSiteDoc.present">
>          <echo>
> -            AnakiaTask is not present! Please check to make sure that
> -            velocity.jar is in your classpath.
> +            HttpdSiteDoc is not present! Please check to make sure that
> +            httpd-docs.jar is in your classpath.
>          </echo>
>      </target>
>
> -    <target name="docs" depends="prepare-error" if="AnakiaTask.present">
> -        <taskdef name="anakia"
classname="org.apache.velocity.anakia.AnakiaTask">
> +    <target name="docs" depends="prepare-error"
if="HttpdSiteDoc.present">
> +        <taskdef name="httpdDocs"
classname="org.apache.httpd.docs.HttpdSiteDoc">
>              <classpath refid="classpath"/>
>          </taskdef>
> -        <anakia basedir="${docs.src}" destdir="${docs.dest}/"
> +        <httpdDocs basedir="${docs.src}" destdir="${docs.dest}/"
>               extension=".html" style="./site.vsl"
>               projectFile="stylesheets/project.xml"
>               excludes="**/stylesheets/** empty.xml **/test/flood/*"
> @@ -37,9 +37,32 @@
>               lastModifiedCheck="true"
>               templatePath="${docs.src}/stylesheets"
>          >
> -        </anakia>
> +        <mapper type="glob" from="*.xml" to="*.html.en"/>
> +        </httpdDocs>
>
> -        <anakia basedir="${docs.src}"
> +        <httpdDocs basedir="${docs.src}" destdir="${docs.dest}/"
> +             extension=".html" style="./site.vsl"
> +             projectFile="stylesheets/ja/project.xml"
> +             excludes="**/stylesheets/** empty.xml **/test/flood/*"
> +             includes="**/*.xml.ja"
> +             lastModifiedCheck="true"
> +             templatePath="${docs.src}/stylesheets"
> +             velocityPropertiesFile="properties/ja"
> +        >
> +        <mapper type="glob" from="*.xml.ja" to="*.html.ja.euc-jp"/>
> +        </httpdDocs>
> +
> +        <httpdDocs basedir="${docs.src}" destdir="${docs.dest}/"
> +             extension=".html" style="./typemap.vsl"
> +             projectFile="stylesheets/lang.xml"
> +             excludes="**/stylesheets/** empty.xml **/test/flood/*"
> +             includes="**/*.xml"
> +             lastModifiedCheck="true"
> +             templatePath="${docs.src}/stylesheets"
> +        >
> +        </httpdDocs>
> +
> +        <httpdDocs basedir="${docs.src}"
>               destdir="${docs.dest}"
>               extension=".html" style="./site.vsl"
>               projectFile="stylesheets/flood.xml"
> @@ -48,7 +71,7 @@
>               lastModifiedCheck="true"
>               templatePath="${docs.src}/stylesheets"
>          >
> -        </anakia>
> +        </httpdDocs>
>
>          <copy todir="${docs.dest}/" filtering="no">
>              <fileset dir="${docs.src}/">
> Index: properties/ja
> ===================================================================
> --- properties/ja (revision 0)
> +++ properties/ja (revision 0)
> @@ -0,0 +1,3 @@
> +file.resource.loader.path=xdocs/stylesheets
> +input.encoding=utf-8
> +output.encoding=euc-jp
> Index: xdocs/stylesheets/lang.xml
> ===================================================================
> --- xdocs/stylesheets/lang.xml (revision 0)
> +++ xdocs/stylesheets/lang.xml (revision 0)
> @@ -0,0 +1,14 @@
> +<?xml version="1.0" encoding="ISO-8859-1"?>
> +<project href="http://httpd.apache.org/">
> +
> +<en>
> +<extension>.en</extension>
> +<charset>iso-8859-1</charset>
> +</en>
> +
> +<ja>
> +<extension>.ja.euc-jp</extension>
> +<charset>euc-jp</charset>
> +</ja>
> +
> +</project>
> Index: xdocs/stylesheets/typemap.vsl
> ===================================================================
> --- xdocs/stylesheets/typemap.vsl (revision 0)
> +++ xdocs/stylesheets/typemap.vsl (revision 0)
> @@ -0,0 +1,6 @@
> +#foreach ( $lang in $language.availableLanguages() )
> +URI: ${fileName}$project.getChild($lang).getChild("extension").getText()
> +Content-Language: $lang
> +Content-Type: text/html;
charset=$project.getChild($lang).getChild("charset").getText()
> +
> +#end
> Index: xdocs/stylesheets/site.vsl
> ===================================================================
> --- xdocs/stylesheets/site.vsl (revision 106705)
> +++ xdocs/stylesheets/site.vsl (working copy)
> @@ -247,6 +247,13 @@
>      </td>
>     </tr>
>     <!-- FOOTER -->
> +   <tr><td colspan="2" align="right">
> +     Available Languages:
> +     #set ($baseHtml = $fileName.substring(0,
$fileName.lastIndexOf(".html")))
> +     #foreach ( $lang in $language.availableLanguages() )
> +       <a href="$relativePath/${baseHtml}.html.$lang">$lang</a>
> +     #end
> +   </td></tr>
>     <tr><td colspan="2"><hr noshade="noshade" size="1"/></td></tr>
>     <tr><td colspan="2" align="center">
>          <font size="-1">
> @@ -258,3 +265,4 @@
>   </body>
>  </html>
>  #end
> +
> Index: xdocs/stylesheets/ja/project.xml
> ===================================================================
> --- xdocs/stylesheets/ja/project.xml (revision 0)
> +++ xdocs/stylesheets/ja/project.xml (revision 0)
> @@ -0,0 +1,48 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<project href="http://httpd.apache.org/">
> +
> +<title>The Apache HTTP Server Project</title>
> +<body>
> +<menu><title>??</title>
> +  <li><a href="/ABOUT_APACHE.html">Apache ????</a></li>
> +  <li><a href="http://www.apache.org/licenses/">?????</a></li>
> +  <li><a href="/docs/misc/FAQ.html">FAQ</a></li>
> +  <li><a href="/security_report.html">??????<br />????</a></li>
> +</menu>
> +
> +<menu><title>??????!</title>
> +  <li><a href="/download.cgi">?????</a></li>
> +</menu>
> +
> +<menu><title href="/docs-project/">??????</title>
> +  <li><a href="/docs/">Apache 1.3</a></li>
> +  <li><a href="/docs-2.0/">Apache 2.0</a></li>
> +</menu>
> +
> +<menu><title>????</title>
> +  <li><a href="/lists.html">????????</a></li>
> +  <li><a href="/bug_report.html">????</a></li>
> +  <li><a href="/dev/">????????</a></li>
> +</menu>
> +
> +<menu><title>????????</title>
> +  <li><a href="/docs-project/">Docs</a></li>
> +  <li><a href="/test/">Test</a></li>
> +  <li><a href="/test/flood/">Flood</a></li>
> +  <li><a href="/apreq/">libapreq</a></li>
> +  <li><a href="/modules/">Modules</a></li>
> +  <li><a href="/cli/">cli (.NET)</a></li>
> +</menu>
> +
> +<menu><title href="/info/">???</title>
> +  <li><a href="/contributors/">????</a></li>
> +  <li><a href="/awards.html">?</a></li>
> +  <li><a href="http://webring.com/hub?ring=apachesupport"
> +      >????<br />??????</a></li>
> +</menu>
> +<!--
> +  <LI><A HREF="announcelist.html">Announcements via Email</A>
> +  <LI><A HREF="related_projects.html">Related Projects</A>
> +-->
> +</body>
> +</project>
>


----------------------------------------------------------------------------
----


>
>
> --
> Yoshiki Hayashi
>
>


----------------------------------------------------------------------------
----


> ---------------------------------------------------------------------
> To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
> For additional commands, e-mail: docs-help@httpd.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org


Mime
View raw message