pruvious: [Bug] 500: unref() is not a function

Hi Muris! When using the internationalization method from

import { _ } from '#pruvious/client'

The prod build of the site fails to load:

[nuxt-app] vue:error: 0.352ms
[nitro] [unhandledRejection] TypeError: unref(...) is not a function
    at file:///Users/andreasvirkus/code/kanban/winstonwolf/website/.output/server/chunks/build/default-zreBDqeV.mjs:366:163
    at renderFnWithContext (/Users/andreasvirkus/code/kanban/winstonwolf/website/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js:314:13)
    at ssrRenderSlotInner (/Users/andreasvirkus/code/kanban/winstonwolf/website/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js:114:17)
    at ssrRenderSlot (/Users/andreasvirkus/code/kanban/winstonwolf/website/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js:96:3)
    at _sfc_ssrRender (file:///Users/andreasvirkus/code/kanban/winstonwolf/website/.output/server/chunks/build/Container-DAivcQ4d.mjs:8:3)
    at renderComponentSubTree (/Users/andreasvirkus/code/kanban/winstonwolf/website/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js:444:9)
    at renderComponentVNode (/Users/andreasvirkus/code/kanban/winstonwolf/website/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js:394:12)
    at ssrRenderComponent (/Users/andreasvirkus/code/kanban/winstonwolf/website/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js:86:10)
    at file:///Users/andreasvirkus/code/kanban/winstonwolf/website/.output/server/chunks/build/default-zreBDqeV.mjs:337:13
    at renderComponentSubTree (/Users/andreasvirkus/code/kanban/winstonwolf/website/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js:444:9)
[nitro-runtime] error: 0.03ms

This is what my ./translatable-strings/default.en.ts looks like

import { defineTranslatableStrings } from '#pruvious'

export default defineTranslatableStrings({
  domain: 'default',
  language: 'en',
  strings: {
    footer_copyright: 'All rights reserved',
    footer_privacy_policy: 'Privacy policy',
    footer_contact: 'Get in touch',
    footer_social_media: 'Social media',
    footer_address: 'Address',
  },
})

And I have a components/Footer.vue file that uses it:

<p>{{ _('footer_copyright') }}</p>

As soon as I comment out the _() usage, the prod bundle works as expected (but it works fine with the dev server)

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Thanks for the invite! I was able to replicate the error on my end. It seems that the translation functions _ and __ cannot be used in slots. šŸ˜•

If you place {{ _('footer_copyright') }} outside of <Container /> in Footer.vue, it will work, though I’m not sure why yet. As a workaround, you can use the string directly instead of the function, like this:

<template>
  <Container>
    {{ footerCopyright }}
  </Container>
</template>

<script lang="ts" setup>
import { _, loadTranslatableStrings } from '#pruvious/client'

await loadTranslatableStrings('default')

const footerCopyright = _('footer_copyright')
</script>

Regarding your question about cache issues, I recommend disabling pruvious.pageCache in your nuxt.config.ts when dealing with situations like this. The incident where you saved your settings collection cleared the .cache folder, which is why you noticed changes afterward.

Thanks for the quick response! Perfectly fine with the workaround for now

šŸ‘€ I had the same error šŸ‘€ thanks for this issue and pointing in the right direction. Removed a translatable from header and all is good again šŸ’Æ

Thank you so much for the offer! Invite sent ā¤ļø