Skip to content

Commit

Permalink
added next.js example
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Apr 3, 2022
1 parent 3942121 commit 23a2198
Show file tree
Hide file tree
Showing 59 changed files with 5,546 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,25 @@ If you don't want to manage your translation files manually or are simply lookin
- *[this Angular blog post](https://dev.to/adrai/unleash-the-full-power-of-angular-i18next-4b7o) [introducing i18next-locize-backend](https://dev.to/adrai/unleash-the-full-power-of-angular-i18next-4b7o#how-look)*
- *[the code integration part](https://www.youtube.com/watch?v=ds-yEEYP1Ks&t=423s) in this [YouTube video](https://www.youtube.com/watch?v=ds-yEEYP1Ks)*

## Troubleshooting

Make sure you set the `debug` option of i18next to `true`. This will maybe log more information in the developer console.

**Seeing failed http requests, like 404?**

Are you using a [language detector](https://github.com/i18next/i18next-browser-languageDetector) plugin that detects region specific languages you are not providing? i.e. you provide `'en'` translations but you see a `'en-US'` request first?

This is because of the default `load` [option](https://www.i18next.com/overview/configuration-options) set to `'all'`.

Try to set the `load` [option](https://www.i18next.com/overview/configuration-options) to `'languageOnly'`

```javascript
i18next.init({
load: 'languageOnly',
// other options
})
```

# Getting started

Source can be loaded via [npm](https://www.npmjs.com/package/i18next-http-backend) or [downloaded](https://github.com/i18next/i18next-http-backend/blob/master/i18nextHttpBackend.min.js) from this repo.
Expand Down
45 changes: 45 additions & 0 deletions example/next/.next/build-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"polyfillFiles": [
"static/chunks/polyfills.js"
],
"devFiles": [
"static/chunks/react-refresh.js"
],
"ampDevFiles": [
"static/chunks/webpack.js",
"static/chunks/amp.js"
],
"lowPriorityFiles": [
"static/development/_buildManifest.js",
"static/development/_ssgManifest.js",
"static/development/_middlewareManifest.js"
],
"pages": {
"/": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/index.js"
],
"/_app": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/_app.js"
],
"/_error": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/_error.js"
],
"/client-page": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/client-page.js"
],
"/second-page": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/second-page.js"
]
},
"ampFirstPages": []
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions example/next/.next/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type": "commonjs"}
1 change: 1 addition & 0 deletions example/next/.next/react-loadable-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
6 changes: 6 additions & 0 deletions example/next/.next/server/middleware-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sortedMiddleware": [],
"clientInfo": [],
"middleware": {},
"version": 1
}
7 changes: 7 additions & 0 deletions example/next/.next/server/pages-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"/_app": "pages/_app.js",
"/_document": "pages/_document.js",
"/_error": "pages/_error.js",
"/second-page": "pages/second-page.js",
"/": "pages/index.js"
}
96 changes: 96 additions & 0 deletions example/next/.next/server/pages/_app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
"use strict";
/*
* ATTENTION: An "eval-source-map" devtool has been used.
* This devtool is neither made for production nor for readable output files.
* It uses "eval()" calls to create a separate source file with attached SourceMaps in the browser devtools.
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
* or disable the default devtool with "devtool: false".
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
*/
(() => {
var exports = {};
exports.id = "pages/_app";
exports.ids = ["pages/_app"];
exports.modules = {

/***/ "./next-i18next.config.js":
/*!********************************!*\
!*** ./next-i18next.config.js ***!
\********************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {

eval("\nconst HttpBackend = __webpack_require__(/*! i18next-http-backend/cjs */ \"i18next-http-backend/cjs\");\nconst ChainedBackend = (__webpack_require__(/*! i18next-chained-backend */ \"i18next-chained-backend\")[\"default\"]);\nconst LocalStorageBackend = (__webpack_require__(/*! i18next-localstorage-backend */ \"i18next-localstorage-backend\")[\"default\"]);\nmodule.exports = {\n backend: {\n backendOptions: [\n {\n expirationTime: 60 * 60 * 1000\n },\n {}\n ],\n backends: false ? 0 : []\n },\n // debug: true,\n i18n: {\n defaultLocale: \"en\",\n locales: [\n \"en\",\n \"de\"\n ]\n },\n serializeConfig: false,\n use: false ? 0 : []\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9uZXh0LWkxOG5leHQuY29uZmlnLmpzLmpzIiwibWFwcGluZ3MiOiJBQUFBO0FBQUEsTUFBTUEsV0FBVyxHQUFHQyxtQkFBTyxDQUFDLDBEQUEwQixDQUFDO0FBQ3ZELE1BQU1DLGNBQWMsR0FBRUQsMEZBQTBDO0FBQ2hFLE1BQU1HLG1CQUFtQixHQUFHSCxvR0FBK0M7QUFFM0VJLE1BQU0sQ0FBQ0MsT0FBTyxHQUFHO0lBQ2ZDLE9BQU8sRUFBRTtRQUNQQyxjQUFjLEVBQUU7WUFBQztnQkFBRUMsY0FBYyxFQUFFLEVBQUUsR0FBRyxFQUFFLEdBQUcsSUFBSTthQUFFO1lBQUUsRUFBRTtTQUFDO1FBQ3hEQyxRQUFRLEVBQUUsTUFBNkIsR0FBRyxDQUFrQyxHQUFFLEVBQUU7S0FDakY7SUFDRCxlQUFlO0lBQ2ZDLElBQUksRUFBRTtRQUNKQyxhQUFhLEVBQUUsSUFBSTtRQUNuQkMsT0FBTyxFQUFFO1lBQUMsSUFBSTtZQUFFLElBQUk7U0FBQztLQUN0QjtJQUNEQyxlQUFlLEVBQUUsS0FBSztJQ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9kdWxlIiwiZXhwb3J0cyIsImJhY2tlbmQiLCJiYWNrZW5kT3B0aW9ucyIsImV4cGlyYXRpb25UaW1lIiwiYmFja2VuZHMiLCJpMThuIiwiZGVmYXVsdExvY2FsZSIsImxvY2FsZXMiLCJzZXJpYWxpemVDb25maWciLCJ1c2UiXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///./next-i18next.config.js\n");

/***/ }),

/***/ "./pages/_app.js":
/*!***********************!*\
!*** ./pages/_app.js ***!
\***********************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ \"react/jsx-dev-runtime\");\n/* harmony import */ var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var next_i18next__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! next-i18next */ \"next-i18next\");\n/* harmony import */ var next_i18next__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(next_i18next__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _next_i18next_config__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../next-i18next.config */ \"./next-i18next.config.js\");\n/* harmony import */ var _next_i18next_config__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_next_i18next_config__WEBPACK_IMPORTED_MODULE_2__);\n\n\n\nconst MyApp = ({ Component , pageProps })=>/*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(Component, {\n ...pageProps\n }, void 0, false, {\n fileName: \"/Users/adrai/Projects/i18next/i18next-http-backend/example/next/pages/_app.js\",\n lineNumber: 4,\n columnNumber: 45\n }, undefined)\n;\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ((0,next_i18next__WEBPACK_IMPORTED_MODULE_1__.appWithTranslation)(MyApp, (_next_i18next_config__WEBPACK_IMPORTED_MODULE_2___default())));\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9wYWdlcy9fYXBwLmpzLmpzIiwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFBQTtBQUFpRDtBQUNFO0FBRW5ELE1BQU1FLEtBQUssR0FBRyxDQUFDLEVBQUVDLFNBQVMsR0FBRUMsU0FBUyxHQUFFLGlCQUFLLDhEQUFDRCxTQUFTO1FBQUUsR0FBR0MsU0FBUzs7Ozs7aUJBQUk7QUFBQTtBQUV4RSxpRUFBZUosZ0VBQWtCLENBQUNFLEtBQUssRUFBRUQsNkRBQWMsQ0FBQyIsInNvdXJjZXMiOlsid2VicGFjazovL3YxMC8uL3BhZ2VzL19hcHAuanM/ZTBhZCJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBhcHBXaXRoVHJhbnNsYXRpb24gfSBmcm9tICduZXh0LWkxOG5leHQnXG5pbXBvcnQgbmV4dEkxOG5Db25maWcgZnJvbSAnLi4vbmV4dC1pMThuZXh0LmNvbmZpZydcblxuY29uc3QgTXlBcHAgPSAoeyBDb21wb25lbnQsIHBhZ2VQcm9wcyB9KSA9PiA8Q29tcG9uZW50IHsuLi5wYWdlUHJvcHN9IC8+XG5cbmV4cG9ydCBkZWZhdWx0IGFwcFdpdGhUcmFuc2xhdGlvbihNeUFwcCwgbmV4dEkxOG5Db25maWcpXG4iXSwibmFtZXMiOlsiYXBwV2l0aFRyYW5zbGF0aW9uIiwibmV4dEkxOG5Db25maWciLCJNeUFwcCIsIkNvbXBvbmVudCIsInBhZ2VQcm9wcyJdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///./pages/_app.js\n");

/***/ }),

/***/ "i18next-chained-backend":
/*!******************************************!*\
!*** external "i18next-chained-backend" ***!
\******************************************/
/***/ ((module) => {

module.exports = require("i18next-chained-backend");

/***/ }),

/***/ "i18next-http-backend/cjs":
/*!*******************************************!*\
!*** external "i18next-http-backend/cjs" ***!
\*******************************************/
/***/ ((module) => {

module.exports = require("i18next-http-backend/cjs");

/***/ }),

/***/ "i18next-localstorage-backend":
/*!***********************************************!*\
!*** external "i18next-localstorage-backend" ***!
\***********************************************/
/***/ ((module) => {

module.exports = require("i18next-localstorage-backend");

/***/ }),

/***/ "next-i18next":
/*!*******************************!*\
!*** external "next-i18next" ***!
\*******************************/
/***/ ((module) => {

module.exports = require("next-i18next");

/***/ }),

/***/ "react/jsx-dev-runtime":
/*!****************************************!*\
!*** external "react/jsx-dev-runtime" ***!
\****************************************/
/***/ ((module) => {

module.exports = require("react/jsx-dev-runtime");

/***/ })

};
;

// load runtime
var __webpack_require__ = require("../webpack-runtime.js");
__webpack_require__.C(exports);
var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
var __webpack_exports__ = (__webpack_exec__("./pages/_app.js"));
module.exports = __webpack_exports__;

})();
255 changes: 255 additions & 0 deletions example/next/.next/server/pages/_document.js

Large diffs are not rendered by default.

Loading

0 comments on commit 23a2198

Please sign in to comment.