helloflask / flask-ckeditor

CKEditor integration for Flask, including image upload, code syntax highlight, and more.
https://flask-ckeditor.readthedocs.io
MIT License
202 stars 67 forks source link

is there a way to add babel/babelex support to translate the editor labels? #56

Closed demetrius-mp closed 2 years ago

demetrius-mp commented 2 years ago

im developing a software that will be used with a non english language, so it would be great to translate the labels of the editor

greyli commented 2 years ago

Why don't use the CKEDITOR_LANGUAGE config to set the UI language?

demetrius-mp commented 2 years ago

i didnt know of that option but still, i tried setting it like CKEDITOR_LANGUAGE = 'pt' but it didnt work, is there anything else im missing?

i initialize the extension using the factory pattern, as follows:

from flask_ckeditor import CKEditor

ckeditor = CKEditor()

def init_app(app):
    ckeditor.init_app(app)

i am using it as a flask admin field, as follows:

...
from flask_ckeditor import CKEditorField
...

class PostView(BaseView):
    create_template = 'create_post.html'
    edit_template = 'edit_post.html'

    column_list = ('title', 'description', 'guide', 'tags', 'owner', 'published_by',)

    form_overrides = {
        'content': CKEditorField
    }
    ...

and i render it on the templates like this:

{% extends 'admin/model/edit.html' %}

{% block tail %}
    {{ super() }}
    {{ ckeditor.load() }}
{% endblock %}
demetrius-mp commented 2 years ago

i tried with other language codes, like 'es' and 'de' and it also didnt work

greyli commented 2 years ago

How do you set the config?

greyli commented 2 years ago

You should set it after the app instance is created, like this:

app.config['CKEDITOR_LANGUAGE'] = 'pt'

Output:

image

demetrius-mp commented 2 years ago

How do you set the config?

i use dynaconf, its how i set all of my other flask configurations

You should set it after the app instance is created, like this:

app.config['CKEDITOR_LANGUAGE'] = 'pt'

Output:

image

i tried it like this:

from flask_ckeditor import CKEditor

ckeditor = CKEditor()

def init_app(app):
    app.config['CKEDITOR_LANGUAGE'] = 'pt'
    ckeditor.init_app(app)

and it still didnt work :/

could you please send the code you used to make it work like the image you sent? maybe im missing something else

greyli commented 2 years ago

https://github.com/greyli/flask-ckeditor/tree/master/examples/flask-admin

demetrius-mp commented 2 years ago

GOT IT! https://github.com/greyli/flask-ckeditor/blob/33439ff44d5d3fc25c1776ccaed6edf616c16028/examples/flask-admin/templates/edit.html#L11 i was missing this line thank you so much for replying this fast!