Which would be the best approach to make a multi lingual website using FW/1

166 views
Skip to first unread message

dehian

unread,
Mar 2, 2012, 9:04:27 AM3/2/12
to framework-one

Hi,

it's my first app using FW/1 or any other framework and also the first
time i'm using a MVC pattern
i'm using the provided SESURL functionnality provided by FW/1 to have
clean URLS
but I'd like to make this app multi lingual

Let's say i want this website in English en French
Let's say i have a controller called "ads" with a method "insert"
the buildurl method will return something like "www.mysite.com/EN/ads/
insert"
even in french i will get a "www.mysite.com/FR/ads/insert" instead of
"www.mysite.com/FR/annonces/ajouter"

and so my question is, what would be the best way to achieve this?
Do i have to create controlers in french that extends the english
controller?

What would also be the best practice to manage the translated labels
in such a context?

Thanks for any idea

dehian

unread,
Mar 3, 2012, 3:48:24 PM3/3/12
to framework-one
Come on, i'm sure i'm not the one who is using FW/1 for a multi
lingual website ;)

Joe Brislin

unread,
Mar 3, 2012, 5:00:45 PM3/3/12
to framew...@googlegroups.com
I would think that you would be able to use URL Routes for this. I'm sure you can use that to handle the language differentiation of /FR, /EN, etc. I'm not sure about the multi-lingual URLs. I've never attempted that before. While I haven't used FW/1 for a multi-lingual site yet, I did something similar utilizing routes in the .NET MVC Framework. Hope this helps.
variables.framework.routes = [
  { "/product/:id" = "/product/view/id/:id", "/user/:id" = "/user/view/id/:id",
    hint = "Display a specific product or user" },
  { "/products" = "/product/list", "/users" = "/user/list" },
  { "/old/url" = "302:/new/url" },
  { "$GET/login" = "/not/authorized", "$POST/login" = "/auth/login" },
  { "*" = "/not/found" }
];

Thanks,
Joe

Thanks,
Joe Brislin


cfx...@gmail.com

unread,
Mar 3, 2012, 8:54:54 PM3/3/12
to framew...@googlegroups.com
I think you would basically do it the same way you would for a non fw/1 site, usually I see folks using resource bundles for this.  You could use routes to handle the url mappings I believe.

Sent from my HTC smartphone on the Now Network from Sprint!

dehian

unread,
Mar 5, 2012, 4:42:10 AM3/5/12
to framework-one
Yeah i guess there are different ways to do it
But as i start a new app i would like to go "best practices"
So i would have liked to hear from experienced users having worked on
a multilingual project to know how they did
I saw that someone wrote a "fw/1 - languages" plugin on riaforge
( http://fw1lang.riaforge.org/ ) (but i didn't manage to make it
work...)
And as it uses text files instead of a database so i'm not sur this
goes "best practices" for an app that will have a lot of labels to
support.

Thanks again for any help

Seth Johnson

unread,
Mar 5, 2012, 8:32:02 AM3/5/12
to framew...@googlegroups.com
BlogCFC uses resource bundles, that code would be one place to look for examples on how to accomplish this.  I think Ray originally used this project for that implementation: http://cfi18n.riaforge.org/

Seth

Sean Corfield

unread,
Mar 5, 2012, 12:00:37 PM3/5/12
to framew...@googlegroups.com
On Mon, Mar 5, 2012 at 1:42 AM, dehian <deh...@hotmail.com> wrote:
> Yeah i guess there are different ways to do it
> But as i start a new app i would like to go "best practices"

I don't think there's is One True Way so "whatever works" is going to
be your best solution.

Specifically, most people have one URL structure but switch languages
on the fly for display using traditional i18n solutions based on Java
resource bundles (Google is your friend).

At World Singles, we support over half a dozen languages and we use a
variant of resource bundles - we store the translations in the
database, keyed by locale and a string "key" for each item, so that we
can have a management console for translators to work with (we have a
fairly sophisticated content review / push mechanism). We keep the
same URL structure for all languages.

I can't recall seeing a web site that goes to the trouble of translating URLs.
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

Richard Tugwell

unread,
Mar 5, 2012, 1:37:04 AM3/5/12
to framework-one
Sorry I'm a bit late to this.

Our applications are multilingual - at least the interface is - and we
use Paul Hastings JavaRB (http://www.sustainablegis.com/unicode/
resourceBundle/javaRB.cfm).

This works a treat, but don't underestimate the amount of work
involved in coding a site for multilingual use. A resource bundle
editor is a great help. I use the Eclipse one in CFBuilder (http://
sourceforge.net/projects/eclipse-rbe/) although I'm not saying it's
the best available - haven't tried many others. There's also the
standalone attesoro which is handy if you're passing properties files
to translators who don't use an IDE and need a simple editor...
http://attesoro.org/

Regarding URL's, if you have a dynamic site, then I don't see the need
for multilingual URL's - just store the language in the session scope,
and pass that to your Resource Bundle processing.

Because you need to access the RB object in the views, I just
instantiate it in the Application scope, and pass a reference to it in
the request scope (not necessary of course - I just don't like seeing
"application." in my views. So from that point of view it's
independent of FW/1 - although all recent development is utilising FW/
1 and DI/1

For a full multilingual site - where the content is multilingual - you
have another problem to solve, but that is in the persistence layer
where you will need multiple version stored for each language. This is
also a lot of work depending on your content, number of languages,
frequency of updates etc.

dehian

unread,
Mar 5, 2012, 5:05:29 PM3/5/12
to framework-one
In fact, my point for translating the urls is that i'm refactoring a
website that has hardcoded translated urls with a simple mecanism of
translating hardcoded url through a custom tag (some sort of
buildurl() in fact ) and i wanted to keep those urls the way they are
for now (to ensure that it won't affect SEO aspect)

so i'm looking for a solution to translate those urls as "easily" and
as clean as I can.

Now for the ressource bundle thing, why not simply say :
i have a database table with "id,locale,keyString,keyValue"
i load all the labels in an array or struct at the application startup
and cache them and then call them in the views by index or struct key
what's the benefit of using ressource bundle instead of this?
(might be a silly question...)

Thanks for your help

On 5 mar, 07:37, Richard Tugwell <r.tugw...@forthmedia.com> wrote:
> Sorry I'm a bit late to this.
>
> Our applications are multilingual - at least the interface is - and we
> use Paul Hastings JavaRB (http://www.sustainablegis.com/unicode/
> resourceBundle/javaRB.cfm).
>
> This works a treat, but don't underestimate the amount of work
> involved in coding a site for multilingual use. A resource bundle
> editor is a great help. I use the Eclipse one in CFBuilder (http://
> sourceforge.net/projects/eclipse-rbe/) although I'm not saying it's
> the best available - haven't tried many others. There's also the
> standalone attesoro which is handy if you're passing properties files
> to translators who don't use an IDE and need a simple editor...http://attesoro.org/

dehian

unread,
Mar 5, 2012, 5:17:56 PM3/5/12
to framework-one
I saw some sample code online of someone overriding the buildurl
method to apply routes with buildurl
http://pastebin.com/bRN7XhkX
so i guess if i define rules saying "/fr/utilisateur/connexion" ="fr/
user.login"
such as
variables.framework.routes = [{"/fr/utilisateur/connexion"="/fr/
user.login"},{"/en/user/login"="/en/user.login"}];




then if in my view i have a link that says "<a href='#buildurl(lang&"/
user.login")#'>link</a>
with lang=fr
it should produce the following html
<a href='/fr/utilisateur/connexion'>link</a>




and then the rewrite rule could translate it back to "/index.cfm?
action=user.login&lang=FR"




am i completely wrong?(might be...)




do you think there would be a cleaner way to do this?
or else, if it can work, where do i have to put the buildurl
overriding code? in the application.cfc file?

On 5 mar, 07:37, Richard Tugwell <r.tugw...@forthmedia.com> wrote:
> Sorry I'm a bit late to this.
>
> Our applications are multilingual - at least the interface is - and we
> use Paul Hastings JavaRB (http://www.sustainablegis.com/unicode/
> resourceBundle/javaRB.cfm).
>
> This works a treat, but don't underestimate the amount of work
> involved in coding a site for multilingual use. A resource bundle
> editor is a great help. I use the Eclipse one in CFBuilder (http://
> sourceforge.net/projects/eclipse-rbe/) although I'm not saying it's
> the best available - haven't tried many others. There's also the
> standalone attesoro which is handy if you're passing properties files
> to translators who don't use an IDE and need a simple editor...http://attesoro.org/

Richard Tugwell

unread,
Mar 6, 2012, 1:48:11 AM3/6/12
to framework-one
"Now for the resource bundle thing, why not simply say :
i have a database table with "id,locale,keyString,keyValue"

Personally, I think the main benefits of using resource bundles are
from a maintenance point of view

1) If you go down the DB route, you will need to implement some kind
of interface for users to update the DB, and this will include things
like managing access to the application. Using resource bundles and an
editor obviates this additional overhead. Depends who's doing the
updates and their relationship to your team but maybe you will need to
use external translators. Maybe you want to allow people to contribute
translations. In these cases you can just send them a simple text file
to edit (also maybe helping with the use of resource bundle editors).
If like Sean, this is all handled as part of your organisations team,
things may well be different. NB I think you will probably want more
than one table. One for the label/keys and one for the locale/
translations for example.

2) For application updates you will need to manage DB replication from
Dev/Acpt/Prod - depending on your lifecycle. Rollbacks will similarly
need to be handled at the DB level. The resource bundle files will be
managed and versioned by your source management system, so this sort
of thing as well as change tracking will be easier.

3) Adding new languages is easy with an RB editor out of the box, as
are facilities like flagging keys that haven't been translated,
providing nice hierarchical display of keys etc. You can of course
implement all this sot of thing yourself in your interface, but it
seems to add unnecessary complexity.

4) Paul Hastings JavaRB implementation provides variable substitution
out of the box. Again you can code this yourself as a function. NOte
that you want always just be able to replace a label by a structKey -
some parts of the interface code will require one or more variable
substitutions.

As Sean says, there is no right way looking at it purely from a code
point of view. It depends how it will all work in practice.

Sharon DiOrio

unread,
Mar 6, 2012, 3:40:09 AM3/6/12
to framew...@googlegroups.com
In a previous job we had a DB-based translation system. We did have
to code up an admin area (as part of a larger content management
system that handled access) for this, but we liked having web-based
access to the translations. Key-based translations were called via a
"translate" function on the front end. Something like
#translations.get('continue_button')#.

Could we have done that with resource bundles? Sure. But our sites
were not static information that was translated once and forgotten.
They were more dynamic. Being able to add and edit translations via a
shared web interface made more sense for us than dealing with text
files because that fit in better with our established workflows.

David Panzarella

unread,
Mar 6, 2012, 12:19:26 PM3/6/12
to framework-one
This might be completely off the original request need, but have you
considered looking at converting your site to use Mura CMS, and then
just install the Locale Translation Manager Plugin? With your SES set
up with Mura, your pages will display as mydomain.com/en/somepage/
somenestedpage, which can (or not if you choose so) match a completely
seperate site instance for your FR site at mydomain.com/fr/
somepageinFR/somenestedpageinFR.

Again, this may not work for you, but i'm working on a multi-lingual
site at the moment, and it works great because not all pages of the
English site will be in the my Spanish site. And vice versa.

On Mar 6, 12:40 am, Sharon DiOrio <sharon...@gmail.com> wrote:
> In a previous job we had a DB-based translation system.  We did have
> to code up an admin area (as part of a larger content management
> system that handled access) for this, but we liked having web-based
> access to the translations.  Key-based translations were called via a
> "translate" function on the front end.  Something like
> #translations.get('continue_button')#.
>
> Could we have done that with resource bundles?  Sure.  But our sites
> were not static information that was translated once and forgotten.
> They were more dynamic. Being able to add and edit translations via a
> shared web interface made more sense for us than dealing with text
> files because that fit in better with our established workflows.
>

Richard Tugwell

unread,
Mar 6, 2012, 12:37:50 PM3/6/12
to framew...@googlegroups.com
Hi Sharon

Sure - DB (or other persistence mechanism) for content, we just use resource bundles for static content. Navigation, Titles, Fields, Forms etc etc. 
--
=================================
Richard Tugwell
http://blog.richardtugwell.com
r.tu...@forthmedia.com

dehian

unread,
Mar 6, 2012, 4:47:07 PM3/6/12
to framework-one
I don't think i cms could fit my needs but it might be interesting to
see how they handle to SES urls.

On 6 mar, 18:19, David Panzarella <da...@sbinnerwebdevelopment.com>
wrote:

dehian

unread,
Mar 6, 2012, 4:48:44 PM3/6/12
to framework-one
Yeah i guess i'll go that route, because we also need a web interface
to manage translations.

On 6 mar, 09:40, Sharon DiOrio <sharon...@gmail.com> wrote:
> In a previous job we had a DB-based translation system.  We did have
> to code up an admin area (as part of a larger content management
> system that handled access) for this, but we liked having web-based
> access to the translations.  Key-based translations were called via a
> "translate" function on the front end.  Something like
> #translations.get('continue_button')#.
>
> Could we have done that with resource bundles?  Sure.  But our sites
> were not static information that was translated once and forgotten.
> They were more dynamic. Being able to add and edit translations via a
> shared web interface made more sense for us than dealing with text
> files because that fit in better with our established workflows.
>

Seth Johnson

unread,
Mar 6, 2012, 4:49:09 PM3/6/12
to framew...@googlegroups.com
You can use FW/1 to create plug-ins to extend Mura, it works really well.

Seth

dehian

unread,
Mar 6, 2012, 4:54:11 PM3/6/12
to framework-one
Alright i now understand the benefits of RBs but as we need a
translation web interface, i guess it's not the right thing for us.
Altough i would have liked the ability to deploy that easily the
translations from dev to acpt/prod ;)

David Panzarella

unread,
Mar 6, 2012, 5:09:58 PM3/6/12
to framew...@googlegroups.com
Yup you can extend Mura using plugins using fw/1 as well. I'm
building and event management plugin in one now that uses it. A great
example to explore us the slatwall plugin. It uses cold spring and
fw/1 and it's open source.

Sent from my iPhone

Reply all
Reply to author
Forward
0 new messages