Localizing a Nearforums website

All strings in the Nearforums application are output through a T() method that can look up a translated string based on the default site culture. By default, Nearforums includes values for English (en-US) and Spanish (es-ES), but you can add support for additional cultures. To localize a site for a culture, you download and install the appropriate set of .po files, and then you update your site settings as shown in this section.

Note In .NET Framework applications, localization is usually done using .resx files and satellite assemblies. Nearforums takes a more lightweight approach that uses .po files. This file format is used on other open source projects as Wordpress or Orchard. The great thing about  .po files is that it can be loaded and unloaded on demand. Like .resx files, .po files are a standard format for which many tools exist.

Installing a translation file

Go to www.nearforums.com/localize and download the .po translation file of your culture. If the translation file for your culture does not exist, you could create your own by copying the en-us.po file delivered on the installation and renaming to your culture code.

Translation File Format

The following illustration shows the format of a translation file. Each text string is represented by elements listed in the following table.

A reference (see below) #: reference-string
The current English string for reference. This helps the translator. msgid "English-string"
The translated string. msgstr "translated-string"

Please make sure when working with .po files that the files are saved in UTF-8 with Byte Order Mark. This is usually a setting in your text editor (in Notepad it is under the Encoding drop-down in the "Save As" dialog).

Switching the site to another culture

To change the default culture for the application, go to the Site.config file located on the Config folder. Edit the cultureName attribute value on the site element.

The cultureName value must match the name of the .po file, located on the path ~/content/localization/.


This document is based on Orchard Project: Creating global ready applications, licensed under New BSD License (BSD).

Last edited Mar 5, 2012 at 3:27 PM by jorgebg, version 9


No comments yet.