question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AisInstantSearchSsr does not work well with nuxt i18n translation functions

See original GitHub issue

Bug 🐞

What is the current behavior?

I use nuxt.js with <ais-instant-search-ssr> and for the translation of the whole website i use the official nuxt i18n module (https://i18n.nuxtjs.org/). The common function to translate strings with nuxt i18n is is $t(). When i place this somewhere inside the <ais-instant-search-ssr> component i get the error "TypeError: Cannot read property '_t' of undefined". Also i use the <ais-refinement-list> component with transform-items where i translate the labels into the desired language but this leads to the same error.

Make a sandbox with the current behavior

Not possible as true SSR with Nuxt is needed…

What is the expected behavior?

The $t() function should be usable inside the <ais-instant-search-ssr> component without any ugly workaround. My workaround is currently to re-render all <ais-refinement-list> components as soo the mounted()hook is called.

Does this happen only in specific situations?

No… in al situations where i use a translation function inside a <ais-instant-search-ssr> component.

What is the proposed solution?

Make $t() available in <ais-instant-search-ssr> or find a way to inject $t() and $tc() functions into <ais-instant-search-ssr>. ($tc() is used for pluralization.)

What is the version you are using?

“nuxt”: “^2.14.3” “vue-instantsearch”: “^3.5.0”, “algoliasearch”: “^4.8.6”,

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:26 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
podlebarcommented, Nov 3, 2021

well yes… if you want the url to change when you click on a facet you need this… because than you can reload the browser and the url will provide the state for the search… otherwise your facets will belost after a reload

1reaction
podlebarcommented, Nov 3, 2021

maybe post your code… makes it easier

singleIndexMapping needs to be imported: import { singleIndex as singleIndexMapping } from 'instantsearch.js/es/lib/stateMappings'

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Guide to Localizing with Nuxt.js | Phrase
Nuxt is a popular JavaScript framework that can help you improve Google rankings. Learn how to use it in your app—with our Nuxt.js...
Read more >
Having problems getting vue-i18n to work with nuxt generate
Everything works as intended when I use the local server but my language switcher isn't updating any of the translation fields when I...
Read more >
Basic Usage - i18n-module
To do this, @nuxtjs/i18n registers a global mixin that provides some helper functions: localePath – Returns the localized URL for a given page....
Read more >
How to use Nuxt i18n & Localazy for Nuxt projects localization
This article will teach you how to set up your Nuxt i18n project and translate your projects with Localazy in a matter of...
Read more >
Nuxt 3 integration - Vue I18n - Intlify
if the locale resource is a function, since it has already been compiled. In this tutorial, the Nuxt 3 application is small, so...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found