pydio / cells

Future-proof content collaboration platform
https://pydio.com
GNU Affero General Public License v3.0
1.78k stars 173 forks source link

Enhancement: language support for collabaro (editor libreoffice) #521

Closed raidroGS closed 5 months ago

raidroGS commented 9 months ago

Collabora is starting with english language as default

Server Versions:

Collabora needs &lang=[language] during start

Only small changes in editor.libreoffice/res/js/editor.js needed

    componentDidMount() {
        const {editorModify} = this.props;
        if (this.props.isActive) {
            editorModify({fixedToolbar: true})
        }
        const pydio = Pydio.getInstance();
        const configs = pydio.getPluginConfigs("editor.libreoffice")

        pydio.notify('longtask_starting');
        const iframeUrl = configs.get("LIBREOFFICE_CODE_VERSION") === "v21" ? "/browser/dist/cool.html" : "/loleaflet/dist/loleaflet.html";
        const frontUrl = pydio.getFrontendUrl();
        const protocol = frontUrl.protocol === 'https:' ? 'wss:' : 'ws:';

        const webSocketUrl = `${protocol}//${frontUrl.host}`; //host.replace(/^http/gi, 'ws');
        // Check current action state for permission
        const {node} = this.props;
        const readonly = node.hasMetadataInBranch("node_readonly", "true") || (node.getMetadata().get("content_lock") && node.getMetadata().get("content_lock") !== pydio.user.id);
        const permission = readonly ? "readonly" : "edit"
        const uri = "/wopi/files/" + node.getMetadata().get("uuid");
        const fileSrcUrl = encodeURIComponent(`${frontUrl.protocol}//${frontUrl.host}${uri}`);

        const api = new TokenServiceApi(PydioApi.getRestClient())
        const req = new RestDocumentAccessTokenRequest();
        req.Path = PydioApi.getClient().getSlugForNode(node) + node.getPath();
        // get preference language
        const lang = pydio.user.getPreference('lang') || 'en';
        // append &lang=lang at the end of the url
        api.generateDocumentAccessToken(req).then(response => {
            this.setState({url: `${iframeUrl}?host=${webSocketUrl}&WOPISrc=${fileSrcUrl}&access_token=${response.AccessToken}&permission=${permission}&lang=${lang}`});
        })
    }
raidroGS commented 5 months ago

Is fixed in V4.3.5!