diff --git a/lib/app/client.js b/lib/app/client.js index 4f6ebf8a33..6687dd3aa7 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -228,7 +228,7 @@ async function render (to, from, next) { await callMiddleware.call(this, Components, context, layout) if (context._redirected) return - this.error({ statusCode: 404, message: 'This page could not be found.' }) + this.error({ statusCode: 404, message: '<%= messages.error_404 %>' }) return next() } @@ -272,7 +272,7 @@ async function render (to, from, next) { }) // ...If .validate() returned false if (!isValid) { - this.error({ statusCode: 404, message: 'This page could not be found.' }) + this.error({ statusCode: 404, message: '<%= messages.error_404 %>' }) return next() } diff --git a/lib/app/components/nuxt-error.vue b/lib/app/components/nuxt-error.vue index 4a12242201..f5aba8261a 100644 --- a/lib/app/components/nuxt-error.vue +++ b/lib/app/components/nuxt-error.vue @@ -5,16 +5,14 @@
{{ message }}

- Back to the home page + <%= messages.back_to_home %>

<% if(debug) { %> -

- An error occurred while rendering the page. Check developer tools console for details. -

+

<%= messages.client_error_details %>

<% } %> @@ -50,7 +48,7 @@ export default { return (this.error && this.error.statusCode) || 500 }, message () { - return this.error.message || 'Nuxt Server Error' + return this.error.message || '<%= messages.client_error %>' } } } diff --git a/lib/app/server.js b/lib/app/server.js index d8e4859618..01c62be7e6 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -193,7 +193,7 @@ export default async context => { // If no Components found, returns 404 if (!Components.length) { - context.nuxt.error = context.error({ statusCode: 404, message: 'This page could not be found.' }) + context.nuxt.error = context.error({ statusCode: 404, message: '<%= messages.error_404 %>' }) } <% if (isDev) { %>if (asyncDatas.length) debug('Data fetching ' + context.url + ': ' + (Date.now() - s) + 'ms')<% } %> diff --git a/lib/app/views/error.html b/lib/app/views/error.html index 83fc7081c7..d2f6b56444 100644 --- a/lib/app/views/error.html +++ b/lib/app/views/error.html @@ -1,22 +1,22 @@ -Application error +<%= messages.server_error %>
-
Application error
-
<% if (debug) { %>{{ message }}<% } else { %>An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.<% } %>
+
<%= messages.server_error %>
+
<% if (debug) { %>{{ message }}<% } else { %><%= messages.server_error_details %><% } %>
diff --git a/lib/builder/builder.js b/lib/builder/builder.js index e8a01c9972..ed09d87f27 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -203,6 +203,7 @@ export default class Builder extends Tapable { ] const templateVars = { options: this.options, + messages: this.options.messages, uniqBy: _.uniqBy, isDev: this.options.dev, debug: this.options.debug, diff --git a/lib/common/options.js b/lib/common/options.js index a232b2d62f..d0fe88746b 100755 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -276,6 +276,12 @@ Options.defaults = { chokidar: {} }, messages: { - not_found: 'This page could not be found.' + error_404: 'This page could not be found (404)', + server_error: 'Server error', + nuxtjs: 'Nuxt.js', + back_to_home: 'Back to the home page', + server_error_details: 'An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.', + client_error: 'Error', + client_error_details: 'An error occurred while rendering the page. Check developer tools console for details.' } }