@ladjs/i18n
Advanced tools
Comparing version 3.0.6 to 3.0.7
@@ -182,2 +182,9 @@ "use strict"; | ||
ctx.translateError = function (...args) { | ||
const str = ctx.translate(...args); | ||
const err = new Error(str); | ||
err.no_translate = true; | ||
return err; | ||
}; | ||
return next(); | ||
@@ -184,0 +191,0 @@ } |
{ | ||
"name": "@ladjs/i18n", | ||
"description": "i18n wrapper and Koa middleware for Lad", | ||
"version": "3.0.6", | ||
"version": "3.0.7", | ||
"author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)", | ||
@@ -6,0 +6,0 @@ "ava": { |
@@ -68,3 +68,3 @@ # [**@ladjs/i18n**](https://github.com/ladjs/i18n) | ||
Returns the same string as `i18n.translate`, but wrapped with a new `Error` object with a property `no_translate` and a value set to `true`. | ||
Returns the same string as `i18n.translate`, but wrapped with a new `Error` object with a property `no_translate` set to `true`. | ||
@@ -89,4 +89,5 @@ This is an extremely useful method if you are using `koa-better-error-handler` package in the [Lad][] framework – as it will prevent a double translation from occurring. | ||
* `ctx.state.availableLanguages` (Array) - which is useful for adding a dropdown to select from an available language | ||
* `ctx.state.currentLanguage` (String) - the current locale's language in native language using [country-language][]'s `getLanguage` method. | ||
* `ctx.state.currentLanguage` (String) - the current locale's language in native language using [country-language][]'s `getLanguage` method | ||
* `ctx.translate` (Function) - a helper function for calling `i18n.api.t` to translate a given phrase by its property key name from the `phrases` object option (same as `i18n.translate` except it throws a `ctx.throw` error using [Boom][]) | ||
* `ctx.translateError` (Function) - same as `ctx.translate` except it returns an Error object with a property `no_translate` set to `true` (similar to `i18n.translateError`) | ||
@@ -93,0 +94,0 @@ If the given locale was not available then it will redirect the user to the detected (or default/fallback) locale. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20919
200
202