Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2010-10-06 09:04:29

LeMacabre
New member
Registered: 2010-10-06
Posts: 8

Howto translate own plugin

Hi

I made a little Plugin for me for an easy insert of Tags / Words.
Now I saw that the other plugins have english texts and so I wrote my texts in english too.
So on it should be possible to use other languages when Xinha is configured ~ in german for example ~ but I don't know how :-/

Thats the steps I tried:
- I created an own Folder in the plugin-Directory of Xinha.
- Then I created the Plugin-files which be needed (= form-file and js-file. the form-file was wrote in english)
- I created a Folder named "lang" and a file named "de.js" (german language-file)

My work has no effect. The Plugin-Form is still english. What have I missed?


It would be nice if somebody could help me to solve my problem ^^

thx
lm

Offline

#2 2010-10-06 18:30:57

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Howto translate own plugin

Without seeing how your plugin works, I can only speak in general terms,

var TranslatedText = Xinha._lc("English Text", 'PluginName');

translates the string "English Text" into the appropriate language, in the "PluginName" scope. 

You put your translations in
/plugins/PluginName/lang/**.js
(where ** is the lang code, "fr" for french etc)

This file must be in UTF-8 encoding (goes for everything).

An example fr.js

// I18N constants
// LANG: "fr", ENCODING: UTF-8
{
  "You must select some text before making a new link.": "Vous devez sélectionner un texte avant de créer un nouveau lien",
  "Are you sure you wish to remove this link?": "Confirmez-vous la suppression de ce lien ?",
  "Remove Link": "Supprimer",
  "URL Link": "Lien URL",
  "Ordinary Link": "Lien standard",
  "Same Window (jump out of frames)": "Même fenêtre (sort des frames)",
  "New Window": "Nouvelle fenêtre",
  "Popup Window": "Fenêtre popup",
  "Email Link": "Lien email",
  "Email Address:": "Adresse email",
  "Subject:": "Sujet",
  "Message Template:": "Message",
  "Size:": "Taille",
  "Name:": "Nom"
};

If you use the "Dialog" system (brief rundown follows) then your dialog html can be like this and the stuff in <l10n> tags and _(....) attributes will be translated automatically.

<label>
  <input type="radio" name="[type]" id="[type_url]" value="url" checked="checked" />
  <l10n>URL Link</l10n>
 </label>

<label for="[href]"><l10n>URL:</l10n> </label>
  <input type="text" name="[href]" id="[href]" style="width:100%" value="http://www.example.com/" />

<input type="button" id="[ok]"     value="_(OK)"     />

Here is a brief rundown on using dialog (see Linker/pluginMethods.js for a complete example) -- note the square brackets are required in ID's, names etc in the HTML, but you omit them in the functions below)

var myDialog = new Xinha.Dialog(theXinhaEditorObject, "html string of your 'dialog'", 'PluginName');
myDialog.show({'fieldName': 'fieldValue, 'anotherField': 'anotherValue'}); // Optional set fields when showing
var fieldValues = myDialog.hide(); // see also myDialog.getValues();

// Additional Useful Functions....
myDialog.toggle();
myDialog.collapse();
myDialog.getElementById('someID');
myDialog.getElementsByName('someName');
myDialog.getElementsByClassName('someClassName');

// See modules/Dialogs/XinhaDialog.js for more

James Sleeman

Offline

#3 2010-10-11 07:06:16

LeMacabre
New member
Registered: 2010-10-06
Posts: 8

Re: Howto translate own plugin

Ok i will try it. so i have a second question .. but its not familiar with this problem ... so i have to start a new thread

Offline

Board footer

Powered by FluxBB