fix: return empty if the key-value is empty value

PR-URL: https://github.com/koajs/locales/pull/17
Reviewed-By: fengmk2 <fengmk2@gmail.com>
Reviewed-By: dead-horse <heyiyu.deadhorse@gmail.com>
This commit is contained in:
ermin.zem
2015-12-22 15:02:45 +08:00
committed by fengmk2
parent e4679a486d
commit c45be8b6ea
4 changed files with 24 additions and 4 deletions

View File

@@ -1,6 +1,4 @@
/**!
* koa-locales - index.js
*
/**
* Copyright(c) koajs and other contributors.
* MIT Licensed
*
@@ -87,7 +85,11 @@ module.exports = function (app, options) {
const locale = this.__getLocale();
const resource = resources[locale] || {};
const text = resource[key] || key;
let text = resource[key];
if (text === undefined) {
text = key;
}
debug('%s: %j => %j', locale, key, text);
if (!text) {
return '';