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

State of Vue I18n

kazupon
February 27, 2021

State of Vue I18n

kazupon

February 27, 2021
Tweet

More Decks by kazupon

Other Decks in Programming

Transcript

  1. KAZUPON Vue.js Core Team Member Vue.js Japan User Group Organizer

    Creator of Vue I18n & Intlify @kazu_pon kazupon
  2. What’s Vue I18n? • Internationalization for Vue.js plugin • Features

    • Translation • Pluralization • Datetime Format • Number Format • Translation per SFC • … and more!
  3. Official Tooling • Bundler middleware • webpack: @intlify/vue-i18n-loader • rollup:

    @intlify/rollup-plugin-vue-i18n • vite: @intlify/vite-plugin-vue-i18n
  4. Official Tooling • Vue Jest Processor • vue-i18n-jest • Vue

    I18n Extensions • @intlify/vue-i18n-extensions • Vue I18n Locale Message Tools • vue-i18n-locale-message • Intlify CLI • @intlify/cli
  5. Third Party Tooling • Nuxt I18n • Babel Edit •

    i18n Ally • IntlliJ IDEA Plugin • vue-i18n-extract
  6. Vue I18n stats • NPM (Feb 2021) • over 180

    releases • 34 Million downloads (total) • Used from over 15,000 packages • JSDelivr • 4 Million downloads / month
  7. Vue I18n stats • Used from over 5,200 Vue /

    Nuxt Apps (Feb, 2021) Vue Telescope
  8. Vue I18n Histories 2015 2016 2014 2017 2018 2019 2020

    Feb Vue v0.8 Oct Vue v1 Sep Vue v2 Sep Vue v3 May Vue I18n v0 Jan Vue I18n v1 June Vue I18n v2 Apr Vue I18n v3 May Vue I18n v4 Feb Vue I18n v5 Apr Vue I18n v6 May Vue I18n v7 June Vue I18n v8 Initial Release! Vue v1 Support! Vue v2 Support! Add many features! - i18n custom block - Datetime Format - Number Format - Component Interpolation - Custom format - SSR - TypeScript type definitions - … and more
  9. V9 Development • Dec 20, 2019 • Released Vue 3

    initial alpha version • Jan 6, 2020 • Started Vue I18n v9 development repo: https://github.com/intlify/vue-i18n-next vue-i18n-next over 600 commits, 9 related tooling development • Feb, 2021 • Released Vue I18n v9!
  10. Full scratch implementation • The Why • Maintenance and enhancement

    has becoming very difficult … • By re-designing and re-writing, Vue I18n could get solidify foundation as an i18n library.
  11. Layered modules • Structured with Monorepo packages vue-i18n @intlify/core @intlify/core-base

    @intlify/message- compiler @intlify/message- resolver @intlify/runtime Entry layer Core layer Utility layer
  12. Layered modules • Better maintainability • More bundle size shavable

    • More extensible • Expose APIs per package • Low-level i18n APIs: @intlify/core-base • Compiler APIs: @intlify/message-compiler
  13. Hybrid APIs • Composition API • Optimized for Vue 3

    Composition API • Legacy API • Almost Compatible v8.x API • Based on Low Level i18n API (@intlify/core-base) Low Level i18n API Composition API Legacy API
  14. Message Compiler • Compiler for Vue I18n Message Format •

    Scanner • Tokenizer • Parser • Transformer • Generator • Generate Message Function from Message
  15. Message Compiler • Compile Process ‘Hi, {name} !’ Tokenizer H

    i , { n a m e } ! Scanner scan & tokenize Hi, { name } ! Tokens Parser Hi, { name } ! syntax analysis type: text value: ‘Hi,’ type: named key: ‘name’ type: text value: ‘ !’ type: message items: […] AST Transformer type: text value: ‘Hi,’ type: named key: ‘name’ type: text value: ‘ !’ type: message items: […] walk & transform Pre-processed AST Generator walk & generate type: text value: ‘Hi,’ type: named key: ‘name’ type: text value: ‘ !’ type: message items: […] Message "function __msg__ (ctx) { … return _normalize([ \\"hi \\”, _interpolate(_named(\\”name\\")), \\” !\\" ]) }" Message Function
  16. Message Compiler • Expose Compiler API • Use-cases • Linter:

    @intlify/eslint-plugin-vue-i18n • CLI: @intlfiy/cli • … and depends on your idea!
  17. Pre-Compilation • Pre-compile locale messages by using official bundler middleware

    (e.g. @intlify/vue-i18n-loader) Pre-Compile yaml javascript
  18. Pre-Compilation • Improve App performance with reduce locale messages compilation

    costs String Case Pre-Compilation Case Reduce locale messages compilation costs!
  19. Vue Devtools Integration • Vue I18n Timeline • Events -

    missing - fallback - message-resolve - message-compilation - message-evaluation - compile-error
  20. Bundle Size Optimization • Vue I18n v9 different builds •

    global build: vue-i18n(.runtime).global(.prod).js • esm-browser build: vue-i18n(.runtime).esm-browser(.prod).js • esm-bundler build: vue-i18n(.runtime).esm-bundler.js • cjs build: vue-i18n.cjs(.prod).js
  21. Bundle Size Optimization • Runtime + Message Compiler vs. Runtime

    only • Runtime + Message Compiler (Default) vue-i18n.esm-bundler.js • Runtime Only vue-i18n.runtime.esm-bundler.js You can reduce message complier size!
  22. Bundle Size Optimization • Feature Flags • `__VUE_I18N_FULL_INSTALL__` • `true`

    (default): Vue I18n APIs + built-in components + directive • `false`: Vue I18n APIs • `__VUE_I18N_LEGACY_API__` • `true` (default): Legacy API + Composition API • `false`: Composition API
  23. Bundle Size Optimization • Case: vite-vue-i18n-starter `vendor.xxxx.js` • No Optimization

    (Full install / Full API / Runtime + Message Compiler) 27.83 KB • Full Optimization: (Composition API / Runtime) 22.00 KB Reduce bundle size about 20% with Tree-Shaking!
  24. New Toolings • Vite Plugin • @intlify/vite-plugin-vue-i18n • Setup Vue

    3 Composition API + Vue I18n Composition API • Intlify CLI • @intlify/cli • `compile` command Locale messages pre-compilation
  25. Message Format Syntax • Enhancement Syntax like ICU message format

    NOTE: This current syntax is still unstable
  26. Main Packages Improvement • vue-i18n • Type inference for TypeScript

    • Custom formatter • @intlify/core-base • Low level i18n APIs improvement • @intlify/message-resolver • pluggable resolver support
  27. Tooling Improvement • Bundler middleware • Monorepo management • ESLint

    Plugin • JSON / YAML parser performance • Vue I18n Processor • vue-jest@v5 support • Intlify CLI • Port from vue-i18n-locale-message
  28. … And • Provide IE 11 Compatibility Build • Move

    kazupon/vue-i18n repo to intlify org • vue-i18n-next codes to intlify/vue-i18n repo
  29. https://intilfy.dev Intlify is a project that aims to improve Developer

    Experience in software internationalization. We will aim to improve the Developer Experience of internationalization by providing libraries, frameworks, and tools that break down barriers to internationalization. Mission “ ”
  30. • Vue I18n is part of Intlify project. • We'll

    be working on solving i18n problem while also working on the Vue ecosystem. • As Vue I18n is growing, Intlify project member wanted. • If you are interested in intlify, please ask me.