cryptpad/customize.dist/translations
2017-06-12 18:14:33 +02:00
..
messages.de.js remove unused translation keys 2017-03-27 11:29:19 +02:00
messages.es.js Remove the pin limit alert 2017-06-06 10:49:32 +02:00
messages.fr.js Fix the upgrade and donate buttons in the home page 2017-06-06 11:37:54 +02:00
messages.js change whiteboard translation 2017-06-12 18:14:33 +02:00
messages.pl.js remove unused translation keys 2017-03-27 11:29:19 +02:00
messages.pt-br.js Merge branch 'master' of https://github.com/gustavohmsilva/cryptpad into staging 2017-04-05 10:36:23 +02:00
messages.ro.js Update messages.ro.js 2017-05-26 16:47:45 +03:00
messages.zh.js Remove the pin limit alert 2017-06-06 10:49:32 +02:00
README.md Update README #2 2017-02-21 11:13:10 +01:00

Adding Translations

To illustrate the process of translating, this guide will make an english-pirate translation of Cryptpad. We'll assume that you have a work locally-installed, properly functioning installation of Cryptpad. If you don't have Cryptpad installed locally, start by following the steps in the main readme.

Getting started

Once everything is working, copy the default (English) source file (/customize.dist/translations/messages.js) to a file named according to your language's ISO 639-1 Code, like /customize.dist/translations/messages.fr.js. There is no ISO 639-1 language code for English-pirate, so we'll just call it messages.pirate.js.

cd /customize.dist/translations/
cp messages.js messages.pirate.js

Including your translation

To include your translation in the list, you'll need to add it to /customize.dist/messages.js. There are comments indicating what to modify in three places:

(function () {
var LS_LANG = "CRYPTPAD_LANG";

var getStoredLanguage = function () { return localStorage.getItem(LS_LANG); };
var getBrowserLanguage = function () { return navigator.language || navigator.userLanguage; };
var getLanguage = function () { return getStoredLanguage() || getBrowserLanguage(); };
var language = getLanguage();

// add your module to this map so it gets used
// please use the translated name of your language ("Français" and not "French"
var map = {
    'fr': 'Français',
    'es': 'Español',
    'pl': 'Polski',
    'de': 'Deutsch',
    'pt-br': 'Português do Brasil'
};

We need to modify that map to include our translation:

(function () {
var LS_LANG = "CRYPTPAD_LANG";

var getStoredLanguage = function () { return localStorage.getItem(LS_LANG); };
var getBrowserLanguage = function () { return navigator.language || navigator.userLanguage; };
var getLanguage = function () { return getStoredLanguage() || getBrowserLanguage(); };
var language = getLanguage();

// add your module to this map so it gets used
// please use the translated name of your language ("Français" and not "French"
var map = {
    'fr': 'Français',
    'es': 'Español',
    'pl': 'Polski',
    'de': 'Deutsch',
    'pt-br': 'Português do Brasil'
    'pirate': 'English Pirate', // add our module to the map of languages
};

Just add your module in a similar fashion to the existing translations, save your changes, and close /customize.dist/messages.js. That's all!

Actually translating content

Now we can go back to our file, /customize.dist/translations/messages.pirate.js and start to add our Pirate-language customizations.

Open the translation file you created in /customize.dist/translations/. You should see something like:

define(function () {
    var out = {};

    out.main_title = "Cryptpad: Zero Knowledge, Collaborative Real Time Editing";

Now you just need to work through this file, updating the strings like so:

define(function () {
    var out = {};

    out.main_title = "Cryptpad: Knowledge lost at sea while ye scribble with yer mateys";

It's important that you modify just the string, and not the variable name which is used to access its content. For instance, changing main_title to mainTitle would make the translated string inaccessible to the rest of the codebase.

If a key is not found in your translation, the default English version of that key will be used. This is to make sure that buttons and other interface elements are not empty, but it's obviously not ideal.

Verifying Your Translations

It's advisable to save your translation file frequently, and reload Cryptpad in your browser to check that there are no errors in your translation file. If there are any errors in your code, the file will fail to parse, and the page will no load correctly.

Checking frequently will make it easier to know which change caused the error.

Additionally, we advise using the apps and visiting the various pages, to make sure that your translations make sense in context.

When you're happy with your translation file, you can visit http://localhost:3000/assert/translations/ to view Cryptpad's tests. These tests will check to make sure that your translation has an entry for every entry in the default English translation.

Getting Help

If you have any issues, reach out via any of the methods listed in the readme under Contacting Us. We're happy to help.