Hi
I’m using the nuxt plugin https://snipcart.nuxtjs.org/ and want to add a custom component with localized labels (en/nl).
So I’ve added the code below in snipcart/customize.js to override the address fields, but I’m receiving this error whenever I use $localize
:
Syntax Error: Missing semicolon. (77:360) friendly-errors 20:47:17
75 | })
76 |
> 77 | snipcartHTML.innerHTML = '"\n<address-fields>\n <div>\n <fieldset class=\"snipcart-form__set\">\n <div class=\"snipcart-form__row\">\n <div class=\"snipcart-form__field snipcart-form__cell--large\">\n <snipcart-label\n class=\"snipcart__font--tiny\"\n for=\"address1\"\n >{{ $localize('address_form.address1') }}</snipcart-label>\n <snipcart-input name=\"address1\"></snipcart-input>\n <snipcart-error-message name=\"address1\"></snipcart-error-message>\n </div>\n\n <div class=\"snipcart-form__field snipcart-form__cell--tidy\">\n <snipcart-label\n class=\"snipcart__font--tiny\"\n for=\"address2\"\n >{{ $localize('address_form.address2') }}</snipcart-label>\n <snipcart-input name=\"address2\"></snipcart-input>\n <snipcart-error-message name=\"address2\"></snipcart-error-message>\n </div>\n </div>\n </fieldset>\n </div>\n </address-fields>\n"'
| ^
78 | document.body.appendChild(snipcartHTML)
79 | }
80 |
module.exports = `
<address-fields>
<div>
<fieldset class="snipcart-form__set">
<div class="snipcart-form__row">
<div class="snipcart-form__field snipcart-form__cell--large">
<snipcart-label
class="snipcart__font--tiny"
for="address1"
>{{ $localize('address_form.address1') }}</snipcart-label>
<snipcart-input name="address1"></snipcart-input>
<snipcart-error-message name="address1"></snipcart-error-message>
</div>
<div class="snipcart-form__field snipcart-form__cell--tidy">
<snipcart-label
class="snipcart__font--tiny"
for="address2"
>{{ $localize('address_form.address2') }}</snipcart-label>
<snipcart-input name="address2"></snipcart-input>
<snipcart-error-message name="address2"></snipcart-error-message>
</div>
</div>
</fieldset>
</div>
</address-fields>
`;
It works fine when I replace the {{ $localize('address_form.address1') }}
with static text.
I’ve added the following to nuxt.config.js
, but this also doesn’t seem to do the trick. Where should I add translations in a Nuxt project for this to work?
snipcart: {
key: SNIPCART_KEY,
locales: {
en: {
address_form: {
address1: 'Street',
address2: 'Box'
}
},
nl: {
address_form: {
address1: 'Straat',
address2: 'Bus'
}
}
}
},
Would really appreciate some help!
Kind regards
Woet