KVS And Multi-Lingual Content

Localizing Content

KVS offers full content localization features in its Ultimate package.

Get started by creating a list of languages your site supports in Site settings. When you create this list, nothing will happen on the site. The content storage system will be extended with new fields and the administration panel will start offering new features.

After you do this, you can start translating your content and categorization items in Administration -> Data Localization in the administration panel. This section offers a unified interface to translate all types of objects that can be localized in KVS. If you prefer to translate video and photo album related text right on the pages where you edit these objects, you can enable the display of language fields on editing pages in your Personal Settings. All localization-related activity is logged in the audit log, which means you can control the translation process and get translation statistics (e.g. for paying your translation team) with the Audit log analysis plugin.

Your site will display content data depending on the current locale. You do not need to modify page templates for this. If for some content you do not have translations so far (for example, you have translated titles and descriptions for 50% of the videos), original data will be shown for this content. This means your site remains functional even when partially localized.

Building Your Site's Language Versions

There are 2 ways you can build your site's language versions. These are language satellites, or within a single domain license. Let us have a look at the differences between these.

Language satellites let you build independent sites using your original database. This is highly recommended for sites with large amounts of content, because you can move language versions to separate servers or separate hard drives (to make sure large amounts of cached data function properly).

Language satellites let you build language copies of your site on any domains you may want to use, e.g. domain.com and domain.de. If you build your sites within a single domain name , you can choose between subdomains for your licensed domain (de.domain.com) or folders (domain.com/de/).

Language satellites have separate templates and ads. However, you can still use the same templates and/or ads and synchronize your copies with your primary site. If you build your versions within a single domain name, all differences between the versions are defined in the same template instance, which may make customizing it difficult.

Unique statistics are tracked for all your Language satellites. If your language versions are within a single domain name no separate language version statistics is available.

Language Versions Within A Single Domain License

For this to work, define the differences between your language versions in a similar manner, when you use subdomains in /admin/include/setup.php:

if ($_SERVER['SERVER_NAME']== 'de.domain.com') { $config['project_url']="http://de.domain.com"; $config['locale']="de"; } elseif ($_SERVER['SERVER_NAME']== 'fr.domain.com') { $config['project_url']="http://fr.domain.com"; $config['locale']="fr"; } else { $config['project_url']="http://domain.com";}

In case you use folders instead, here is how the code will look:

if (strpos($_SERVER['SCRIPT_NAME'], '/de/')!==false) { $config['project_url']="http://domain.com/de"; $config['locale']="de"; } elseif (strpos($_SERVER['SCRIPT_NAME'], '/fr/')!==false) { $config['project_url']="http://domain.com/fr"; $config['locale']="fr"; } else { $config['project_url']="http://domain.com";}

With subdomains, you will need to assign their document root to the same directory where files of the site on your primary domain are.

With folders, you need to manually synchronize the root .htaccess file defining the paths on the site between the site in the root folder and the language folders. Here, using subdomains is easier as it lets you avoid differences in your .htaccess file.

Language Satellites

This approach is installing separate KVS satellites on language subdomains and connecting them to the primary database. As the satellites have different sets of pages and site templates, you can add new site languages without switching your primary templates to language keys. It means you can copy primary templates and replace the texts with translations. This is easier when you are adding 1 language. If you want to add several languages, you will find that switching the templates to language keys is easier, as you will only need to translate a single language file.

The main advantage of this approach lies in your ability to move the language versions to separate servers or HDDs. Another advantage here is that separate statistics are tracked for each satellite. You can also use different ads and different site designs and structures. Possible disadvantages include having to maintain and update additional KVS installations separately and modifying the templates of each satellite if you want to change something across the site. Updating templates becomes much easier if you switch your primary site to language keys. In this case, you can set up automated server-side replication of all changes in you make in templates and page configuration of your primary site to your satellites.

To switch a satellite to one of the supported locales, add this to /admin/include/setup.php:

$config['locale']='de'; // specify a supported language code to assign it to this satellite; after this, the satellite will be displayed in the chosen locale.

Language Keys

If you want to use language keys in your site's templates, you will need to create a /langs/default.php file where all keys and their values for the default locale will be defined. Then, you need to copy the contents of this file into language files of all your locales (/langs/de.php, /langs/fr.php), and have these translated. Here is the format the language files need to have:

<?php $lang['key1']="Text 1"; $lang['section1']['key1']="Section 1 Text 1"; $lang['section1']['key2']="Section 1 Text 2"; $lang['section2']['subsection1']['key1']="Section 2 Subsection 1 Text 1"; ... ?>

The files can have any amount and hierarchy of sections.

We recommend notions common for the entire site without sections. Declare notions that are logically grouped in the same section, for example:

$lang['site_title']="Site name - best videos and community site"; $lang['posted_by']="Posted by"; $lang['duration']="Duration"; ... $lang['main_menu']['home']="Home"; $lang['main_menu']['videos']="Videos"; ...

Then, use these keys to display this or that text on your site's pages:

{{$lang.site_title}} {{$lang.posted_by}} {{$lang.duration}} {{$lang.main_menu.home}} {{$lang.main_menu.videos}}

In case you need to insert any dynamic content into a text, never break this text into several smaller parts. Instead, use placeholders that will be replaced with their values when shown on the page. This is a better strategy as texts may have different word order in different languages, and the entire text will need to be rephrased during translation. For example:

$lang['titles']['videos_by_category']="Videos for category %1%"; $lang['confirmations']['delete_messages']="Are you sure to delete %1% messages from %2% user?"; {{$lang.titles.videos_by_category|replace:"%1%":$category_info.title}} {{$lang.confirmations.delete_messages|replace:"%1%":$selected_count|replace:"%2%":$username}}

Use this syntax if you need to apply a modifier to a language key in a dynamic variable:

{{assign var=nav_page_num value=$nav.page_num[index]|string_format:"%d"}} {{$nav_page_num}} – this results in the variable having the value you need to display on the site.