[opencms-dev] OpenCMS website localization

Michael Moossen m.moossen at alkacon.com
Tue Sep 23 11:48:27 CEST 2008


Hi!

Just to tell that i got it working... i have one folder structure in 
OpenCms and it looks like several localized folders from the outside.

All i needed is:
- a locale handler that selects the locale from the folder prefix,
- a resource init handler that removes the folder prefix from incoming 
requests, and
- the most important is the link substitution handler that will teach 
OpenCms to link resources as we need.

My link substitution handler is mainly based on the test link 
substitution handler (which shows how to combine both approaches) see 
opencms/test/org/opencms/staticexport/CmsTestLinkSubstitutionHandler.java 
on CVS.

HTH

Kind regards,
Michael

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

Alkacon Software GmbH  - The OpenCms Experts
http://www.alkacon.com - http://www.opencms.org


Martin Wunderlich wrote:
> Hi Claus and Michael,
> 
> Talking of properties, is there a way to make properties work in the 
> HTML content that is wrapped in the XML of the pages? I would like to be 
> able to pull in strings from properties files, but so far we have only 
> managed to make this work in the templates, not in the actual XML pages 
> itself. The reason being that all the HTML is escaped as CDATA sections, 
> so any JSP code that is placed in the HTML is output as a literal string 
> and not interpreted as JSP.
> 
> Cheers,
> 
> Martin  
> 
> 
> On 19/09/2008 17:50, "Michael Moossen" <m.moossen at alkacon.com> wrote:
> 
>     Hi Claus!
> 
>      > After attending your session on CRE in the OpenCms days I was
>     thinking
>      > that one could somehow utilize the generic relationship mechanism to
>      > create such a type of "translation of" relationship.
>     you are not the only one having this idea ;)
> 
>     thank you also for your additional ideas to the subject, indeed there
>     are localized websites that can be easier implemented with the
>     one-folder-per-locale than the all-locales-in-one-folder approach as
>     vice-versa... and in any case you will have some use cases that will
>     have some kind of problems, it does not matter what do you choose.
> 
>     So, IMHO both approaches are equally important.
> 
>     And you mentioned the properties issue which i forgot to write about
>     yesterday. Indeed, if you use xmlpages you are damned, you have to use
>     properties, like title, description, etc (you could think that an
>     additional element in the xmlpage could help, but then the FCKEditor
>     will append some html markup you will have to remove later in your
>     template... so no go for xmlpages), but using xmlcontents solves
>     everything you have just to prevent the properties get indexed by Lucene
>     and that's all.
> 
>     Kind regards,
>     Michael
> 
>     -------------------
> 
>     Alkacon Software GmbH  - The OpenCms Experts
>     http://www.alkacon.com - http://www.opencms.org
> 
> 
>     Claus Priisholm wrote:
>     >  Hi Michael
>     >
>     >  Just adding my 10 cents to the discussion...
>     >
>     >  I'm all for the one top-level folder per locale. It is the most
>     flexible
>     >  and gives a simple solution to localized properties as well, even on
>     >  folders.
>     >
>     >  In some cases it makes sense to have shared content (i.e.
>     siblings) and
>     >  in others it don't (i.e. full copies).
>     >
>     >  In my experience it is mostly a organisational issue as to who can do
>     >  what and how the translation of the pages is handled. Typically if
>     each
>     >  locale is maintained by a country manager or likewise, or the site
>     >  content/structure is allowed to become different from locale to
>     locale,
>     >  then siblings are not the way to go.
>     >
>     >  Basically the problem is that publishing is not independent between
>     >  locales so you run the risk of a typo on say the English page
>     cannot be
>     >  fixed because the translation of the Korean page is still under
>     way. And
>     >  from an organisational point of view it may be that under no
>     >  circumstances should a country manager be able to publish anything
>     >  related to the international site... In these cases full copies are
>     >  required.
>     >
>     >  But even when one can work with siblings it is, as you mention,
>     somewhat
>     >  of a challenge to keep things in sync. Siblings as well as copies are
>     >  too generic, they do not themselves imply a "translation of"
>     >  relationship between the resources.
>     >
>     >  After attending your session on CRE in the OpenCms days I was thinking
>     >  that one could somehow utilize the generic relationship mechanism to
>     >  create such a type of "translation of" relationship. If so the UI
>     would
>     >    have to have some handles to maybe automatically create stub
>     copies or
>     >  siblings for each locale (according to some kind of configuration) and
>     >  so forth.
>     >
>     >  I haven't had an excuse (nor time) to look further into the
>     subject, but
>     >  maybe you can shed some light on whether or not it would be
>     feasible to
>     >  use CRE for that?
>     >
>     >  best regards
>     >  Claus
>     >
>     >  Michael Moossen wrote:
>     > > Hi,
>     > >
>     > > I just want to share my experience with content localization.
>     > >
>     > > As far as i know all projects developed by Alkacon (normally i work
>     > > developing the core) that had to deal with localization were
>     using the
>     > > several folders with siblings approach. Which is, in my opinion,
>     quite
>     > > easy to setup but not to maintain, despite some project were also
>     > > including different approaches to automatic sibling creation.
>     > >
>     > > So when i started to develop my first website from scratch with
>     OpenCms
>     > > (http://www.moossen.net/) a couple of weeks ago, i tried a different
>     > > approach.
>     > > And i thought it would be enough with a single folder structure
>     for all
>     > > locales, a 10 LOC locale handler (see
>     > > org.opencms.i18n.I_CmsLocaleHandler) and a cookie.
>     > >
>     > > But this turned out to be a very bad and naive idea, mainly
>     because one
>     > > URL is having different content:
>     > > - try to flush browser cache when the user changes the locale.
>     > > - try to tell google that he has to set a cookie for indexing
>     different
>     > > languages.
>     > > - The same applies also for the static export, and everything else...
>     > >
>     > > so, for now i am just appending a meaningless lang parameter to every
>     > > url, which is working but awful :(
>     > >
>     > > But i learnt by heart that you MUST have different URLs for different
>     > > locales.
>     > >
>     > > My next try will be (as soon as i get the time for it) to implement a
>     > > resource initialization handler (see
>     org.opencms.main.I_CmsResourceInit)
>     > > with a link substitution handler (see
>     > > org.opencms.staticexport.I_CmsLinkSubstitutionHandler).
>     > >
>     > > The idea is to have in OpenCms a single folder structure that
>     will look
>     > > to the outside world like several folders for the locales.
>     > >
>     > > On one side, the resource initialization handler will intercept the
>     > > requests and remove the leading locale folder from the URL (if you
>     > > request /en/index.html, it will read the OpenCms resource at
>     /index.html).
>     > >
>     > > And the link substitution handler will generate the links with a
>     locale
>     > > folder prefix. (if in /index.html you have a link to
>     /about/contact.html
>     > > (and let say the selected locale is en (with a cookie, for
>     instance), it
>     > > will generate in the html output a link to /en/about/contact.html.
>     > >
>     > > I hope this will workout as i expect, and i was just checking the API
>     > > and it seems to be easier to implement than i thought, so i
>     better start
>     > > to code now ;)
>     > >
>     > > Hope that helps
>     > >
>     > > Kind regards,
>     > > Michael
>     > >
>     > >
>     > >
>     > > Carl Alex Friis Nielsen wrote:
>     > >> No - the content resides in the resource.
>     > >> The locale property can be set by simply having all material
>     that shall
>     > >> be available for a given
>     > >> locale under a folder with its locale property set to the
>     desired locale.
>     > >> It really is quite simple to set up and use.
>     > >>
>     > >>     -----Original Message-----
>     > >>     *From:* opencms-dev-bounces at opencms.org
>     > >>     [mailto:opencms-dev-bounces at opencms.org]*On Behalf Of
>     *Martin Wunderlich
>     > >>     *Sent:* Monday, September 15, 2008 11:57 AM
>     > >>     *To:* The OpenCms mailing list
>     > >>     *Subject:* Re: [opencms-dev] OpenCMS website localization
>     > >>
>     > >>     OK, but that means the content needs to be externalised to
>     > >>     properties files, right? In our case, we non-technical people
>     > >>     creating the original English content and they wouldn’t
>     necessarily
>     > >>     know how to work with properties files.
>     > >>
>     > >>     Cheers,
>     > >>
>     > >>     Martin
>     > >>
>     > >>
>     > >>     On 15/09/2008 10:35, "Carl Alex Friis Nielsen" <cfn at kb.dk>
>     wrote:
>     > >>
>     > >>         You have multiple locales in the same resource.
>     > >>         Which locale is displayed depends on the locale property
>     of the
>     > >>         resource.
>     > >>         Different siblings can have different locale properties.
>     > >>         The properties can be inherited from the folder hierachy
>     in the VFS.
>     > >>
>     > >>         AFAIK this is a very widely used way to handle multilingual
>     > >>         content in OpenCms.
>     > >>
>     > >>
>     > >>             -----Original Message-----
>     > >>             *From:*  opencms-dev-bounces at opencms.org
>     > >>             [mailto:opencms-dev-bounces at opencms.org]*On  Behalf Of
>     > >>             *Martin Wunderlich
>     > >>             *Sent:* Monday, September 15, 2008  11:11 AM
>     > >>             *To:* The OpenCms mailing list
>     > >>             *Subject:* Re:  [opencms-dev] OpenCMS website
>     localization
>     > >>
>     > >>             Hi  Steve,
>     > >>
>     > >>             Are you saying that you’re using the siblings
>     mechanism for
>     > >>              content in different languages? How would that
>     work? AFAIK,
>     > >>             siblings are  basically pointers to the exact same
>     content.
>     > >>
>     > >>             About the web services  interface, does OpenCms somehow
>     > >>             support SOAP calls at the moment?
>     > >>
>     > >>             Kind  regards,
>     > >>
>     > >>             Martin
>     > >>
>     > >>
>     > >>             On 15/09/2008 10:01, "Steve Bryan"
>     > >>             <steve at bright-interactive.com>  wrote:
>     > >>
>     > >>
>     > >>
>     > >>                 Hi
>     > >>
>     > >>                 One usability problem we found is that  when an
>     editor
>     > >>                 creates a page in one
>     > >>                 language folder (eg under en), the  siblings do
>     not get
>     > >>                 created automatically
>     > >>                 in the other language folders  (which for us is
>     > >>                 generally required except for
>     > >>                 the odd case that the  pages are only in one of the
>     > >>                 locales).
>     > >>
>     > >>                 One solution to this would be  to customize
>     OpenCms to add a
>     > >>                 'copy-to-all-locales' function, either on  the
>     create
>     > >>                 dialog or (more easily)
>     > >>                 as a separate context menu function.  The latter
>     can be
>     > >>                 done by adapting the
>     > >>                 regular copy function to copy out  siblings to
>     the other
>     > >>                 locale folders.
>     > >>
>     > >>                 An associated problem (which I  think Martin is
>     > >>                 referring to), is that title
>     > >>                 & navtext properties etc  would normally need to be
>     > >>                 translated as well as
>     > >>                 elements of pages and  structured types. One
>     work-around
>     > >>                 for this, is to add
>     > >>                 title and nav-text  page elements, and use them
>     instead
>     > >>                 of the properties in
>     > >>                 the template  navigation. The ideal is to ensure
>     that
>     > >>                 all properties are
>     > >>                 locale  independent (and hence a straight
>     sibling copy
>     > >>                 does the job). Any
>     > >>                 locale  dependent stuff should go in page
>     elements. Then
>     > >>                 only the page  bodies
>     > >>                 need translation.
>     > >>
>     > >>                 After that, we have a batch translation  system that
>     > >>                 sounds like a much less
>     > >>                 advanced version of Martin's :-) - ie  exporting
>     pages,
>     > >>                 getting the
>     > >>                 translation company to fill in the control
>      code, then
>     > >>                 re-importing. The web
>     > >>                 services idea sounds  good.
>     > >>
>     > >>                 Steve
>     > >>
>     > >>
>     > >>
>                     ----------------------------------------------------------------------
>     > >>
>     > >>                 Date:  Fri, 12 Sep 2008 11:23:52 +0100
>     > >>                 From: "Martin Wunderlich"
>     <mwunderlich at salesforce.com>
>     > >>                 Subject:  Re: [opencms-dev] OpenCMS website
>     localization
>     > >>                 To: "The OpenCms mailing  list"
>     <opencms-dev at opencms.org>
>     > >>                 Message-ID:
>      <C4F001C8.2D0D%mwunderlich at salesforce.com>
>     > >>                 Content-Type:  text/plain; charset="iso-8859-1"
>     > >>
>     > >>                 Hi David,
>     > >>
>     > >>                 We currently have  17 different locales on our
>     website
>     > >>                 (5 of them English
>     > >>                 language) and it  works somehow like this:
>     > >>
>     > >>                  *   The localised sites are  located under sub
>     folders
>     > >>                 of the main domain,
>     > >>                 whereby the subfolder name  consists of the ISO
>     country
>     > >>                 ID, e.g.
>     > >>                 www.salesforce.com/es for  Spanish.
>     > >>                  *   Some locale specific content is
>     externalised  to
>     > >>                 properties files, but
>     > >>                 not the main body text of the pages.
>     > >>                  *    Translation is generally a one way street from
>     > >>                 en-US to all the  other
>     > >>                 locales.
>     > >>                  *   To get a web page translated, we  run an export
>     > >>                 that picks up the
>     > >>                 respective pages, based on a custom  property
>     that we
>     > >>                 have included in the
>     > >>                 templates. The export file then  gets dumped to
>     an FTP
>     > >>                 server, from where it
>     > >>                 is picked up every so often  by the translation
>     > >>                 management system (feels a
>     > >>                 bit ancient, IMHO; this  should happen in real time
>     > >>                 through a web services
>     > >>                 interface).  We do  some automated tweaks to the
>     > >>                 manifest file of the export
>     > >>                 file (replace  locales IDs and such) and then import
>     > >>                 back into OpenCms.
>     > >>
>     > >>                 Some things  that I really miss are better
>     support for
>     > >>                 image localisation,
>     > >>                 the web  services interface mentioned above, and a
>     > >>                 better OpenCms interface
>     > >>                 for  sending files for translation. Also, it
>     would be
>     > >>                 great to have a  WYSIWYG
>     > >>                 interface for externalising information to
>     properties
>     > >>                 files, so  that
>     > >>                 non-technical content editors can create
>     properties on
>     > >>                 the  fly.
>     > >>
>     > >>                 Cheers,
>     > >>
>     > >>                 Martin
>     > >>
>     > >>
>     > >>                 On 01/09/2008 11:41, "David  Valls roure"
>     > >>                 <david.valls at sogeti.com>  wrote:
>     > >>
>     > >>                 Hi All,
>     > >>
>     > >>                 i'm having some issues regarding web site
>      localization
>     > >>                 and I want to
>     > >>                 review if i'm doing well...
>     > >>
>     > >>                 This are my  steps:
>     > >>                 1.- new folder www at /sites/default
>     > >>                 1.1.-  properties-advanced-locale: en
>     > >>                 2.- some content-> pages with free  text
>     > >>                 3.- new folder news at www
>     > >>                 4.- add some news inside
>     > >>
>     > >>                 ok,  now i have my website in english
>     > >>
>     > >>                 How to localize?
>     > >>
>     > >>                 1.- copy  all, even siblings from www to www_es
>     > >>                 2.- Administration-> Merge pages  -> from www 2
>     www_es
>     > >>                 3.- Change locale-> www_es (include  subfolders)
>     from en
>     > >>                 2 es
>     > >>                 4.- Open website and traduce all...
>     > >>                 That's  what i've done.
>     > >>
>     > >>                 repeat this steps for other languages...
>     > >>
>     > >>                 The  first thing i want to know if i'm doing well...
>     > >>                 because now i have
>     > >>                 a  problem: when i add content like pages with
>     free text
>     > >>                 i can merge
>     > >>                 and  goon, but with news i cannot localize them... i
>     > >>                 can't copy them  to
>     > >>                 corresponding language folder...
>     > >>
>     > >>                 How do i create localized  (multilanguage) sites?
>     > >>                 How do i mantain localized (multilanguage)  sites?
>     > >>
>     > >>                 Thanks in  advice,
>     > >>
>     > >>                 David.
>     > >>
>     > >>
>     > >>
>     > >>
>     > >>
>     > >>                 _______________________________________________
>     > >>                 This  mail is sent to you from the opencms-dev
>     mailing list
>     > >>                 To change your list  options, or to unsubscribe
>     from the
>     > >>                 list, please visit
>     > >>
>                     http://lists.opencms.org/mailman/listinfo/opencms-dev
>     > >>
>     > >>
>     > >>
>     > >>
>     ------------------------------------------------------------------------
>     > >>
>     > >>
>     > >> _______________________________________________
>     > >> This mail is sent to you from the opencms-dev mailing list
>     > >> To change your list options, or to unsubscribe from the list,
>     please visit
>     > >> http://lists.opencms.org/mailman/listinfo/opencms-dev
>     > > _______________________________________________
>     > > This mail is sent to you from the opencms-dev mailing list
>     > > To change your list options, or to unsubscribe from the list,
>     please visit
>     > > http://lists.opencms.org/mailman/listinfo/opencms-dev
>     > >
>     >
> 
>     _______________________________________________
>     This mail is sent to you from the opencms-dev mailing list
>     To change your list options, or to unsubscribe from the list, please
>     visit
>     http://lists.opencms.org/mailman/listinfo/opencms-dev
> 
> 
> ------------------------------------------------------------------------
> 
> 
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev



More information about the opencms-dev mailing list