tinymce / tinymce-react

Offical TinyMCE React component
MIT License
972 stars 156 forks source link

How to change default language in React-TinyMCE? #109

Closed NimaKaviyani closed 4 years ago

NimaKaviyani commented 4 years ago

I just installed and configured react-tinymce in my React JS Application. Everything work fine !

But, the user interface is in English, and my client would like to have it in Persian. So, I followed the advice on tinymce documentation, but I have this error message that appears in my console:

backend.js:6 Failed to load language: fa_IR from url https://cdn.tiny.cloud/1/q9ubj8bidvmvxe2oevx5l0puv4dv2rea4u61fe28qsec3oh7/tinymce/5.1.6-68/langs/fa_IR.js

imports:

import {Editor} from '@tinymce/tinymce-react';
const lang = 'http://localhost:4000/public/langs/fa';

This is my code:

<Editor
    apiKey='XXXX'
    cloudChannel='5-stable'
    disabled={false}
    id='uuid'
    init={{
        plugins: 'link image code table imagetools media ',
        toolbar: 'undo redo | bold italic | alignleft aligncenter alignright | code | table | image',
        images_upload_url: true,
        file_picker_types: 'file image media',
        directionality: 'rtl',
        language: 'fa_IR',
        language_url: {lang},
    }}
    initialValue={fields.content}
    inline={false}
    onEditorChange={(data) => this.handleModelChange(data)}
    value={fields.content}
/>

Any ideas ? Thank you in advance.

SimonFc commented 4 years ago

The line with language_url: {lang}, should be language_url: lang, so that you pass a string to the language_url setting and not an object. That should fix your issue so I'll close this!