cancel
Showing results for 
Search instead for 
Did you mean: 

The best way to create multilingual site

d_mon
Champ in-the-making
Champ in-the-making
I want to create multilingual website using WCM. What will be the best way to handle multilingual content? Is it possible, say, to create a select in the form, where u can select a language; and then, depending on the value of this select store generated xml in the different folder? Or what is the preferred way?
Any help greatly appreciated!

Thanks in andvance,
Dmitry
7 REPLIES 7

kvc
Champ in-the-making
Champ in-the-making
Yes.  In your output path, you have access to individual fields captured within your Web Form.   You can use one of these values to construct either the filename or path for your generated XML.  So, you can have a generic article form and the user can when opening the form select a given language with the generated XML stored in either a /content/en/form_type/foo.xml or /content/fr/form_type/foo.xml depending on whether the user selected English or French.  The tooltip for output paths should have an example here.

Kevin

arielb
Champ in-the-making
Champ in-the-making
to further elaborate on kevin's response, what i'd recommend is the following.  in your schema, have selectonemenu which would be based on something like this:


<xs:schema xmlns:xs="…" xmlns:alf="http://www.alfresco.org" elementFormDefault="qualified">
  <xs:simpleType name="language">
    <xs:restriction base="xs:normalizedString">
      <xs:enumeration value="en">
        <xs:annotation>
          <xs:appinfo><alf:label>English</alf:label></xs:appinfo>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="fr">
        <xs:annotation>
          <xs:appinfo><alf:label>French</alf:label></xs:appinfo>
        </xs:annotation>
      </xs:enumeration>
      … other languages …
    </xs:restriction>
  </xs:simpleType>
  <xs:element name="my_form">
    <xs:complexType>
      <xs:element name="language" type="language"/>
      … other fields …
    </xs:complexType>  
  </xs:element>
</xs:schema>

then, in selecting the output path for your form instance data, you can use something like:
/${webapp}/${xml.my_form.languague}/${name}.xml

note that if your xml nodenames contain characters that are invalid for java properties (most frequently -), you'll can use square bracket notation with xpath such as


/${webapp}/${xml["my-form/language"]}/${name}.xml

d_mon
Champ in-the-making
Champ in-the-making
And what if I want to create the form with only one language-dependent component (say article with language-dependent body and common title)?
Do I need to create 2 xsl files to put instance data to different folders?

Thanks,
Dmitry

terry_tao
Champ in-the-making
Champ in-the-making
Hi, all

I create one file according to your said, but it failure.
Please help me correct it.

Thanks in advance.

Error Message:

Please correct the errors below then click Finish.
Error processing output path pattern <#ftl ns_prefixes={ "alf":"_http://www.alfresco.org", "alfdotcom":"_http://www.inventec.com.cn/bodycontent", "chiba":"_http://chiba.sourceforge.net/xforms", "ev":"_http://www.w3.org/2001/xml-events", "xf":"_http://www.w3.org/2002/xforms", "xhtml":"_http://www.w3.org/1999/xhtml", "xs":"_http://www.w3.org/2001/XMLSchema", "xsi":"_http://www.w3.org/2001/XMLSchema-instance"}> /${webapp}/${xml["form/lang"]}/${name}.xml for mmindex in webapp ROOT: Error during processing of the template 'Error on line 10, column 14 in s


Source File:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:alf="http://www.alfresco.org"
   xmlns:alfdotcom="http://www.inventec.com.cn/bodycontent"
   targetNamespace="http://www.inventec.com.cn/bodycontent" elementFormDefault="qualified">
   <xs:simpleType name="language">
    <xs:restriction base="xs:normalizedString">
      <xs:enumeration value="en">
        <xs:annotation>
          <xs:appinfo><alf:label>English</alf:label></xs:appinfo>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="fr">
        <xs:annotation>
          <xs:appinfo><alf:label>French</alf:label></xs:appinfo>
        </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>
<xs:element name="form">
<xs:complexType>
<xs:sequence>
<xs:element name="lang" type="alfdotcom:language"/>
<xs:element name="page_title" type="xs:normalizedString"/>
</xs:sequence>
</xs:complexType>   
</xs:element>
</xs:schema>

output path:
/${webapp}/${xml.form.lang}/${name}.xml
or
/${webapp}/${xml["form/lang"]}/${name}.xml

randomman
Champ in-the-making
Champ in-the-making
I was playing around with this kind of thing last week. I found that I had to specify things a bit more and use an output path equivalent to this:

/${webapp}/${xml["alfdotcom:form/alfdotcom:lang"]}/${name}.xml

tonizz
Champ in-the-making
Champ in-the-making
I have been trying with a code similar to yours and the problem was that you can´t call your new "simpleType" as "language" because there exists another type called language. I only have had to rename the name of the simpleType.

terry_tao
Champ in-the-making
Champ in-the-making
Thanks Random and tonizz. Smiley Very Happy

I can run it successfully.

By the way, i have another question about it.
Does we need to add these codes in every web form (XSD)?
I think it is a large workload.
Do you have a easier method to implement it?

Thanks for your help again.

Terry