Omnigraffle Translation

Hi ! Is there a way to automatic translate a complete diagramm in one go ???

Thanx

You should be able to script the application of a Google Translate function across the set of shapes that have text, but it will entail the loss of any bolding, italicisation or special fonts for any specific phrases or words.

(No way for a script to know which words in the GT output (if any) match particular words or attribute runs in the input).

(And of course the whole thing could be reasonably disastrous unless checked and edited by a human translator, who might do the whole thing quicker without the “help” of Google Translate :-)

    (function () {
        'use strict';


    // applyToGraphicsText :: Function -> [Graphic] -> [String]
        function applyToGraphicsText(f, gs) {
            return gs.map(function (x) {
                var s = x.text(),
                    fs = s !== '' ? f(s) : '';

                return ( // resulting text, updated in diagram if different
                    (fs !== s) && (x.text = fs),
                    fs
                );
            });
        }


        var og = Application('Omnigraffle'),
            ws = og.windows.where({
                _not: [{
                    id: -1
                }]
            });

        return ws.length ? applyToGraphicsText(
            function (x) {

                return x.toUpperCase(); // replace with a translation function

            },
            ws.at(0) // graphics of canvas of front window
            .canvas.graphics.where({
                _not: [{
                    text: ''
                }]
            })()
        ) : undefined;

    })();