Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defineMessages throws Uncaught Reference error when used in index.html of cspace#tenant #211

Open
atsakir opened this issue Apr 30, 2024 · 2 comments

Comments

@atsakir
Copy link

atsakir commented Apr 30, 2024

Following the configuration docs I tried the vocabularyConfiguration example like so:

                <script>
                        cspaceUI({
                                basename: '/cspace/core',
                                prettyUrls: true,
                                tenantId: '1',
                                recordTypes: {
                                        collectionobject: {
                                                vocabularies: {
                                                        category: {
                                                                messages: defineMessages({
                                                                        name: {
                                                                                id: 'vocab.collectionobject.category.name',
                                                                                description: 'Toy category',
                                                                                defaultMessage: 'Toy category',
                                                                        },
                                                                        collectionName: {
                                                                                id: 'vocab.collectionobject.subcategory.collectionName',
                                                                                description: 'Toy categories',
                                                                                defaultMessage: 'Toy categories',
                                                                        },
                                                                }),
                                                                serviceConfig: {
                                                                        servicePath: 'urn:cspace:name(category)',
                                                                },
                                                                sortOrder: 0,
                                                        },
                                                },
                                        },
                                },
                        });
                </script>

using the installed [email protected] source with the default 7.2.0 collaborationSpace installation.
However ,although I can see that react-intl is included in the compiled source, I get an Undefined Reference for defineMessage.

How can this be resolved?

@atsakir atsakir changed the title defineMessage throws Uncaught Reference error when used in index.html of cspace#tenant defineMessages throws Uncaught Reference error when used in index.html of cspace#tenant Apr 30, 2024
@ray-lee
Copy link
Member

ray-lee commented May 2, 2024

You can omit the defineMessages function call:

messages: {
        name: {
                id: 'vocab.collectionobject.category.name',
                description: 'Toy category',
                defaultMessage: 'Toy category',
        },
        collectionName: {
                id: 'vocab.collectionobject.subcategory.collectionName',
                description: 'Toy categories',
                defaultMessage: 'Toy categories',
        },
),

defineMessages actually just returns the argument that's passed in. It's only used as a marker for a babel plugin to extract message definitions so you can send them to a translation service. In this context you don't care about that, so you can omit it.

@ray-lee
Copy link
Member

ray-lee commented May 2, 2024

BTW, collection object is not an authority record, so your configuration won't do anything. A vocabulary is a kind of an authority record. For example, the Concept authority has Activity, Material, and Occasion vocabularies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants