├── .editorconfig ├── .eslintrc.js ├── .gitignore ├── README.md ├── assets └── README.md ├── components ├── LangSwitcher.vue ├── Logo.vue └── README.md ├── config └── index.js ├── lang ├── en-US.js ├── es-ES.js └── fr-FR.js ├── layouts ├── README.md └── default.vue ├── middleware └── README.md ├── now.json ├── nuxt.config.js ├── package.json ├── pages ├── README.md ├── about.vue ├── dynamicNested │ ├── _category.vue │ ├── _category │ │ └── _subCategory │ │ │ ├── _id.vue │ │ │ └── index.vue │ └── index.vue ├── index.vue ├── post │ └── _id.vue └── posts.vue ├── plugins ├── README.md └── version.js ├── renovate.json ├── static ├── README.md └── favicon.ico ├── store └── README.md └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_size = 2 6 | indent_style = space 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "extends": [ 3 | "@nuxtjs" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | node_modules 3 | 4 | # logs 5 | npm-debug.log 6 | 7 | # Nuxt build 8 | .nuxt 9 | 10 | # Nuxt generate 11 | dist 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nuxt-i18n-example 2 | 3 | > [nuxt-i18n](https://github.com/paulgv/nuxt-i18n) showcase project based on nuxt-starter template 4 | 5 | [https://nuxt-i18n-example.now.sh/](https://nuxt-i18n-example.now.sh/) 6 | 7 | ## Build Setup 8 | 9 | ``` bash 10 | # install dependencies 11 | $ yarn # Or npm install 12 | 13 | # serve with hot reload at localhost:3000 14 | $ yarn dev 15 | 16 | # build for production and launch server 17 | $ yarn build 18 | $ yarn start 19 | 20 | # generate static project 21 | $ yarn generate 22 | ``` 23 | 24 | For detailed explanation on how things work, checkout the [Nuxt.js docs](https://github.com/nuxt/nuxt.js). 25 | -------------------------------------------------------------------------------- /assets/README.md: -------------------------------------------------------------------------------- 1 | # ASSETS 2 | 3 | This directory contains your un-compiled assets such as LESS, SASS, or JavaScript. 4 | 5 | More information about the usage of this directory in the documentation: 6 | https://nuxtjs.org/guide/assets#webpacked 7 | 8 | **This directory is not required, you can delete it if you don't want to use it.** 9 | -------------------------------------------------------------------------------- /components/LangSwitcher.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 23 | -------------------------------------------------------------------------------- /components/Logo.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 80 | -------------------------------------------------------------------------------- /components/README.md: -------------------------------------------------------------------------------- 1 | # COMPONENTS 2 | 3 | The components directory contains your Vue.js Components. 4 | Nuxt.js doesn't supercharge these components. 5 | 6 | **This directory is not required, you can delete it if you don't want to use it.** 7 | -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | import en from '../lang/en-US.js' 2 | import fr from '../lang/fr-FR.js' 3 | import es from '../lang/es-ES.js' 4 | 5 | export const API_ROOT = 'https://jsonplaceholder.typicode.com/' 6 | 7 | export const I18N = { 8 | locales: [ 9 | { 10 | code: 'en', 11 | iso: 'en-US', 12 | name: 'English' 13 | }, 14 | { 15 | code: 'fr', 16 | iso: 'fr-FR', 17 | name: 'Français' 18 | }, 19 | { 20 | code: 'es', 21 | iso: 'es-ES', 22 | name: 'Español' 23 | } 24 | ], 25 | defaultLocale: 'en', 26 | routes: { 27 | about: { 28 | fr: '/a-propos', 29 | en: '/about-us' 30 | }, 31 | posts: { 32 | fr: '/articles' 33 | }, 34 | 'post/_id': { 35 | fr: '/article/:id?', 36 | es: '/articulo/:id?' 37 | }, 38 | 'dynamicNested/_category': { 39 | fr: 'imbrication-dynamique/:category' 40 | } 41 | }, 42 | vueI18n: { 43 | fallbackLocale: 'en', 44 | messages: { en, fr, es } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lang/en-US.js: -------------------------------------------------------------------------------- 1 | export default { 2 | home: 'Homepage', 3 | posts: 'Posts', 4 | about: 'About us', 5 | homepage: { 6 | subtitle: 'nuxt-i18n demo' 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /lang/es-ES.js: -------------------------------------------------------------------------------- 1 | export default { 2 | home: 'Página principal', 3 | posts: 'Artículos', 4 | about: 'Sobre nosotros', 5 | homepage: { 6 | subtitle: 'Demostración nuxt-i18n' 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /lang/fr-FR.js: -------------------------------------------------------------------------------- 1 | export default { 2 | home: 'Accueil', 3 | posts: 'Articles', 4 | about: 'À propos', 5 | homepage: { 6 | subtitle: 'Démo de nuxt-i18n' 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /layouts/README.md: -------------------------------------------------------------------------------- 1 | # LAYOUTS 2 | 3 | This directory contains your Application Layouts. 4 | 5 | More information about the usage of this directory in the documentation: 6 | https://nuxtjs.org/guide/views#layouts 7 | 8 | **This directory is not required, you can delete it if you don't want to use it.** 9 | -------------------------------------------------------------------------------- /layouts/default.vue: -------------------------------------------------------------------------------- 1 | 23 | 24 | 33 | 34 | 131 | 132 | 138 | -------------------------------------------------------------------------------- /middleware/README.md: -------------------------------------------------------------------------------- 1 | # MIDDLEWARE 2 | 3 | This directory contains your Application Middleware. 4 | The middleware lets you define custom function to be ran before rendering a page or a group of pages (layouts). 5 | 6 | More information about the usage of this directory in the documentation: 7 | https://nuxtjs.org/guide/routing#middleware 8 | 9 | **This directory is not required, you can delete it if you don't want to use it.** 10 | -------------------------------------------------------------------------------- /now.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "builds": [ 4 | { 5 | "src": "nuxt.config.js", 6 | "use": "@nuxtjs/now-builder", 7 | "config": { 8 | "serverFiles": [ 9 | "config/**", 10 | "lang/**" 11 | ] 12 | } 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /nuxt.config.js: -------------------------------------------------------------------------------- 1 | import { API_ROOT, I18N } from './config' 2 | 3 | export default { 4 | /* 5 | ** Headers of the page 6 | */ 7 | head: { 8 | title: process.env.npm_package_name || '', 9 | meta: [ 10 | { charset: 'utf-8' }, 11 | { name: 'viewport', content: 'width=device-width, initial-scale=1' }, 12 | { 13 | hid: 'description', 14 | name: 'description', 15 | content: process.env.npm_package_description || '' 16 | } 17 | ], 18 | link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }] 19 | }, 20 | /* 21 | ** Customize the progress bar color 22 | */ 23 | loading: { color: '#fff' }, 24 | modules: [ 25 | ['nuxt-i18n', I18N], 26 | [ 27 | '@nuxtjs/axios', 28 | { 29 | baseURL: API_ROOT 30 | } 31 | ] 32 | ], 33 | plugins: [ 34 | { src: '~/plugins/version' } 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nuxt-i18n-example", 3 | "version": "1.0.0", 4 | "description": "nuxt-i18n showcase project based on nuxt-starter template", 5 | "private": true, 6 | "scripts": { 7 | "dev": "nuxt", 8 | "build": "nuxt build", 9 | "start": "nuxt start", 10 | "generate": "nuxt generate", 11 | "lint": "eslint --ext .js,.vue --ignore-path .gitignore .", 12 | "precommit": "npm run lint" 13 | }, 14 | "dependencies": { 15 | "@nuxtjs/axios": "5.10.1", 16 | "nuxt": "2.12.2", 17 | "nuxt-i18n": "6.10.1" 18 | }, 19 | "devDependencies": { 20 | "@nuxtjs/eslint-config": "2.0.2", 21 | "eslint": "7.0.0", 22 | "eslint-loader": "4.0.2" 23 | }, 24 | "engines": { 25 | "node": ">=10.x" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /pages/README.md: -------------------------------------------------------------------------------- 1 | # PAGES 2 | 3 | This directory contains your Application Views and Routes. 4 | The framework reads all the .vue files inside this directory and create the router of your application. 5 | 6 | More information about the usage of this directory in the documentation: 7 | https://nuxtjs.org/guide/routing 8 | -------------------------------------------------------------------------------- /pages/about.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 20 | -------------------------------------------------------------------------------- /pages/dynamicNested/_category.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 11 | -------------------------------------------------------------------------------- /pages/dynamicNested/_category/_subCategory/_id.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 11 | -------------------------------------------------------------------------------- /pages/dynamicNested/_category/_subCategory/index.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 10 | -------------------------------------------------------------------------------- /pages/dynamicNested/index.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 10 | -------------------------------------------------------------------------------- /pages/index.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 27 | 28 | 71 | -------------------------------------------------------------------------------- /pages/post/_id.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 25 | -------------------------------------------------------------------------------- /pages/posts.vue: -------------------------------------------------------------------------------- 1 | 39 | 40 | 70 | 71 | 137 | -------------------------------------------------------------------------------- /plugins/README.md: -------------------------------------------------------------------------------- 1 | # PLUGINS 2 | 3 | This directory contains your Javascript plugins that you want to run before instantiating the root vue.js application. 4 | 5 | More information about the usage of this directory in the documentation: 6 | https://nuxtjs.org/guide/plugins 7 | 8 | **This directory is not required, you can delete it if you don't want to use it.** 9 | -------------------------------------------------------------------------------- /plugins/version.js: -------------------------------------------------------------------------------- 1 | import packageJson from '../package.json' 2 | 3 | export default (_, inject) => { 4 | inject('nuxtI18nVersion', packageJson.dependencies['nuxt-i18n']) 5 | } 6 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["config:base", "group:allNonMajor"], 3 | "lockFileMaintenance": { 4 | "enabled": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /static/README.md: -------------------------------------------------------------------------------- 1 | # STATIC 2 | 3 | This directory contains your static files. 4 | Each file inside this directory is mapped to /. 5 | 6 | Example: /static/robots.txt is mapped as /robots.txt. 7 | 8 | More information about the usage of this directory in the documentation: 9 | https://nuxtjs.org/guide/assets#static 10 | 11 | **This directory is not required, you can delete it if you don't want to use it.** 12 | -------------------------------------------------------------------------------- /static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulgv/nuxt-i18n-example/20cc6bb908aa3643e53d3ce01011ea9abd3f9f56/static/favicon.ico -------------------------------------------------------------------------------- /store/README.md: -------------------------------------------------------------------------------- 1 | # STORE 2 | 3 | This directory contains your Vuex Store files. 4 | Vuex Store option is implemented in the Nuxt.js framework. 5 | Creating a index.js file in this directory activate the option in the framework automatically. 6 | 7 | More information about the usage of this directory in the documentation: 8 | https://nuxtjs.org/guide/vuex-store 9 | 10 | **This directory is not required, you can delete it if you don't want to use it.** 11 | --------------------------------------------------------------------------------