merge develop

This commit is contained in:
John McLear 2013-03-20 01:11:27 +00:00
commit 4ea7ccd104
60 changed files with 6957 additions and 232 deletions

130
out/doc/localization.html Normal file
View file

@ -0,0 +1,130 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Localization - Etherpad Lite v1.2.81 Manual &amp; Documentation</title>
<link rel="stylesheet" href="assets/style.css">
</head>
<body class="apidoc" id="api-section-localization">
<header id="header">
<h1>Etherpad-Lite v1.2.81 Manual &amp; Documentation</h1>
</header>
<div id="toc">
<h2>Table of Contents</h2>
<ul>
<li><a href="#localization_localization">Localization</a><ul>
<li><a href="#localization_translating">Translating</a></li>
<li><a href="#localization_implementation">Implementation</a><ul>
<li><a href="#localization_server_side">Server-side</a></li>
<li><a href="#localization_client_side">Client-side</a></li>
</ul>
</li>
<li><a href="#localization_localizing_plugins">Localizing plugins</a><ul>
<li><a href="#localization_1_mark_the_strings_to_translate">1. Mark the strings to translate</a></li>
<li><a href="#localization_2_create_translate_files_in_the_locales_directory_of_your_plugin">2. Create translate files in the locales directory of your plugin</a></li>
<li><a href="#localization_overwrite_core_messages">Overwrite core messages</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div id="apicontent">
<h1>Localization<span><a class="mark" href="#localization_localization" id="localization_localization">#</a></span></h1>
<p>Etherpad lite provides a multi-language user interface, that&apos;s apart from your users&apos; content, so users from different countries can collaborate on a single document, while still having the user interface displayed in their mother tongue.
</p>
<h2>Translating<span><a class="mark" href="#localization_translating" id="localization_translating">#</a></span></h2>
<p>We rely on <a href="http://translatewiki.net">http://translatewiki.net</a> to handle the translation process for us, so if you&apos;d like to help...
</p>
<ol>
<li>sign up at <a href="http://translatewiki.net">http://translatewiki.net</a></li>
<li>Visit our <a href="https://translatewiki.net/wiki/Translating:Etherpad_lite">TWN project page</a></li>
<li>Click on <code>Translate Etherpad lite interface</code></li>
<li>Choose a target language, you&apos;d like to translate our interface to, and hit <code>Fetch</code></li>
<li>Start translating!</li>
</ol>
<p>Translations will be send back to us regularly and will eventually appear in the next release.
</p>
<h2>Implementation<span><a class="mark" href="#localization_implementation" id="localization_implementation">#</a></span></h2>
<h3>Server-side<span><a class="mark" href="#localization_server_side" id="localization_server_side">#</a></span></h3>
<p><code>/src/locales</code> contains files for all supported languages which contain the translated strings. Translation files are simple <code>*.json</code> files and look like this:
</p>
<pre><code class="json">{ &quot;pad.modals.connected&quot;: &quot;Connect<EFBFBD>.&quot;
, &quot;pad.modals.uderdup&quot;: &quot;Ouvrir dans une nouvelle fen<65>tre.&quot;
, &quot;pad.toolbar.unindent.title&quot;: &quot;D<EFBFBD>sindenter&quot;
, &quot;pad.toolbar.undo.title&quot;: &quot;Annuler (Ctrl-Z)&quot;
, &quot;timeslider.pageTitle&quot;: &quot;{{appTitle}} Curseur temporel&quot;
, ...
}</code></pre>
<p>Each translation consists of a key (the id of the string that is to be translated) and the translated string. Terms in curly braces must not be touched but left as they are, since they represent a dynamically changing part of the string like a variable. Imagine a message welcoming a user: <code>Welcome, {{userName}}!</code> would be translated as <code>Ahoy, {{userName}}!</code> in pirate.
</p>
<h3>Client-side<span><a class="mark" href="#localization_client_side" id="localization_client_side">#</a></span></h3>
<p>We use a <code>language</code> cookie to save your language settings if you change them. If you don&apos;t, we autodetect your locale using information from your browser. Now, that we know your preferred language this information is feeded into a very nice library called <a href="https://github.com/marcelklehr/html10n.js">html10n.js</a>, which loads the appropriate translations and applies them to our templates, providing translation params, pluralization, include rules and even a nice javascript API along the way.
</p>
<h2>Localizing plugins<span><a class="mark" href="#localization_localizing_plugins" id="localization_localizing_plugins">#</a></span></h2>
<h3>1. Mark the strings to translate<span><a class="mark" href="#localization_1_mark_the_strings_to_translate" id="localization_1_mark_the_strings_to_translate">#</a></span></h3>
<p>In the template files of your plugin, change all hardcoded messages/strings...
</p>
<p>from:
</p>
<pre><code class="html">&lt;option value=&quot;0&quot;&gt;Heading 1&lt;/option&gt;</code></pre>
<p>to:
</p>
<pre><code class="html">&lt;option data-l10n-id=&quot;ep_heading.h1&quot; value=&quot;0&quot;&gt;&lt;/option&gt;</code></pre>
<p>In the javascript files of your plugin, chaneg all hardcoded messages/strings...
</p>
<p>from:
</p>
<pre><code class="js">alert (&apos;Chat&apos;);</code></pre>
<p>to:
</p>
<pre><code class="js">alert(window._(&apos;pad.chat&apos;));</code></pre>
<h3>2. Create translate files in the locales directory of your plugin<span><a class="mark" href="#localization_2_create_translate_files_in_the_locales_directory_of_your_plugin" id="localization_2_create_translate_files_in_the_locales_directory_of_your_plugin">#</a></span></h3>
<div class="signature"><ul>
<li>The name of the file must be the language code of the language it contains translations for (see <a href="http://joker-x.github.com/languages4translatewiki/test/">supported lang codes</a>; e.g. en ? English, es ? Spanish...)</li>
<li>The extension of the file must be <code>.json</code></li>
<li>The default language is English, so your plugin should always provide <code>en.json</code></li>
<li><p>In order to avoid naming conflicts, your message keys should start with the name of your plugin followed by a dot (see below)</p>
</li>
<li><p>ep_your-plugin/locales/en.json*</p>
<pre><code>&lt;span class=&quot;type&quot;&gt; &quot;ep_your-plugin.h1&quot;: &quot;Heading 1&quot;
&lt;/span&gt;</code></pre>
</li>
<li><p>ep_your-plugin/locales/es.json*</p>
<pre><code>&lt;span class=&quot;type&quot;&gt; &quot;ep_your-plugin.h1&quot;: &quot;T<EFBFBD>tulo 1&quot;
&lt;/span&gt;</code></pre>
</li>
</div></ul>
<p>Everytime the http server is started, it will auto-detect your messages and merge them automatically with the core messages.
</p>
<h3>Overwrite core messages<span><a class="mark" href="#localization_overwrite_core_messages" id="localization_overwrite_core_messages">#</a></span></h3>
<p>You can overwrite Etherpad Lite&apos;s core messages in your plugin&apos;s locale files.
For example, if you want to replace <code>Chat</code> with <code>Notes</code>, simply add...
</p>
<p><em>ep_your-plugin/locales/en.json</em>
</p>
<pre><code>{ &quot;ep_your-plugin.h1&quot;: &quot;Heading 1&quot;
, &quot;pad.chat&quot;: &quot;Notes&quot;
}</code></pre>
</div>
</body>
</html>