Vue.js / Nuxt.js

Nuxt Internationalization

i18n module, translations, locale detection, route localization, language switching, multilingual SEO

18 คำถามสัมภาษณ์·
Senior
1

What does the @nuxtjs/i18n module bring to a Nuxt application?

คำตอบ

The @nuxtjs/i18n module integrates vue-i18n into Nuxt and adds framework-specific features like automatic routing per locale, browser language detection, multilingual SEO, and automatic generation of localized routes. It significantly simplifies setting up a multilingual application by automatically handling complex technical aspects like redirects, alternate meta tags, and lazy loading of translations.

2

Which configuration allows defining the default locale of a Nuxt i18n application?

คำตอบ

The defaultLocale property in the i18n configuration defines the default language used when no specific locale is detected or requested. This locale serves as a fallback and is used for the site root if the routing strategy allows it. It must correspond to one of the codes defined in the locales array. This is a fundamental parameter that ensures the application always has a functional reference language.

3

How to access translations in a Vue component with @nuxtjs/i18n?

คำตอบ

The useI18n composable provided by @nuxtjs/i18n exposes the t function which allows accessing translations defined in locale files. This function accepts a translation key and optional parameters for interpolation. This is the recommended method in Nuxt 3 with the Composition API, replacing the old this.$t syntax. The composable also provides access to other features like locale, locales, and setLocale to dynamically manage languages.

4

How to dynamically change the active locale in a Nuxt i18n application?

5

What is the difference between prefix_except_default and prefix routing strategies?

+15 คำถามสัมภาษณ์

เชี่ยวชาญ Vue.js / Nuxt.js สำหรับการสัมภาษณ์ครั้งถัดไป

เข้าถึงคำถามทั้งหมด flashcards แบบทดสอบเทคนิค แบบฝึกหัด code review และตัวจำลองสัมภาษณ์

เริ่มใช้ฟรี