Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Nuxt i18n Experience Sharing

Nuxt i18n Experience Sharing

Nuxt i18n 實戰經驗分享 @ v-tw #006
v-tw event: https://vuejs.kktix.cc/events/v-tw-meetup-006

LINE Developers Taiwan

August 19, 2020
Tweet

More Decks by LINE Developers Taiwan

Other Decks in Programming

Transcript

  1. Menu 1. Intro Nuxt i18n 5mins 2. Intro LINE TODAY

    5mins 3. Our Problems 15mins 4. Q&A 5mins
  2. Problem 1 Split Message /\.poll\./ title.poll.page /\.weather\./ info.weather.AQI /\.movie\./ bt.movie.book

    poll_zh_TW.json 20 messages weather_zh_TW.json 50 messages movie_zh_TW.json 130 messages lang/zh_TW.json 700 messages 150 messages Others bt.copy
  3. Problem 1 Split Message Nuxt i18n lazy load 700 messages

    Poll Component Weather Component Movie Component poll_zh_TW.json 20 messages weather_zh_TW.json 50 messages movie_zh_TW.json 130 messages shared 150 messages
  4. Problem 2 SSR import messages import component Async Component 1st

    request 2nd request HTML with language Weather.vue Async Component HTML no language Weather.vue
  5. Problem 2 Solution Nuxt Plugin Import 700 messages import 50

    messages import component Async Component Weather.vue SSR CSR HTML with language
  6. Summary • Split big JSON into small pieces. • Only

    import the messages the you need. • Server side: import the whole messages. • Client side: import messages on the fly. • Don’t use JS literal to save i18n message. Use JSON.
  7. Q&A

  8. 35