You are on page 1of 7

4/10/2015 Tales 

from the Evil Empire ­ Creating and maintaining Orchard translations

Creating and maintaining Orchard
translations
Friday, January 14, 2011
.NET (/bleroy/Tags/.NET)   ASP.NET (/bleroy/Tags/ASP.NET)   Orchard (/bleroy/Tags/Orchard)

Many volunteers have already stepped up
(http://orchardproject.net/localize) to provide translations for
Orchard. There are many challenges to overcome with
translating such a project.

Orchard is a very modular CMS, so the translation mechanism
needs to account for the core as well as first and third party
modules and themes.

Another issue is that every new version of Orchard or of a
module changes some localizable strings and adds new ones as others enter obsolescence.

In order to address those problems, I've built a small Orchard module that automates some of the most
complex tasks that maintaining a translation implies. In this post, I'll walk you through the operations I
had to do to update the French translation for Orchard 1.0.

In order to make sure you translate all the first party modules, I would recommend that you start from a
full source code enlistment (http://orchardproject.net/docs/Setting­up­a­source­enlistment.ashx). The
reason is that I'll show how you can extract the default en­US translation from any source code
enlistment. That enables you to create a translation that is even more up­to­date than what is currently
on the site. Alternatively, you could start by downloading the current en­US translation. If you decide to
do so, just skip the relevant paragraphs.

First, let's install the Orchard Translation Manager
(http://www.orchardproject.net/gallery/List/Modules/Orchard.Module.Vandelay.TranslationManager). I'm
starting from a vanilla clone of the latest in the code repository. After you've setup the site
(http://orchardproject.net/docs/Installing­Orchard.ashx), go into the dashboard and click on Gallery.
Locate the Orchard Translation Manager in the list of modules and click "Install".

Once the module is installed, you need to enable its one feature by going into Configuration/Features
and clicking "Enable" next to Vandelay.TranslationManager.

We're done with the setup that we need in order to start our translation work. We'll now switch to the
command­line and to our favorite text editor.

https://weblogs.asp.net/bleroy/creating­and­maintaining­orchard­translations 1/7
4/10/2015 Tales from the Evil Empire ­ Creating and maintaining Orchard translations

Open a command­line (http://orchardproject.net/docs/Using­the­command­line­interface.ashx) on the
Orchard web site folder. I found the easiest way to do this is to do a SHIFT+right­click on the
Orchard.Web folder in Windows Explorer and to click "Open command window here". Type bin\orchard
to enter the Orchard command­line environment.

If you do a "help commands" you should see four commands in the list that came from the module we
just installed: extract default translation, install translation, package translation and sync translation.

First, we're going to generate the default translation. Note that it is possible to generate that default
translation for a specific list of modules and themes by using the /Extensions: switch, which should
facilitate the translation of third party extensions, but in this tutorial we're going to generate it for the
whole of the Orchard source code.

extract default translation /Output:\temp

This should have created an Orchard.en­us.po.zip file in the temp directory. Extract that archive into an
orchard.po folder under \temp.

The next step depends on whether you have an existing translation that you want to update or not. If you
do have an existing translation, just extract it into the same \temp\orchard.po directory. That should
result in a file structure where you have the default en­US translation alongside your own. If you don't
have an existing translation, just continue, the commands will be the same.

We are now going to synchronize those translations (or generate the stub for a new one if you didn't
start from an existing translation).

sync translation /Input:\temp\orchard.po /Culture:fr‐FR

After this command (where you should of course substitute fr­FR with the culture you're working on), we
now have updated files that contain a few useful flags.

Open each of the .po files under the culture you are working on (there should be around 36) with your
favorite text editor.

For all the strings that are still valid in the latest version, nothing changes and you don't need to do
anything.

For all the strings that disappeared from the default culture, the old translation will still be there but they
will be prefixed with the following comment:

# Obsolete translation

Conveniently, all the obsolete strings will be grouped at the end of the file. You can select all those and
delete them.

For all the new strings, you will see the following comment:

# Untranslated string

https://weblogs.asp.net/bleroy/creating­and­maintaining­orchard­translations 2/7
4/10/2015 Tales from the Evil Empire ­ Creating and maintaining Orchard translations

This is where the hard work begins. You'll need to translate each of those new strings by entering the
translation between the quotes in:

msgstr ""

Don't introduce hard carriage returns in the strings, just stay on one line (your text editor should do some
reasonable wrapping so this shouldn't be a big deal).

Once you're done with a file, save it. Make sure, and this is very important, that your text editor is saving
using the UTF­8 encoding. In Notepad, that setting can be found in the file saving dialog by doing a
"Save As" rather than a plain "Save":

When all the po files have been edited, you are ready to package the translation for submission (a.k.a.
sending e­mail to the localization mailing list (mailto:orchard­localization@lists.outercurve.org)).

package translation /Culture:fr‐FR
    /Input:\temp\orchard.po /Output:\temp

You should now see a Orchard.fr­FR.po.zip file in temp that is ready to be submitted.

That is, once you've tested it, which can be done by deploying it into the site:

install translation \temp\orchard.fr‐fr.po.zip

Once this is done you can go into the dashboard under Configuration/Settings and click on "Add or
remove supported cultures for the site". Choose your culture and click "Add". You can go back to settings
and set the default culture. Save.

You may now take a tour of the application and verify that everything works as expected:

https://weblogs.asp.net/bleroy/creating­and­maintaining­orchard­translations 3/7
4/10/2015 Tales from the Evil Empire ­ Creating and maintaining Orchard translations

And that's it really. Creating a translation for Orchard is a matter of a few hours. If you don't see a
translation for your culture, please consider creating it.

7 Comments
Trying to make it work with the orchard site installed from WebMatrix but doesn't work 
—  Simone Chiaretta (http://codeclimber.net.nz) ­ Friday, January 14, 2011 11:34:38 AM (/bleroy/creating­and­maintaining­
orchard­translations#comment­776)

https://weblogs.asp.net/bleroy/creating­and­maintaining­orchard­translations 4/7
4/10/2015 Tales from the Evil Empire ­ Creating and maintaining Orchard translations

Installed Orchard with WebPI, set it up, and tried to extract translation. Got weird error message
about Orchard.Azure folder not being present, even though the folder it is installed is called
"orchard". Did I miss something? 

orchard> extract default translation /Output:\temp 

Error executing command "extract default translation" 
­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ 

Could not find a part of the path 'C:\inetpub\wwwroot\Orchard.Azure\'. 

Exception Details: System.IO.DirectoryNotFoundException: Could not find a part o 
f the path 'C:\inetpub\wwwroot\Orchard.Azure\'. 

Stack Trace: 

[DirectoryNotFoundException: Could not find a part of the path 'C:\inetpub\wwwro 
ot\Orchard.Azure\'.] 
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
at System.IO.FileSystemEnumerableIterator`1.CommonInit() 
at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String origina 
lUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler` 
1 resultHandler) 
at System.IO.Directory.InternalGetFileDirectoryNames(String path, String user 
PathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, S 
earchOption searchOption) 
at System.IO.Directory.InternalGetFiles(String path, String searchPattern, Se 
archOption searchOption) 
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext() 
at System.Linq.Enumerable.d__14`2.MoveNext() 
at Fluent.IO.Path.Files(Predicate`1 predicate, String searchPattern, Boolean 
recursive) 
at Vandelay.TranslationManager.Services.LocalizationManagementService.c__Di 
splayClass1d.b__18(Path p) 
at Fluent.IO.Path.ForEach(Action`1 action) 
at Vandelay.TranslationManager.Services.LocalizationManagementService.Extract 
DefaultTranslation(String sitePath) 
at Vandelay.TranslationManager.Commands.LocalizationManagementCommands.Extrac 
tDefaultTranslation() 

­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ 
—  TBay ­ Friday, January 14, 2011 8:06:08 PM (/bleroy/creating­and­maintaining­orchard­translations#comment­777)

https://weblogs.asp.net/bleroy/creating­and­maintaining­orchard­translations 5/7
4/10/2015 Tales from the Evil Empire ­ Creating and maintaining Orchard translations

I figured out the weird Azure thing. You NEED the full source code, not just the web site or a
WebPI install. 
The Azure thing comes from the fact that the Azure project contains specific strings that also need
to be translated and that are one level up from the web site project. 
So just try again with the full source code. 
—  Bertrand Le Roy (http://weblogs.asp.net/bleroy/) ­ Saturday, January 15, 2011 10:01:06 PM (/bleroy/creating­and­
maintaining­orchard­translations#comment­778)

How is Orchard for seo ? 

The only thing I have against a cms is the seo factor, many people say it is hard to optimise a
website built by a cms. 

Is this true for Orchard ? 
—  jason_palmer (http://jetsetjason.wordpress.com/) ­ Tuesday, January 18, 2011 1:52:31 PM (/bleroy/creating­and­
maintaining­orchard­translations#comment­779)

@Jason: a long time ago, CMS could impair your ability to have good SEO, but now they are all
supporting relatively clean markup and URLs which gets you most of the way there. In Orchard,
the default markup is clean and everything can be overridden anyway. Clean URLs are there by
default. Additional stuff could be done, such as meta tags and additional semantic constructs in the
markup and I'd expect that to be available as modules at some point. 
—  Bertrand Le Roy (http://weblogs.asp.net/bleroy/) ­ Tuesday, January 18, 2011 8:16:41 PM (/bleroy/creating­and­
maintaining­orchard­translations#comment­780)

oh, looks like I haven't worked with latest source code from codeplex. It works now! 
—  Ivan Pavlović (http://twitter.com/ipavlovi) ­ Tuesday, February 15, 2011 9:51:36 PM (/bleroy/creating­and­maintaining­
orchard­translations#comment­781)

@william: these things probably get cached. Try restarting the server and see if it makes a
difference. 
—  Bertrand Le Roy (http://weblogs.asp.net/bleroy/) ­ Monday, December 5, 2011 2:36:37 AM (/bleroy/creating­and­
maintaining­orchard­translations#comment­782)

Comments have been disabled for this content.

https://weblogs.asp.net/bleroy/creating­and­maintaining­orchard­translations 6/7
4/10/2015 Tales from the Evil Empire ­ Creating and maintaining Orchard translations

Terms Of Use (http://www.asp.net/terms­of­use) ­ Powered by Orchard (http://www.orchardproject.net)

https://weblogs.asp.net/bleroy/creating­and­maintaining­orchard­translations 7/7

You might also like