Search code examples
javascripthtmlinternationalizationaloha-editor

Change language of Aloha-Editor


I want to use the Aloha-Editor for one of my projects. The default project language is german, but I can't find any way to change the language of the editor. (Searched the web and the Guides of their website.)

The only thing I found is how to use i18n when developing a plugin for the editor but not how to set the language in the current stable version.

This is what I did:

<!-- load the jQuery and require.js libraries -->
<script type="text/javascript" src="http://cdn.aloha-editor.org/latest/lib/require.js"></script>
<script type="text/javascript" src="http://cdn.aloha-editor.org/latest/lib/vendor/jquery-1.7.2.js"></script>

<!-- load the Aloha Editor core and some plugins -->
<script src="http://cdn.aloha-editor.org/latest/lib/aloha.js"
        data-aloha-plugins="common/ui,
                            common/format,
                            common/list,
                            common/link,
                            common/highlighteditables">
</script>

<!-- load the Aloha Editor CSS styles -->
<link href="http://cdn.aloha-editor.org/latest/css/aloha.css" rel="stylesheet" type="text/css" />

<!-- make all elements with class="editable" editable with Aloha Editor -->
<script type="text/javascript">
    Aloha.ready( function() {
        var $ = Aloha.jQuery;
        $('.editable').aloha();
    });
</script>

Does anyone know what I need to add or change to get the editor in an other language?


Solution

  • At first I found something in the Aloha Guide about Localization but doing this didn't work for me.

    Than I had a look at the demo pages and came to this working solution. I had to add the following javascript before I include require.js and aloha.js

    <script language="javascript">
        Aloha = window.Aloha || {};
        Aloha.settings = {
            locale: 'de'
        };
    </script>
    

    Then the Aloha script automatically loads the i18n files for the chosen language. I used a local version of aloha and did not test it with the version from http://cdn.aloha-editor.org/latest. My version was 0.22.7.