@narando/express-preferred-ui-language
Advanced tools
Comparing version 0.23.0 to 0.23.1
@@ -16,6 +16,8 @@ "use strict"; | ||
const LOCALE_DIR = _path.default.join(__dirname, "locales"); | ||
const LOCALE_DIR = _path.default.join(process.cwd(), "app", "locales"); | ||
const preferredUILanguage = () => (req, res, next) => { | ||
const availableLanguages = Object.keys(_expressI18nMiddleware.default.loadLocales(LOCALE_DIR)); | ||
const preferredUILanguage = ({ | ||
customDir = LOCALE_DIR | ||
} = {}) => (req, res, next) => { | ||
const availableLanguages = Object.keys(_expressI18nMiddleware.default.loadLocales(customDir)); | ||
res.locals[LOCALS_NAME] = availableLanguages.map(languageCode => { | ||
@@ -22,0 +24,0 @@ return { |
@@ -5,2 +5,4 @@ "use strict"; | ||
var _path = _interopRequireDefault(require("path")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -24,2 +26,4 @@ | ||
const LOCALES_DIR = _path.default.join(__dirname, "..", "..", "tests", "fixtures", "locales"); | ||
describe("@narando/express-expose-current-year", () => { | ||
@@ -41,4 +45,6 @@ describe("exposeCurrentYear", () => { | ||
}); | ||
it("should modify the response to include the current year", () => { | ||
const middleware = (0, _.default)(); | ||
it("should return a object with de-DE selected", () => { | ||
const middleware = (0, _.default)({ | ||
customDir: LOCALES_DIR | ||
}); | ||
const { | ||
@@ -61,3 +67,5 @@ req, | ||
it("should call the next middleware", () => { | ||
const middleware = (0, _.default)(); | ||
const middleware = (0, _.default)({ | ||
customDir: LOCALES_DIR | ||
}); | ||
const { | ||
@@ -64,0 +72,0 @@ req, |
{ | ||
"name": "@narando/express-preferred-ui-language", | ||
"version": "0.23.0", | ||
"version": "0.23.1", | ||
"description": "", | ||
@@ -40,3 +40,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "a8a68fbccf197b7a01464edcd4250b235d2347d1" | ||
"gitHead": "47844597ba64ae34a51c83e84d745ba1a0867bd6" | ||
} |
5468
93