cancel
Showing results for 
Search instead for 
Did you mean: 

wcmqs multilingual

rmorant
Champ in-the-making
Champ in-the-making
I'm thinking the best way to do a multilingual site based in wcmqs.
Firstable i translated the alfresco/messages/common.properties to I10n named files, and was okay.
But for the documents… i was reading http://wiki.alfresco.com/wiki/Multilingual_Document_Support and i'm not sure to understand it.
Are there any examples available?
Anyway, may be more useful handle a site by language, each with his own documents and publication workflow.
In this case the locale should be part of WebSite data handled by WebSite Service in order to select the right site.
For now, I can only instantiate a webapp for each language and play with his context (/wcmqs, /wcmqs_es, /wcmqs_fr, …)

What is the best way to approach this problem?

Any suggestions are welcome.

thanks
4 REPLIES 4

bremmington
Champ on-the-rise
Champ on-the-rise
Funnily enough, this is a topic that we're talking about at Alfresco now with a view to providing an out-of-the-box solution in a future release. There is always a slight problem with multi-lingual sites, in that different people want to manage them in different ways. Some want to manage the content for each language as a separate site (different site structure), while others prefer to have a single site structure and have the appropriate translation selected at request time. As you say, in the first case you'd want to include the locale in the site-selection logic. In the second case you'd want to use the locale in the asset-selection logic.

The simplest approach if you wish to tackle this yourself is the one where you have a different website structure in the repo for each language. In this case you could perhaps use sub-domains to select the site you want:

  es.example.com
  fr.example.com
  en.example.com
Another possibility worth considering is replacing the ApplicationDataInterceptor with your own implementation that takes the first segment of the requested path (the bit after "wcmqs" in the default installation) and appends it to the contextPath before calling websiteService.getWebSite(…). Just to clarify that a little, if a request comes in for:

    http://www.example.com/wcmqs/fr/news/global/article1
then the call to getWebSite has the arguments: "www.example.com", 80, and "/wcmqs/fr"  (note the addition of "/fr" on the context path)

Similarly, the "/fr" is then stripped from the path that is subsequently passed into the call to webSite.getAssetByPath (so this method is passed "/news/global/article1"). It would be sensible to store the selected locale as a thread local too so that it can be used to select static text from the appropriate message bundle and can also be used by a tweaked implementation of the UrlUtils interface to produce outbound URLs in the correct format.

I don't know if that's a step too far for you right now, but, if so, it is something that we will address as early as we can.

rmorant
Champ in-the-making
Champ in-the-making
Thank you.
I think the <contextPath>/<lang> solution it's ok for this application because the content can be different for each location while the desing don't change.
In other service like a product catalog should be at asset level the selection logic.
I need both, i will follow your development.

Thanks again.

rmorant
Champ in-the-making
Champ in-the-making
I have changed ApplicationDataInterceptor


  public boolean preHandle(…

        String lang = request.getPathInfo().split("/")[1];
        WebSite webSite = webSiteService.getWebSite(serverName, serverPort, contextPath+"/"+lang);
        String path = request.getPathInfo().substring(lang.length()+1);

but in webSiteService.getWebSite() call throws the following exception.


java.lang.NoSuchMethodError: org.json.JSONTokener.<init>(Ljava/io/Reader;)V
   at org.alfresco.wcm.client.impl.WebScriptCallerImpl.getJsonObject(WebScriptCallerImpl.java:121)
   at org.alfresco.wcm.client.impl.WebSiteServiceImpl.getWebsiteInfo(WebSiteServiceImpl.java:247)
   at org.alfresco.wcm.client.impl.WebSiteServiceImpl.refreshWebsiteCache(WebSiteServiceImpl.java:187)
   at org.alfresco.wcm.client.impl.WebSiteServiceImpl.getWebSiteCache(WebSiteServiceImpl.java:152)
   at org.alfresco.wcm.client.impl.WebSiteServiceImpl.getWebSite(WebSiteServiceImpl.java:119)
        at org.gestorweb.site.client.interceptor.ApplicationDataInterceptor.preHandle(ApplicationDataInterceptor.java:42)
   at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:761)

The json response to GET /alfresco/service/api/websiteinfo?websiteid=workspace%3A%2F%2FSpacesStore%2F0e1c90ad-d393-4379-8643-76d7227617d2


{
    data: {
        "rootsectionid" : "workspace://SpacesStore/83242220-1b1c-4843-87ba-b5ad82adf833",
        "feedbackfolderid" : "workspace://SpacesStore/06c64b2d-e476-4a04-a92f-1c4784f68408",
    }
}

from where the last comma?
It's an error on server side?

any ideas?

bremmington
Champ on-the-rise
Champ on-the-rise
The NoSuchMethodError suggests that you may be linking to the incorrect json library (json.jar) in your webapp. Although the comma you mention is unnecessary, it is also not harmful. Is there a possibility that you have pulled in a different json.jar from the one we use? That would be my best guess based on what you've said.