#1 December 16, 2012 2:35pm

clearbold
Member
Registered: April 18, 2012
Posts: 8

Translated content

In an email, Dylan had said, regarding translated content:

We've built a few sites where the client has required translated content. In all situations, we created separate content fields for each language. For example, page_header_english and page_header_spanish. A user's language preference was stored in a cookie and we'd draw the content as $bigtree["resources"]["page_header_".$user_language] or something similar. This method does require duplication of effort, as the translation is not automatic, but the language-specific content can be edited for tone / grammar very easily.

Two questions:

1) Were you able to use language-specific URLs that way? I.e.,

site.com/about

And

site.com/es/about

If so, did you do that via .htaccess?

2) Is it possible to clone the controller across those directories and set $user_language as a global variable in the controller? Then any request that comes in via:

/es/index.php

Gets "es" set to $user_language and the same technique can be used for content fields.

Requests to index.php without /es/ set the variable to "en".

Thanks!

Mark

Offline

#2 December 16, 2012 2:59pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 978

Re: Translated content

I think to accomplish what you're asking with the URL scheme you'd need to create a custom router.php in in /custom/.

You'd also want to override a few functions in the BigTreeCMS class so that when getLink or getNavByParent is called it throws the /en/ or /es/ into your URLs.

RC2 is modifying the router.php file quite a bit to simplify and enhance routed templates so I'll have to let you know where to modify that when it rolls out. Basically, you'd want to add something like:

if ($bigtree["path"][0] == "es") {
    define("USER_LANGUAGE","es");
    $bigtree["path"] = array_slice($bigtree["path"],1);
} else {
    define("USER_LANGUAGE","en");
}

That would make the routing work properly when it starts with /es/. You'd probably need to put it in the line that precedes the $cms->getNavId call (I'm not sure what line it's on in RC1, but I think it's only called once).

For extending the BigTreeCMS class to properly get your /es/ links when your user's language is currently spanish you'd want to do the following:

  • Create a class in /custom/inc/required/ that extends BigTreeCMS

  • Edit your /templates/config.php file to define "BIGTREE_CUSTOM_BASE_CLASS" to the name of the class you created (it should be set to false in the default config, switching it to your custom class will make the default $cms variable an instance of your custom class instead of BigTreeCMS).

It looks like the following functions would need to be extended:

  • drawXMLSitemap (if you want /es/sitemap.xml to show a separate sitemap of /es/ links)

  • getBreadcrumbByPage

  • getInternalPageLink

  • getLink

  • getNavByParent

They would mostly need to be changed to draw "es/" after WWW_ROOT when returning links if USER_LANGUAGE was set to "es". I'd be happy to write the extension class if you're interested. This is something that's come up a few times so we may be adding it as a core feature in the 4.1 release.

Offline

#3 December 16, 2012 3:07pm

clearbold
Member
Registered: April 18, 2012
Posts: 8

Re: Translated content

Thanks, Tim!


This is the most common implementation I've seen of translations, so I think it'd be a great addition to core.


In past CMS experience, the first part was accomplished by just copying the controller and setting the global var, but the second part - updating dynamic links - took customization of a 3rd party add-on we relied on for hierarchical nav. Of course hierarchical nav management and output is a great built-in feature of BigTree, so it'd be great to see that supported as well.


Do you have a repository of extensions or community modules started anywhere? Even if your extension class for the nav items was just posted somewhere, it'd be a great resource.


Thanks for the quick reply!

Offline

#4 December 16, 2012 3:15pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 978

Re: Translated content

We're working on getting together a system for submitting and listing extensions for the official 4.0 release (which should be first quarter 2013). We'll be starting it off with a few of the common ones that we've used with our own clients and begin accepting third party extensions after that. Adding in the language extension class to that section is a great idea!

Offline

#5 December 16, 2012 3:21pm

clearbold
Member
Registered: April 18, 2012
Posts: 8

Re: Translated content

Great. Where have you been publishing updates on the timeline and releases? I'd love to know how close the official 4.0 release is. I'm considering 4.0 for an upcoming project which would kick off some time in January.

Offline

#6 December 16, 2012 3:23pm

clearbold
Member
Registered: April 18, 2012
Posts: 8

Re: Translated content

I've also posted a few issues I've come across to GitHub. Is that the best place for those?

Offline

#7 December 16, 2012 3:32pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 978

Re: Translated content

Right now the timeline is internal to get the most stable 4.0 release we can -- we're going to be publishing release schedules and feature expectations when 4.0 goes live.  GitHub is definitely the best place for any bugs you find, thanks!

Offline

Board footer

Powered by FluxBB

The Discussion Forum is not available on displays of this size.