GoZOo / Symfony2-XML-translations-to-YAML

Tool to convert Symfony2 XML translations files (xliff) to YAML format.
GNU General Public License v3.0
3 stars 1 forks source link

Can't assign to property "form" on "Organiser" #2

Open anuri73 opened 6 years ago

anuri73 commented 6 years ago

I've tried to convert the following xliff document, but some error happen

<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
    <file source-language="fr" datatype="plaintext" original="file.ext">
        <body>

            <trans-unit id="menu.save.items.success">
                <source>menu.save.items.success</source>
                <target>Menu modifié avec succès.</target>
            </trans-unit>
            <trans-unit id="menu.save.items.validate">
                <source>menu.save.items.validate</source>
                <target>Valider les modifications</target>
            </trans-unit>
            <trans-unit id="menu.add.item">
                <source>menu.add.item</source>
                <target>Ajouter un élément au menu</target>
            </trans-unit>
            <trans-unit id="menu.organize">
                <source>menu.organize</source>
                <target>Organiser</target>
            </trans-unit>
            <trans-unit id="menu.organize.form.show">
                <source>menu.organize.form.show</source>
                <target>Montrer les champs Parents et Ordre</target>
            </trans-unit>
            <trans-unit id="menu.organize.form.hide">
                <source>menu.organize.form.hide</source>
                <target>Cacher les champs Parents et Ordre</target>
            </trans-unit>
            <trans-unit id="menu.organize.title">
                <source>menu.organize.title</source>
                <target>Editer le menu</target>
            </trans-unit>
            <trans-unit id="menu.edition">
                <source>menu.edition</source>
                <target>Edition</target>
            </trans-unit>
            <trans-unit id="menu.item.title">
                <source>menu.item.title</source>
                <target>Titre</target>
            </trans-unit>
            <trans-unit id="menu.item.order">
                <source>menu.item.order</source>
                <target>Ordre</target>
            </trans-unit>
            <trans-unit id="menu.item.parent">
                <source>menu.item.parent</source>
                <target>Parent</target>
            </trans-unit>
            <trans-unit id="menu.actions">
                <source>menu.actions</source>
                <target>Actions</target>
            </trans-unit>
            <trans-unit id="menu.name">
                <source>menu.name</source>
                <target>Nom du menu</target>
            </trans-unit>
            <trans-unit id="menu.menu_label">
                <source>menu.menu_label</source>
                <target>Menus</target>
            </trans-unit>
            <trans-unit id="menu.menu_item_label">
                <source>menu.menu_item_label</source>
                <target>Eléments de menu</target>
            </trans-unit>
            <trans-unit id="menu.menu_item.updated">
                <source>menu.menu_item.updated</source>
                <target>Mise à jour enregistrée</target>
            </trans-unit>
            <trans-unit id="menu.menu_item.error">
                <source>menu.menu_item.error</source>
                <target>Une erreur est survenue</target>
            </trans-unit>
            <trans-unit id="id4v.menu_item.warning_delete">
                <source>id4v.menu_item.warning_delete</source>
                <target>Attention, en supprimant cet item, vous supprimerez également ses enfants.</target>
            </trans-unit>

            <trans-unit id="Menu List">
                <source>Menu List</source>
                <target>Liste des menus</target>
            </trans-unit>
            <trans-unit id="Menu Item List">
                <source>Menu Item List</source>
                <target>Listes des Eléments du menu</target>
            </trans-unit>
            <trans-unit id="Depth">
                <source>Depth</source>
                <target>Profondeur</target>
            </trans-unit>
            <trans-unit id="Title">
                <source>Title</source>
                <target>Titre</target>
            </trans-unit>
            <trans-unit id="menu.menu_item.same_window">
                <source>menu.menu_item.same_window</source>
                <target>Même Fenêtre</target>
            </trans-unit>
            <trans-unit id="menu.menu_item.new_window">
                <source>menu.menu_item.new_window</source>
                <target>Nouvelle fenêtre</target>
            </trans-unit>
        </body>
    </file>
</xliff>

Error:

Error: can't assign to property "form" on "Organiser": not an object $scope.add@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/controllers.js:35:5 $scope.add@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/controllers.js:36:5 $scope.add@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/controllers.js:36:5 $scope.convert/<@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/controllers.js:21:4 each@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/jquery.min.js:2:2971 each@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/jquery.min.js:2:833 $scope.convert@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/controllers.js:15:3 functionCall/<@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:176:139 $eval@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:112:315 link/<@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:189:294 Xe</this.$setViewValue/<@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:188:323 q@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:7:278 Xe</this.$setViewValue@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:188:279 l/<@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:137:161 $eval@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:112:315 $apply@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:113:43 l@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:137:141 dispatch@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/jquery.min.js:3:8384 add/r.handle@http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/jquery.min.js:3:5122 angular.min.js:92:210 e/< http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:92:210 Rd/this.$get</< http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:68:175 Xe</this.$setViewValue/< http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:188:336 q http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:7:278 Xe</this.$setViewValue http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:188:279 l/< http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:137:161 $eval http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:112:315 $apply http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:113:43 l http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/angular.min.js:137:141 dispatch http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/jquery.min.js:3:8384 add/r.handle http://gozoo.github.io/Symfony2-XML-translations-to-YAML/js/jquery.min.js:3:5122

GoZOo commented 6 years ago

menu.organize has a value AND children menu.organize.form.show, menu.organize.form.hide, menu.organize.title etc.

It's not possible in a yaml format.

I'll publish a patch to take care of this case and add a warning about this.

Remove the ancestors and conversion should work:

<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
    <file source-language="fr" datatype="plaintext" original="file.ext">
        <body>

            <trans-unit id="menu.save.items.success">
                <source>menu.save.items.success</source>
                <target>Menu modifié avec succès.</target>
            </trans-unit>
            <trans-unit id="menu.save.items.validate">
                <source>menu.save.items.validate</source>
                <target>Valider les modifications</target>
            </trans-unit>
            <trans-unit id="menu.add.item">
                <source>menu.add.item</source>
                <target>Ajouter un élément au menu</target>
            </trans-unit>
            <trans-unit id="menu.organize.form.show">
                <source>menu.organize.form.show</source>
                <target>Montrer les champs Parents et Ordre</target>
            </trans-unit>
            <trans-unit id="menu.organize.form.hide">
                <source>menu.organize.form.hide</source>
                <target>Cacher les champs Parents et Ordre</target>
            </trans-unit>
            <trans-unit id="menu.organize.title">
                <source>menu.organize.title</source>
                <target>Editer le menu</target>
            </trans-unit>
            <trans-unit id="menu.edition">
                <source>menu.edition</source>
                <target>Edition</target>
            </trans-unit>
            <trans-unit id="menu.item.title">
                <source>menu.item.title</source>
                <target>Titre</target>
            </trans-unit>
            <trans-unit id="menu.item.order">
                <source>menu.item.order</source>
                <target>Ordre</target>
            </trans-unit>
            <trans-unit id="menu.item.parent">
                <source>menu.item.parent</source>
                <target>Parent</target>
            </trans-unit>
            <trans-unit id="menu.actions">
                <source>menu.actions</source>
                <target>Actions</target>
            </trans-unit>
            <trans-unit id="menu.name">
                <source>menu.name</source>
                <target>Nom du menu</target>
            </trans-unit>
            <trans-unit id="menu.menu_label">
                <source>menu.menu_label</source>
                <target>Menus</target>
            </trans-unit>
            <trans-unit id="menu.menu_item_label">
                <source>menu.menu_item_label</source>
                <target>Eléments de menu</target>
            </trans-unit>
            <trans-unit id="menu.menu_item.updated">
                <source>menu.menu_item.updated</source>
                <target>Mise à jour enregistrée</target>
            </trans-unit>
            <trans-unit id="menu.menu_item.error">
                <source>menu.menu_item.error</source>
                <target>Une erreur est survenue</target>
            </trans-unit>
            <trans-unit id="id4v.menu_item.warning_delete">
                <source>id4v.menu_item.warning_delete</source>
                <target>Attention, en supprimant cet item, vous supprimerez également ses enfants.</target>
            </trans-unit>

            <trans-unit id="Menu List">
                <source>Menu List</source>
                <target>Liste des menus</target>
            </trans-unit>
            <trans-unit id="Menu Item List">
                <source>Menu Item List</source>
                <target>Listes des Eléments du menu</target>
            </trans-unit>
            <trans-unit id="Depth">
                <source>Depth</source>
                <target>Profondeur</target>
            </trans-unit>
            <trans-unit id="Title">
                <source>Title</source>
                <target>Titre</target>
            </trans-unit>
            <trans-unit id="menu.menu_item.same_window">
                <source>menu.menu_item.same_window</source>
                <target>Même Fenêtre</target>
            </trans-unit>
            <trans-unit id="menu.menu_item.new_window">
                <source>menu.menu_item.new_window</source>
                <target>Nouvelle fenêtre</target>
            </trans-unit>
        </body>
    </file>
</xliff>
GoZOo commented 6 years ago

I fix the conversion. In case there is an issue due to conflicting source key, a flatten yaml is generated instead of multiple_level.