How to localize Sense/Net

From Sense/Net Wiki
Jump to: navigation, search
  •  
  •  
  •  
  •  
  • 100%
  • 6.0.8
  • Enterprise
  • Community
  • Planned

Overview

Localization
Sense/Net pages can be localized and thus portal builders can provide ECM solutions for their customers with content and pages in different languages. A single page can be viewed in different languages but also multiple sites of different languages can be created in the Sense/Net Content Repository. This guide shows you how to translate your pages easily to another language.

Details

String resources

Pages and content can be made multi-lingual by using string resources instead of hard-coded texts. A string resource defines the different language-variant texts for a single text entity and will display the appropriate language variant according to the language settings of the Site. From a user perspective a string resource is simply a text (or label), that appears in the current language of the Site. The string resources can be found in the /Root/Localization folder.

String resources in the Content Repository

The Localization folder contains content of Resource Content Type (containing resources in XML format). Builders and developers can create their own .xml files and upload them here to create multi-language pages and content.

The structure of the resource XML files is the following:

<?xml version="1.0" encoding="utf-8"?>
<Resources>
  <ResourceClass name="[CLASSNAME]">
    <Languages>
      <Language cultureName="[LANGUAGE CODE 1]">
        <data name="[KEYNAME]" xml:space="preserve">
	  <value>...</value>
	</data>
      </Language>
      <Language cultureName="[LANGUAGE CODE 2]">
        <data name="[KEYNAME]" xml:space="preserve">
	  <value>...</value>
	</data>
      </Language>
    </Languages>
  </ResourceClass>
</Resources>


When creating resource files it is recommended to use separate resource files for different classes, and use the ClassNameResources.xml naming convention for the name of resource files. Tha class name can be the name of your custom portlet, content view or feature where you want to use the resources.

Add new language to a string resource

New site language must be set on the site and the string resources for that language must be defined too. The resources that belong to one language are in one Language section in the resource file (in XML format) under the 'Languages' node.

    <Languages>
      <Language cultureName="en">
        <data name="StartDateLabel" xml:space="preserve">
		<value>Start date:</value>
	</data>
      </Language>
      <Language cultureName="hu">
        <data name="StartDateLabel" xml:space="preserve">
		<value>Kezdő dátum:</value>
	</data>
      </Language>
    </Languages>

The easiest way to add a new language is to copy an existing one and change its culturName attribute to the new language code.

It is advisable however to use the built-in Resource Editor that provides a handy UI for users to localize their pages without managing resource files. See details below.

Resource editor

Sense/Net provides a handy tool to localize pages by allowing in-place editing of the string resources on a page. To invoke the editor on a page:

  • You need to be logged in as a user that is a member of the Administrators group,
  • Open the Portal Remote Control,
  • Click on the "Resource editor mode" button on the PRC.

In versions 6.1.1 and older, this used to work by typing in the resources query parameter in the url bar with any value.

Subsequently, all string resources will appear highlighted on the page:

Highlighted string resources

These are clickable links, that bring up an editor popup when clicked:

Resource Editor popup

In this editor popup every language appears for the current Site that has been configured in its CTD. If a value for a language is missing, the corresponding textbox appears empty. The string resources can be defined/edited here freely, modifications after clicking the Save button will take effect immediately:

Edited string resource

When you are done, click again on the "Resource editor mode" button on the PRC to quit resource editing mode.

Related links

References

There are no external references for this article.