Nuxt-community / i18n-module with Prismic

Hello everyone,

I am looking for a way to make i18n with Prismic on a client's website. I do not want to work with Prismic pages because they do not require a full fledge editor. I would rather be loading specific datasets where it matters. Things like partners list [name, logo, link, status, priority...] and some blog posts with the usual metadata that they come with.

Right now, my research sessions are not conclusive as they all talk about pages or stuff far out of the scope I want. All the logic I want is the following:
if $i18n.locale is 'fr' fetch prismic datasets in 'fr' locale

Here is my code:

async asyncData({ $i18n, $prismic, error }) {
            try {
                let languages = $prismic.api.data.languages;

                let newsArticles;

                if ($i18n.locale === 'fr') {
                    newsArticles = await $prismic.api.query(
                        $prismic.predicates.at('document.type', 'news_articles', { lang: 'fr-ca' }),
                    );
                } else if ($i18n.locale === 'en') {
                    newsArticles = await $prismic.api.query(
                        $prismic.predicates.at('document.type', 'news_articles', { lang: 'en-ca' }),
                    );
                }

                return {
                    posts: newsArticles.results,
                };
            } catch (e) {
                error({ statusCode: 404, message: 'Page not found' });
            }

            return null;
        },

All I get are 404s from this query. Is the problem up here in this code? My link resolver and html serialiser are untouched from the doc.

I know for a fact everything outside prismic is working; i18n is doing its thing with the vue router and meta values in the HTML head very well.

sigh
I am not a developer, I'm a UI/UX designer trying to get things I don't fully understand work together. I'd simply appreciate if someone could guide me in the right direction based on what I shared here.

Thank you to everyone willing to spend few minutes to help me get out of this mess haha!

EDIT: clarifications & typos, I'm ESL lol.

Hello @nicolas-giuristante

Thanks for reaching out to us.

We recommend implementing language in the project like this:

And I need to debug more your code. It would be better if you can share GitHub code or Zip file with me.

Thanks,
Priyanka

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.