Making a language pack plugin
From KnowledgeTree Document Management Made Simple
A language pack plugin provides additional language support to KnowledgeTree. Language pack plugins require KnowledgeTree 3.0.2 or above (3.0.1 translation release will also work).
A plugin is generally packaged in both ZIP and TAR.GZ format (post on the i18n forum or mailing list to get help to do a format you can't do).
The only file that needs to be edited for a translation is the knowledgeTree.po file. This file is in the i18n directory of the "KnowledgeTree 3.0.1 translation release".
This is a standard PO file that many projects use for translation. There is a tool called [poedit] that you can use to help in translation.
As an example, here is the layout of a Spanish (Colombian) language pack plugin:
spanish/ spanish/SpanishPlugin.php spanish/translations/ spanish/translations/es_CO/ spanish/translations/es_CO/knowledgeTree.po
The SpanishPlugin.php is the file that KnowledgeTree reads to find out what the plugin does.
The translations directory contains the translations. The es_CO directory within relates to the Spanish (es) language as spoken in Colombia (CO).
The knowledgeTree.po or knowledgeTree.mo file contains the translations, in the Gettext PO or MO file formats. Tools such as poedit will output such output.
The plugin file will have the following format:
<?php
class SpanishPlugin extends KTPlugin {
var $sNamespace = "spanish.plugin";
var $iOrder = -50;
function setup() {
$this->registerI18nLang('knowledgeTree', "es_CO", 'translations/');
$this->registerLanguage("es_CO", "Español (Colombia)");
}
}
$oPluginRegistry =& KTPluginRegistry::getSingleton();
$oPluginRegistry->registerPlugin('SpanishPlugin', 'spanish.plugin', __FILE__);
The <?php at the beginning is required for the file to be read properly by PHP. Make sure <?php is on the very first line of the file with no space before it.
The line starting with 'class' gives the name of the plugin, and that it is a plugin. Change SpanishPlugin to the name of your language.
The line with sNamespace identifies this plugin uniquely. Change the "spanish" part of spanish.plugin to your language.
The order line ensures that the plugin is read before any text that needs to be translated. Don't change this.
The next important line is the one with registerI18nLang. This says that this plugin contains translations for the 'knowledgeTree' domain (the default in KnowledgeTree), for the 'es_CO' (Spanish in Colombia) language, in the 'translations' directory. Change the 'es_CO' to your locale.
The line after that describes "es_CO" as being "Espanol (Colombia)", and this is the option that shows up on the login screen to use this language.
Finally, the registerPlugin line must be changed to the plugin class name (replace SpanishPlugin) and the plugin identifier name (replace 'spanish.plugin').
The plugin should now be able to be registered on your system. Go to Administration > Miscellaneous > Plugins, and select the "Reread plugins" option. The plugin should now be included in the list. Enable the plugin in the list by selecting the checkbox next to the plugin (whatever you used in place of 'spanish.plugin'), and selecting the 'Enable' option.
The plugin should now show up as enabled. Log out, and your language should now be selectable in the login page.
del.icio.us
reddit

