pylixm / django-mdeditor

Django-mdeditor is Markdown Editor plugin application for django base on Editor.md.
https://pypi.org/project/django-mdeditor/
GNU General Public License v3.0
481 stars 103 forks source link

Language unable to set to English #113

Closed tywin1104 closed 4 years ago

tywin1104 commented 4 years ago

Hi! This is amazing work. However I was unable to set language to English under Django's setting 'languaje': 'en' # zh / en / es I suppose this should set the global language to English. However hovering UI elements in the editor still showing up Chinese characters. Thank you!

Wistral commented 4 years ago

upstream(editor.md ) seems already support for English

https://github.com/pandao/editor.md/issues/404

When set settings.MDEDITOR_CONFIGS['default']['language']='en' and refresh my webpage,

I can't see a en.js to be loaded, which is needed to set language to English.

However, I find a way to solve, which directly use js to create an editor according to https://github.com/pandao/editor.md#create-a-markdown-editor

And add some modification to script

<script type="text/javascript">
    $(function () {
        var path = "/static/editor.md/languages/en";
        // not `var path = "/static/editor.md/languages/en.js";`
        // which will cause a load `en.js.js` 404 problema
        editormd.loadScript(path, function () {
            editor.lang = editormd.defaults.lang;
            editor.recreate();
        });
        var editor = editormd("editor", {
            width: "1000px",
            height: "400px",
            float: "right",
            // markdown: "xxxx",     // dynamic set Markdown text
            path: "/static/editor.md/lib/"  // Autoload modules mode, codemirror, marked... dependents libs path
        });

    });
</script>

Effect

image

Anyway, it's a walk-around. maybe django-mdeditor needs to fix bugs

(eg. languaje typo in README)😅

tywin1104 commented 4 years ago

@Wistral Thanks for your answer. Actually this is caused by the typo you mentioned above it was mistyped to languaje, switch this to language works with my current setting 'language': 'en' # zh / en / es