Update README about translations
This commit is contained in:
parent
3b71c8b0b5
commit
f17b84d7e9
@ -20,63 +20,51 @@ To include your translation in the list, you'll need to add it to `/customize.di
|
|||||||
There are comments indicating what to modify in three places:
|
There are comments indicating what to modify in three places:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
define(['/customize/languageSelector.js',
|
(function () {
|
||||||
'/customize/translations/messages.js',
|
var LS_LANG = "CRYPTPAD_LANG";
|
||||||
'/customize/translations/messages.es.js',
|
|
||||||
'/customize/translations/messages.fr.js',
|
|
||||||
|
|
||||||
// 1) additional translation files can be added here...
|
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();
|
||||||
|
|
||||||
'/bower_components/jquery/dist/jquery.min.js'],
|
// add your module to this map so it gets used
|
||||||
|
// please use the translated name of your language ("Français" and not "French"
|
||||||
// 2) name your language module here...
|
var map = {
|
||||||
function(LS, Default, Spanish, French) {
|
'fr': 'Français',
|
||||||
var $ = window.jQuery;
|
'es': 'Español',
|
||||||
|
'pl': 'Polski',
|
||||||
// 3) add your module to this map so it gets used
|
'de': 'Deutsch',
|
||||||
var map = {
|
'pt-br': 'Português do Brasil'
|
||||||
'fr': French,
|
};
|
||||||
'es': Spanish,
|
|
||||||
};
|
|
||||||
```
|
```
|
||||||
|
|
||||||
We need to modify these three places to include our file:
|
We need to modify that map to include our translation:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
define(['/customize/languageSelector.js',
|
(function () {
|
||||||
'/customize/translations/messages.js',
|
var LS_LANG = "CRYPTPAD_LANG";
|
||||||
'/customize/translations/messages.es.js',
|
|
||||||
'/customize/translations/messages.fr.js',
|
|
||||||
|
|
||||||
// 1) additional translation files can be added here...
|
var getStoredLanguage = function () { return localStorage.getItem(LS_LANG); };
|
||||||
'/customize/translations/messages.pirate.js', // add our module via its path
|
var getBrowserLanguage = function () { return navigator.language || navigator.userLanguage; };
|
||||||
|
var getLanguage = function () { return getStoredLanguage() || getBrowserLanguage(); };
|
||||||
|
var language = getLanguage();
|
||||||
|
|
||||||
'/bower_components/jquery/dist/jquery.min.js'],
|
// add your module to this map so it gets used
|
||||||
|
// please use the translated name of your language ("Français" and not "French"
|
||||||
// 2) name your language module here...
|
var map = {
|
||||||
function(LS, Default, Spanish, French, Pirate) { // name our module 'Pirate' for use as a variable
|
'fr': 'Français',
|
||||||
var $ = window.jQuery;
|
'es': 'Español',
|
||||||
|
'pl': 'Polski',
|
||||||
// 3) add your module to this map so it gets used
|
'de': 'Deutsch',
|
||||||
var map = {
|
'pt-br': 'Português do Brasil'
|
||||||
'fr': French,
|
'pirate': 'English Pirate', // add our module to the map of languages
|
||||||
'es': Spanish,
|
};
|
||||||
'pirate': Pirate, // add our module to the map of languages
|
|
||||||
};
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that the path to the file is `/customize/translations/`, not `/customize.dist/translations`.
|
|
||||||
Cryptpad's server is configured to search for files in `/customize/` first.
|
|
||||||
If a file is not found, it falls back to `/customize.dist/`.
|
|
||||||
This allows administrators of a Cryptpad installation to override the default behaviour with their own files.
|
|
||||||
|
|
||||||
We want translations to be the default behaviour, so we'll place it in `/customize.dist/translations/`, but resolve it via `/customize/translations/`.
|
|
||||||
|
|
||||||
The second and third steps are simpler.
|
|
||||||
Just add your module in a similar fashion to the existing translations, save your changes, and close `/customize.dist/messages.js`.
|
Just add your module in a similar fashion to the existing translations, save your changes, and close `/customize.dist/messages.js`.
|
||||||
That's all!
|
That's all!
|
||||||
|
|
||||||
|
|
||||||
## Actually translating content
|
## 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.
|
Now we can go back to our file, `/customize.dist/translations/messages.pirate.js` and start to add our Pirate-language customizations.
|
||||||
@ -88,9 +76,7 @@ You should see something like:
|
|||||||
define(function () {
|
define(function () {
|
||||||
var out = {};
|
var out = {};
|
||||||
|
|
||||||
// translations must set this key for their language to be available in
|
out.main_title = "Cryptpad: Zero Knowledge, Collaborative Real Time Editing";
|
||||||
// the language dropdowns that are shown throughout Cryptpad's interface
|
|
||||||
out._languageName = 'English';
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Now you just need to work through this file, updating the strings like so:
|
Now you just need to work through this file, updating the strings like so:
|
||||||
@ -99,9 +85,7 @@ Now you just need to work through this file, updating the strings like so:
|
|||||||
define(function () {
|
define(function () {
|
||||||
var out = {};
|
var out = {};
|
||||||
|
|
||||||
// translations must set this key for their language to be available in
|
out.main_title = "Cryptpad: Knowledge lost at sea while ye scribble with yer mateys";
|
||||||
// the language dropdowns that are shown throughout Cryptpad's interface
|
|
||||||
out._languageName = 'Pirate';
|
|
||||||
```
|
```
|
||||||
|
|
||||||
It's important that you modify just the string, and not the variable name which is used to access its content.
|
It's important that you modify just the string, and not the variable name which is used to access its content.
|
||||||
@ -119,8 +103,8 @@ 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.
|
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/ to view Cryptpad's tests.
|
When you're happy with your translation file, you can visit http://localhost:3000/assert/translations/ to view Cryptpad's tests.
|
||||||
Among other things, these tests will check to make sure that your translation has an entry for every entry in the default English translation.
|
These tests will check to make sure that your translation has an entry for every entry in the default English translation.
|
||||||
|
|
||||||
## Getting Help
|
## Getting Help
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user