index.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>Introduction &mdash; Converse.js 0.3 documentation</title>
  7. <link rel="stylesheet" href="_static/stylesheet.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: '',
  12. VERSION: '0.3',
  13. COLLAPSE_INDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true
  16. };
  17. </script>
  18. <script type="text/javascript" src="_static/jquery.js"></script>
  19. <script type="text/javascript" src="_static/underscore.js"></script>
  20. <script type="text/javascript" src="_static/doctools.js"></script>
  21. <link rel="top" title="Converse.js 0.3 documentation" href="#" />
  22. </head>
  23. <body>
  24. <div id="header_wrap" class="outer">
  25. <header class="inner">
  26. <a id="forkme_banner" href="https://github.com/jcbrand/converse.js">View on GitHub</a>
  27. <h1 id="project_title"><a href="http://conversejs.org">Converse.js</a></h1>
  28. <h2 id="project_tagline">Documentation</h2>
  29. <section id="downloads">
  30. <a class="zip_download_link" href="https://github.com/jcbrand/converse.js/zipball/master">Download this project as a .zip file</a>
  31. <a class="tar_download_link" href="https://github.com/jcbrand/converse.js/tarball/master">Download this project as a tar.gz file</a>
  32. </section>
  33. </header>
  34. </div>
  35. <div id="main_content_wrap" class="outer">
  36. <div class="related">
  37. <h3>Navigation</h3>
  38. <ul>
  39. <li class="right" style="margin-right: 10px">
  40. <a href="genindex.html" title="General Index"
  41. accesskey="I">index</a></li>
  42. <li><a href="#">Converse.js 0.3 documentation</a> &raquo;</li>
  43. </ul>
  44. </div>
  45. <section id="main_content" class="inner">
  46. <div class="document">
  47. <div class="documentwrapper">
  48. <div class="body">
  49. <div class="toctree-wrapper compound">
  50. <ul class="simple">
  51. </ul>
  52. </div>
  53. <div class="contents local topic" id="table-of-contents">
  54. <p class="topic-title first">Table of Contents</p>
  55. <ul class="simple">
  56. <li><a class="reference internal" href="#introduction" id="id1">Introduction</a></li>
  57. <li><a class="reference internal" href="#what-you-will-need" id="id2">What you will need</a><ul>
  58. <li><a class="reference internal" href="#an-xmpp-jabber-server" id="id3">An XMPP/Jabber server</a></li>
  59. <li><a class="reference internal" href="#connection-manager" id="id4">Connection Manager</a><ul>
  60. <li><a class="reference internal" href="#overcoming-cross-domain-request-restrictions" id="id5">Overcoming cross-domain request restrictions</a></li>
  61. </ul>
  62. </li>
  63. <li><a class="reference internal" href="#server-side-authentication" id="id6">Server-side authentication</a><ul>
  64. <li><a class="reference internal" href="#session-support" id="id7">Session Support</a></li>
  65. </ul>
  66. </li>
  67. </ul>
  68. </li>
  69. <li><a class="reference internal" href="#quickstart-to-get-a-demo-up-and-running" id="id8">Quickstart (to get a demo up and running)</a></li>
  70. <li><a class="reference internal" href="#configuration" id="id9">Configuration</a><ul>
  71. <li><a class="reference internal" href="#configuration-variables" id="id10">Configuration variables</a><ul>
  72. <li><a class="reference internal" href="#animate" id="id11">animate</a></li>
  73. <li><a class="reference internal" href="#auto-list-rooms" id="id12">auto_list_rooms</a></li>
  74. <li><a class="reference internal" href="#auto-subscribe" id="id13">auto_subscribe</a></li>
  75. <li><a class="reference internal" href="#bosh-service-url" id="id14">bosh_service_url</a></li>
  76. <li><a class="reference internal" href="#fullname" id="id15">fullname</a></li>
  77. <li><a class="reference internal" href="#hide-muc-server" id="id16">hide_muc_server</a></li>
  78. <li><a class="reference internal" href="#prebind" id="id17">prebind</a></li>
  79. <li><a class="reference internal" href="#xhr-user-search" id="id18">xhr_user_search</a></li>
  80. </ul>
  81. </li>
  82. </ul>
  83. </li>
  84. <li><a class="reference internal" href="#minification" id="id19">Minification</a><ul>
  85. <li><a class="reference internal" href="#minifying-javascript" id="id20">Minifying Javascript</a></li>
  86. <li><a class="reference internal" href="#minifying-css" id="id21">Minifying CSS</a></li>
  87. </ul>
  88. </li>
  89. <li><a class="reference internal" href="#translations" id="id22">Translations</a></li>
  90. </ul>
  91. </div>
  92. <div class="section" id="introduction">
  93. <h1><a class="toc-backref" href="#id1">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h1>
  94. <p>Even though you can connect to public XMPP servers on the <a class="reference external" href="http://conversejs.org">conversejs.org</a>
  95. website, <em>Converse.js</em> is not really meant to be a &#8220;Software-as-a-service&#8221; (SaaS)
  96. webchat.</p>
  97. <p>Instead, its goal is to provide the means for website owners to add a tightly
  98. integrated instant messaging service to their own sites.</p>
  99. <p>As a website owner, you are expected to host <em>Converse.js</em> yourself, and to do some legwork to
  100. properly configure and integrate it into your site.</p>
  101. <p>The benefit in doing this, is that your users have a much more streamlined and integrated
  102. webchat experience and that you have control over the data. The latter being a
  103. requirement for many sites dealing with sensitive information.</p>
  104. <p>You&#8217;ll need to set up your own XMPP server and in order to have
  105. <a class="reference internal" href="#session-support">Session Support</a> (i.e. single-signon functionality whereby users are authenticated once and stay
  106. logged in to XMPP upon page reload) you will also have to add some server-side
  107. code.</p>
  108. <p>The <a class="reference internal" href="#what-you-will-need">What you will need</a> section has more information on all these
  109. requirements.</p>
  110. </div>
  111. <div class="section" id="what-you-will-need">
  112. <h1><a class="toc-backref" href="#id2">What you will need</a><a class="headerlink" href="#what-you-will-need" title="Permalink to this headline">¶</a></h1>
  113. <div class="section" id="an-xmpp-jabber-server">
  114. <h2><a class="toc-backref" href="#id3">An XMPP/Jabber server</a><a class="headerlink" href="#an-xmpp-jabber-server" title="Permalink to this headline">¶</a></h2>
  115. <p><em>Converse.js</em> implements <a class="reference external" href="https://en.wikipedia.org/wiki/Xmpp">XMPP</a> as its messaging protocol, and therefore needs
  116. to connect to an XMPP/Jabber server (Jabber is really just a synonym for XMPP).</p>
  117. <p>You can connect to public XMPP servers like <tt class="docutils literal"><span class="pre">jabber.org</span></tt> but if you want to
  118. have <a class="reference internal" href="#session-support">Session Support</a> you&#8217;ll have to set up your own XMPP server.</p>
  119. <p>You can find a list of public XMPP servers/providers on <a class="reference external" href="http://xmpp.net">xmpp.net</a> and a list of
  120. servers that you can set up yourself on <a class="reference external" href="http://xmpp.org/xmpp-software/servers/">xmpp.org</a>.</p>
  121. </div>
  122. <div class="section" id="connection-manager">
  123. <h2><a class="toc-backref" href="#id4">Connection Manager</a><a class="headerlink" href="#connection-manager" title="Permalink to this headline">¶</a></h2>
  124. <p>Your website and <em>Converse.js</em> use <a class="reference external" href="https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol">HTTP</a> as protocol to communicate with
  125. the webserver. HTTP connections are stateless and usually shortlived.</p>
  126. <p><a class="reference external" href="https://en.wikipedia.org/wiki/Xmpp">XMPP</a> on the other hand, is the protocol that enables instant messaging, and
  127. its connections are stateful and usually longer.</p>
  128. <p>To enable a web application like <em>Converse.js</em> to communicate with an XMPP
  129. server, we need a proxy in the middle that can act as a bridge between the two
  130. protocols.</p>
  131. <p>This is the job of a connection manager. A connection manager can be either a
  132. standalone application or part of an XMPP server. <a class="reference external" href="http://www.ejabberd.im">ejabberd</a> for example,
  133. includes a connection manager (but you have to enable it).</p>
  134. <p>The demo on the <a class="reference external" href="http://conversejs.org">Converse.js homepage</a> uses a a connection manager located at <a class="reference external" href="https://bind.opkode.im">https://bind.opkode.im</a>.
  135. This connection manager is for testing purposes only, please don&#8217;t use it in
  136. production.</p>
  137. <div class="section" id="overcoming-cross-domain-request-restrictions">
  138. <h3><a class="toc-backref" href="#id5">Overcoming cross-domain request restrictions</a><a class="headerlink" href="#overcoming-cross-domain-request-restrictions" title="Permalink to this headline">¶</a></h3>
  139. <p>The domain of the <em>Converse.js</em> demo is <em>conversejs.org</em>, but the domain of the connection manager is <em>opkode.im</em>.
  140. HTTP requests are made by <em>Converse.js</em> to the connection manager via XmlHttpRequests (XHR).
  141. Until recently, it was not possible to make such requests to a different domain
  142. than the one currently being served (to prevent XSS attacks).</p>
  143. <p>Luckily there is now a standard called <a class="reference external" href="https://en.wikipedia.org/wiki/Cross-origin_resource_sharing">CORS</a> (Cross-origin resource sharing), which enables exactly that.
  144. Modern browsers support CORS, but there are problems with Internet Explorer &lt;
  145. 10.</p>
  146. <p>IE 8 and 9 partially support CORS via a proprietary implementation called
  147. XDomainRequest. There is a <a class="reference external" href="https://gist.github.com/1095825/6b4517276f26b66b01fa97b0a78c01275fdc6ff2">Strophe.js plugin</a> which you can use to enable
  148. support for XDomainRequest when it is present.</p>
  149. <p>In IE &lt; 8, there is no support for CORS.</p>
  150. <p>If you need to support these browsers, you can add a front-end proxy in
  151. Apache/Nginx which serves the connection manager under the same domain as your
  152. website. This will remove the need for any cross-domain XHR support.</p>
  153. </div>
  154. </div>
  155. <div class="section" id="server-side-authentication">
  156. <h2><a class="toc-backref" href="#id6">Server-side authentication</a><a class="headerlink" href="#server-side-authentication" title="Permalink to this headline">¶</a></h2>
  157. <div class="section" id="session-support">
  158. <h3><a class="toc-backref" href="#id7">Session Support</a><a class="headerlink" href="#session-support" title="Permalink to this headline">¶</a></h3>
  159. <p>It&#8217;s possible to enable single-site login, whereby users already
  160. authenticated in your website will also automatically be logged in on the chat server,
  161. but this will require custom code on your server.</p>
  162. <p>Jack Moffitt has a great <a class="reference external" href="http://metajack.im/2008/10/03/getting-attached-to-strophe">blogpost</a> about this and even provides an <a class="reference external" href="https://github.com/metajack/strophejs/tree/master/examples/attach">example Django application</a> to demonstrate it.</p>
  163. </div>
  164. </div>
  165. </div>
  166. <div class="section" id="quickstart-to-get-a-demo-up-and-running">
  167. <h1><a class="toc-backref" href="#id8">Quickstart (to get a demo up and running)</a><a class="headerlink" href="#quickstart-to-get-a-demo-up-and-running" title="Permalink to this headline">¶</a></h1>
  168. <p>When you download a specific release of <em>Converse.js</em>, say for example version 0.3,
  169. there will be two minified files inside the zip file.</p>
  170. <p>For version 0.3 they will be:</p>
  171. <ul class="simple">
  172. <li>converse.0.3.min.js</li>
  173. <li>converse.0.3.min.css</li>
  174. </ul>
  175. <p>You can include these two files in your website via the <em>script</em> and <em>link</em>
  176. tags:</p>
  177. <div class="highlight-python"><pre>&lt;link rel="stylesheet" type="text/css" media="screen" href="converse.0.3.min.css"&gt;
  178. &lt;script src="converse.0.3.min.js"&gt;&lt;/script&gt;</pre>
  179. </div>
  180. <p>The <em>index.html</em> file inside the Converse.js folder serves as a nice usable
  181. example of this.</p>
  182. <p>These minified files provide the same demo-like functionality as is available
  183. on the <a class="reference external" href="http://conversejs.org">conversejs.org</a> website. Useful for testing or demoing, but not very
  184. practical.</p>
  185. <p>You&#8217;ll most likely want to implement some kind of single-signon solution for
  186. your website, where users authenticate once in your website and then stay
  187. logged into their XMPP session upon page reload.</p>
  188. <p>For more info on this, read <a class="reference internal" href="#session-support">Session Support</a>.</p>
  189. <p>You might also want to have more fine-grained control of what gets included in
  190. the minified Javascript file. Read <a class="reference internal" href="#configuration">Configuration</a> and <a class="reference internal" href="#minification">Minification</a> for more info on how to do
  191. that.</p>
  192. </div>
  193. <div class="section" id="configuration">
  194. <h1><a class="toc-backref" href="#id9">Configuration</a><a class="headerlink" href="#configuration" title="Permalink to this headline">¶</a></h1>
  195. <p>The included minified JS and CSS files can be used for demoing or testing, but
  196. you&#8217;ll want to configure <em>Converse.js</em> to suit your needs before you deploy it
  197. on your website.</p>
  198. <p><em>Converse.js</em> is passed its configuration settings when you call its
  199. <em>initialize</em> method.</p>
  200. <p>Please refer to the <a class="reference internal" href="#configuration-variables">Configuration variables</a> section below for info on
  201. all the available configuration settings.</p>
  202. <p>After you have configured <em>Converse.js</em>, you&#8217;ll have to regenerate the minified
  203. JS file so that it will include the new settings. Please refer to the
  204. <a class="reference internal" href="#minification">Minification</a> section for more info on how to do this.</p>
  205. <div class="section" id="configuration-variables">
  206. <h2><a class="toc-backref" href="#id10">Configuration variables</a><a class="headerlink" href="#configuration-variables" title="Permalink to this headline">¶</a></h2>
  207. <div class="section" id="animate">
  208. <h3><a class="toc-backref" href="#id11">animate</a><a class="headerlink" href="#animate" title="Permalink to this headline">¶</a></h3>
  209. <p>Default = True</p>
  210. <p>Show animations, for example when opening and closing chat boxes.</p>
  211. </div>
  212. <div class="section" id="auto-list-rooms">
  213. <h3><a class="toc-backref" href="#id12">auto_list_rooms</a><a class="headerlink" href="#auto-list-rooms" title="Permalink to this headline">¶</a></h3>
  214. <p>Default = False</p>
  215. <p>If true, and the XMPP server on which the current user is logged in supports
  216. multi-user chat, then a list of rooms on that server will be fetched.</p>
  217. <p>Not recommended for servers with lots of chat rooms.</p>
  218. <p>For each room on the server a query is made to fetch further details (e.g.
  219. features, number of occupants etc.), so on servers with many rooms this
  220. option will create lots of extra connection traffic.</p>
  221. </div>
  222. <div class="section" id="auto-subscribe">
  223. <h3><a class="toc-backref" href="#id13">auto_subscribe</a><a class="headerlink" href="#auto-subscribe" title="Permalink to this headline">¶</a></h3>
  224. <p>Default = False</p>
  225. <p>If true, the user will automatically subscribe back to any contact requests.</p>
  226. </div>
  227. <div class="section" id="bosh-service-url">
  228. <h3><a class="toc-backref" href="#id14">bosh_service_url</a><a class="headerlink" href="#bosh-service-url" title="Permalink to this headline">¶</a></h3>
  229. <p>Connections to an XMPP server depend on a BOSH connection manager which acts as
  230. a middle man between HTTP and XMPP.</p>
  231. <p>See <a class="reference external" href="http://metajack.im/2008/09/08/which-bosh-server-do-you-need/l">here</a> for more information.</p>
  232. </div>
  233. <div class="section" id="fullname">
  234. <h3><a class="toc-backref" href="#id15">fullname</a><a class="headerlink" href="#fullname" title="Permalink to this headline">¶</a></h3>
  235. <p>If you are using prebinding, you need to specify the fullname of the currently
  236. logged in user.</p>
  237. </div>
  238. <div class="section" id="hide-muc-server">
  239. <h3><a class="toc-backref" href="#id16">hide_muc_server</a><a class="headerlink" href="#hide-muc-server" title="Permalink to this headline">¶</a></h3>
  240. <p>Default = False</p>
  241. <p>Hide the <tt class="docutils literal"><span class="pre">server</span></tt> input field of the form inside the <tt class="docutils literal"><span class="pre">Room</span></tt> panel of the
  242. controlbox. Useful if you want to restrict users to a specific XMPP server of
  243. your choosing.</p>
  244. </div>
  245. <div class="section" id="prebind">
  246. <h3><a class="toc-backref" href="#id17">prebind</a><a class="headerlink" href="#prebind" title="Permalink to this headline">¶</a></h3>
  247. <p>Default = False</p>
  248. <p>Use this option when you want to attach to an existing XMPP connection that was
  249. already authenticated (usually on the backend before page load).</p>
  250. <p>This is useful when you don&#8217;t want to render the login form on the chat control
  251. box with each page load.</p>
  252. <p>When set to true, you&#8217;ll need to make sure that the onConnected method is
  253. called, and passed to it a Strophe connection object.</p>
  254. <p>Besides requiring the back-end to authenticate you, you&#8217;ll also
  255. have to write a Javascript snippet to attach to the set up connection:</p>
  256. <div class="highlight-python"><pre>$.JSON({
  257. 'url': 'mysite.com/xmpp-authenticate',
  258. 'success': function (data) {
  259. connection = new Strophe.Connection(bosh_service_url);
  260. connection.attach(data.jid, data.sid, data.rid, converse.onConnected);
  261. }</pre>
  262. </div>
  263. <p>The backend must authenticate for you, and then return a SID (session ID) and
  264. RID (Request ID), which you use when you attach to the connection.</p>
  265. </div>
  266. <div class="section" id="xhr-user-search">
  267. <h3><a class="toc-backref" href="#id18">xhr_user_search</a><a class="headerlink" href="#xhr-user-search" title="Permalink to this headline">¶</a></h3>
  268. <p>Default = False</p>
  269. <p>There are two ways to add users.</p>
  270. <ul class="simple">
  271. <li>The user inputs a valid JID (Jabber ID), and the user is added as a pending contact.</li>
  272. <li>The user inputs some text (for example part of a firstname or lastname), an XHR will be made to a backend, and a list of matches are returned. The user can then choose one of the matches to add as a contact.</li>
  273. </ul>
  274. <p>This setting enables the second mechanism, otherwise by default the first will
  275. be used.</p>
  276. </div>
  277. </div>
  278. </div>
  279. <div class="section" id="minification">
  280. <h1><a class="toc-backref" href="#id19">Minification</a><a class="headerlink" href="#minification" title="Permalink to this headline">¶</a></h1>
  281. <div class="section" id="minifying-javascript">
  282. <h2><a class="toc-backref" href="#id20">Minifying Javascript</a><a class="headerlink" href="#minifying-javascript" title="Permalink to this headline">¶</a></h2>
  283. <p>We use <a class="reference external" href="http://requirejs.org">require.js</a> to keep track of <em>Converse.js</em> and its dependencies and to
  284. to bundle them together in a single minified file fit for deployment to a
  285. production site.</p>
  286. <p>To use the require.js&#8217;s optimization tool, you&#8217;ll need Node and it&#8217;s package
  287. manager, NPM.</p>
  288. <p>You can then install install require.js for Node like so:</p>
  289. <div class="highlight-python"><pre>npm install requirejs</pre>
  290. </div>
  291. <p>The minified javascript file is then created like this:</p>
  292. <div class="highlight-python"><pre>r.js -o build.js</pre>
  293. </div>
  294. <p>You should now have a new minified file (the name which is specified in build.js).</p>
  295. <p>You can <a class="reference external" href="http://requirejs.org/docs/optimization.html">read more about require.js&#8217;s optimizer here</a>.</p>
  296. </div>
  297. <div class="section" id="minifying-css">
  298. <h2><a class="toc-backref" href="#id21">Minifying CSS</a><a class="headerlink" href="#minifying-css" title="Permalink to this headline">¶</a></h2>
  299. <p>CSS can be minimized with Yahoo&#8217;s yuicompressor tool:</p>
  300. <div class="highlight-python"><pre>yui-compressor --type=css converse.css -o converse.min.css</pre>
  301. </div>
  302. </div>
  303. </div>
  304. <div class="section" id="translations">
  305. <h1><a class="toc-backref" href="#id22">Translations</a><a class="headerlink" href="#translations" title="Permalink to this headline">¶</a></h1>
  306. <p>The gettext POT file located in ./locale/converse.pot is the template
  307. containing all translations and from which for each language an individual PO
  308. file is generated.</p>
  309. <p>The POT file contains all translateable strings extracted from converse.js.</p>
  310. <p>To make a user facing string translateable, wrap it in the double underscore helper
  311. function like so:</p>
  312. <div class="highlight-python"><div class="highlight"><pre><span class="n">__</span><span class="p">(</span><span class="s">&#39;This string will be translated at runtime&#39;</span><span class="p">);</span>
  313. </pre></div>
  314. </div>
  315. <p>After adding the string, you&#8217;ll need to regenerate the POT file, like so:</p>
  316. <div class="highlight-python"><pre>make pot</pre>
  317. </div>
  318. <p>You can then create or update the PO file for a specific language by doing the following:</p>
  319. <div class="highlight-python"><pre>msgmerge ./locale/af/LC_MESSAGES/converse.po ./locale/converse.pot -U</pre>
  320. </div>
  321. <p>This PO file is then what gets translated.</p>
  322. <p>If you&#8217;ve created a new PO file, please make sure to add the following
  323. attributes at the top of the file (under <em>Content-Transfer-Encoding</em>). They are
  324. required as configuration settings for Jed, the Javascript translations library
  325. that we&#8217;re using.</p>
  326. <div class="highlight-python"><div class="highlight"><pre><span class="s">&quot;domain: converse</span><span class="se">\n</span><span class="s">&quot;</span>
  327. <span class="s">&quot;lang: af</span><span class="se">\n</span><span class="s">&quot;</span>
  328. <span class="s">&quot;plural_forms: nplurals=2; plural=(n != 1);</span><span class="se">\n</span><span class="s">&quot;</span>
  329. </pre></div>
  330. </div>
  331. <p>Unfortunately Jed cannot use the PO files directly. We have to generate from it
  332. a file in JSON format and then put that in a .js file for the specific
  333. language.</p>
  334. <p>To generate JSON from a PO file, you&#8217;ll need po2json for node.js. Run the
  335. following command to install it (npm being the node.js package manager):</p>
  336. <div class="highlight-python"><pre>npm install po2json</pre>
  337. </div>
  338. <p>You can then convert the translations into JSON format:</p>
  339. <div class="highlight-python"><pre>po2json locale/af/LC_MESSAGES/converse.po locale/af/LC_MESSAGES/converse.json</pre>
  340. </div>
  341. <p>Now from converse.json paste the data as a value for the &#8220;locale_data&#8221; key in the
  342. object in the language&#8217;s .js file.</p>
  343. <p>So, if you are for example translating into German (language code &#8216;de&#8217;), you&#8217;ll
  344. create or update the file ./locale/LC_MESSAGES/de.js with the following code:</p>
  345. <div class="highlight-python"><pre>(function (root, factory) {
  346. define("af", ['jed'], function () {
  347. return factory(new Jed({
  348. "domain": "converse",
  349. "locale_data": {
  350. // Paste the JSON data from converse.json here
  351. }
  352. })
  353. }
  354. }(this, function (i18n) {
  355. return i18n;
  356. }));</pre>
  357. </div>
  358. <p>making sure to also paste the JSON data as value to the &#8220;locale_data&#8221; key.</p>
  359. <div class="admonition note">
  360. <p class="first admonition-title">Note</p>
  361. <p class="last">If you are adding translations for a new language that is not already supported,
  362. you&#8217;ll have to make one more edit in ./locale/locales.js to make sure the
  363. language is loaded by require.js.</p>
  364. </div>
  365. <p>Congratulations, you&#8217;ve now succesfully added your translations. Sorry for all
  366. those hoops you had to jump through.</p>
  367. </div>
  368. </div>
  369. </div>
  370. <div class="clearer"></div>
  371. </div>
  372. </section>
  373. <div class="related">
  374. <h3>Navigation</h3>
  375. <ul>
  376. <li class="right" style="margin-right: 10px">
  377. <a href="genindex.html" title="General Index"
  378. >index</a></li>
  379. <li><a href="#">Converse.js 0.3 documentation</a> &raquo;</li>
  380. </ul>
  381. </div>
  382. </div>
  383. <div id="footer_wrap" class="outer">
  384. <footer class="inner">
  385. &copy; Copyright 2013, JC Brand.
  386. <p class="copyright">Converse.js created by <a href="http://opkode.com" target="_blank">jcbrand</a></p>
  387. </footer>
  388. </div>
  389. </body>
  390. </html>