nuxt-i18n routing is not working with SSR but working on SPA

1.4k views Asked by At

I was working on nuxt universal(ssr) app and i wanted to add a translation using nuxt-i18n , i followed the config instruction on the site, translation works fine but the routing is not working at all clicking on a link changes the URL on the browser but not content on the page.

Here is my nuxt config file

import colors from 'vuetify/es5/util/colors'

export default {
  mode: 'universal',
  head: {
    titleTemplate: '%s - sme-cip',
    title: 'sme-cip',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },


  css: [
    '~/assets/fonts/raleway.css',
    '~/assets/main.css'
  ],

  // Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
  plugins: [
  ],

  // Auto import components (https://go.nuxtjs.dev/config-components)
  components: true,

  // Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
  buildModules: [
    '@nuxtjs/apollo',
    '@nuxtjs/vuetify',
  ],

  apollo: {
    clientConfigs: {
      default: '~/client-config.js'

    }
  },

  // Modules (https://go.nuxtjs.dev/config-modules)
  modules: [
    '@nuxtjs/axios',
    [
      'nuxt-i18n',
      {
        vueI18n: {
          fallbackLocale: 'en',
          dateTimeFormats: {
            en: {
              short: {
                year: 'numeric',
                month: 'short',
                day: 'numeric'
              },
              long: {
                year: 'numeric',
                month: 'short',
                day: 'numeric',
                weekday: 'short',
                hour: 'numeric',
                minute: 'numeric'
              }
            }
          }
        },
        locales: [
          {
            code: 'en',
            file: 'en.json',
            name: 'English'
          },
          {
            code: 'አማ',
            file: 'am.json',
            name: 'አማርኛ'
          }
        ],
        lazy: true,
        langDir: 'lang/',
        defaultLocale: 'en',
        strategy: 'prefix_and_default'
      }
    ]
  ],

  // Axios module configuration (https://go.nuxtjs.dev/config-axios)
  axios: {},

  // Vuetify module configuration (https://go.nuxtjs.dev/config-vuetify)
  vuetify: {
    treeShake: true,

    defaultAssets: {
      font: {
        family: 'Raleway'
      }
    },
    customVariables: ['~/assets/variables.scss'],
    theme: {
      dark: false,
      themes: {
        light: {
          primary: "#245478",
          accent: colors.grey.darken3,
          secondary: colors.amber.darken3,
          info: colors.teal.lighten1,
          warning: colors.amber.base,
          error: colors.deepOrange.accent4,
          success: colors.green.accent3
        }
      }
    }
  },


}

and here is how i navigate to a route

  <v-btn
              color="black"
              class="px-3 font-weight-bold black--text text-capitalize"
              :to="localePath({ name: 'products' })"
              text
              >Products</v-btn
0

There are 0 answers