Adding Language Selector Links to a Roller Theme

Note: There is now an easier way to do this with most Roller themes.  

Several of the blogs I work with, such as Bob Porras' and Storage Stop, are translated into multiple languages. It's nice to separate them out so that readers can quickly reach the language they're interested in.

The elegant way to do this is to add language links to your blog's navigation - in  Bob's right column you'll see:

Languages

English

简体中文

Español

Русский

Set Up a Roller Blog for Multiple Languages 

  1. Go to your settings page (Preferences > Settings) and under 'I18n Settings' check the box to indicate you publish your blog in multiple languages.
  2. When you edit entries from now on, you will be given the option of choosing a language for your entries, so pick whatever makes sense.
  3. Any post with a non-English language setting will be stored in a subdirectory with the appropriate locale string, e.g. your Spanish entries would go into http://blogs.sun.com/your-blog-handle/es/

Create Language Selector Links 

To make it easier for each visitor to get to the right language, you can modify your Roller template to provide a link that will put them straight into that directory, where they will see all those language posts, and nothing else. NB: There appears to be no way to link a specific English post to a specific other language post.Tip: There's a setting you can change so that your main home page shows only your English posts, which declutters your blog, but then a visitor MUST click a link to see another language. Go to Preferences > Settings and UNcheck the box next to "Show my weblog entries from all languages on my homepage".
Here's how to create the links:

  1. Go to the Design tab.
  2. Select Templates.
  3. Click on Weblog.
  4. At the very top of the page in the blue bar, right click on "editing weblog [your blog name]" and open it in a new tab or window so you can see your blog as it currently appears.
  5. Decide where on the blog you want your language links to go, e.g., I opted for the right navigation column above the Tag section. This may be in a separate theme template.
  6. In the Roller editing window, scroll down through the mess o' code to find where you want to insert your new links. In my case, it was under
     
<!- RIGHT COLUMN/SIDEBAR -->

.
Just before

<!- TAGS ->

I inserted:

<!-Languages!>

<h1>LANGUAGES</h1>

<p><a href="http://blogs.sun.com/your-blog-handle/">English</a></p>

<p><a href="http://blogs.sun.com/your-blog-handle/es/">Spanish</a></p>

<!- /  Languages-!>

Save your changes with the Save button way down at the bottom.

Refresh the page on your blog and see how the changes have affected the page. Depending on what theme you started from, you may have to add some div code to make the text match the rest of the blog . Remember that changes you make to your Roller theme are specific to that template (you'll be using a customized template from here on) and would have to be done over again if you change theme.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact