react-intl-universal
Advanced tools
Comparing version 2.7.5 to 2.8.0-beta1
@@ -77,3 +77,4 @@ /* | ||
// commonLocaleDataUrls: COMMON_LOCALE_DATA_URLS, | ||
fallbackLocale: null // Locale to use if a key is not found in the current locale | ||
fallbackLocale: null, // Locale to use if a key is not found in the current locale | ||
debug: false // If true, the message would be fold by span with key | ||
}; | ||
@@ -135,3 +136,3 @@ } | ||
} else { | ||
return msg; | ||
return this.options.debug ? this.createReactElementMessage('span', key, msg, this.options.debug) : msg; | ||
} | ||
@@ -141,3 +142,4 @@ | ||
var msgFormatter = new IntlMessageFormat(msg, currentLocale, formats); | ||
return msgFormatter.format(variables); | ||
var nextMessage = msgFormatter.format(variables); | ||
return this.options.debug ? this.createReactElementMessage('span', key, nextMessage, this.options.debug) : nextMessage; | ||
} catch (err) { | ||
@@ -168,12 +170,3 @@ this.options.warningHandler("react-intl-universal format message failed for key='" + key + "'.", err.message); | ||
if (msg) { | ||
var el = React.createElement("span", { | ||
dangerouslySetInnerHTML: { | ||
__html: msg | ||
} | ||
}); | ||
// when key exists, it should still return element if there's defaultMessage() after getHTML() | ||
var defaultMessage = function defaultMessage() { | ||
return el; | ||
}; | ||
return Object.assign({ defaultMessage: defaultMessage, d: defaultMessage }, el); | ||
return this.createReactElementMessage('span', key, msg, this.options.debug); | ||
} | ||
@@ -333,2 +326,16 @@ return ""; | ||
} | ||
}, { | ||
key: "createReactElementMessage", | ||
value: function createReactElementMessage(elem, key, msg, debug) { | ||
var el = React.createElement(elem, { | ||
alt: debug ? key : undefined, | ||
dangerouslySetInnerHTML: { | ||
__html: msg | ||
} | ||
}); | ||
var defaultMessage = function defaultMessage() { | ||
return el; | ||
}; | ||
return Object.assign({ defaultMessage: defaultMessage, d: defaultMessage }, el); | ||
} | ||
}]); | ||
@@ -335,0 +342,0 @@ return ReactIntlUniversal; |
@@ -83,3 +83,4 @@ /* | ||
// commonLocaleDataUrls: COMMON_LOCALE_DATA_URLS, | ||
fallbackLocale: null // Locale to use if a key is not found in the current locale | ||
fallbackLocale: null, // Locale to use if a key is not found in the current locale | ||
debug: false // If true, the message would be fold by span with key | ||
}; | ||
@@ -141,3 +142,3 @@ } | ||
} else { | ||
return msg; | ||
return this.options.debug ? this.createReactElementMessage('span', key, msg, this.options.debug) : msg; | ||
} | ||
@@ -147,3 +148,4 @@ | ||
var msgFormatter = new IntlMessageFormat(msg, currentLocale, formats); | ||
return msgFormatter.format(variables); | ||
var nextMessage = msgFormatter.format(variables); | ||
return this.options.debug ? this.createReactElementMessage('span', key, nextMessage, this.options.debug) : nextMessage; | ||
} catch (err) { | ||
@@ -174,12 +176,3 @@ this.options.warningHandler("react-intl-universal format message failed for key='" + key + "'.", err.message); | ||
if (msg) { | ||
var el = React.createElement("span", { | ||
dangerouslySetInnerHTML: { | ||
__html: msg | ||
} | ||
}); | ||
// when key exists, it should still return element if there's defaultMessage() after getHTML() | ||
var defaultMessage = function defaultMessage() { | ||
return el; | ||
}; | ||
return Object.assign({ defaultMessage: defaultMessage, d: defaultMessage }, el); | ||
return this.createReactElementMessage('span', key, msg, this.options.debug); | ||
} | ||
@@ -339,2 +332,16 @@ return ""; | ||
} | ||
}, { | ||
key: "createReactElementMessage", | ||
value: function createReactElementMessage(elem, key, msg, debug) { | ||
var el = React.createElement(elem, { | ||
alt: debug ? key : undefined, | ||
dangerouslySetInnerHTML: { | ||
__html: msg | ||
} | ||
}); | ||
var defaultMessage = function defaultMessage() { | ||
return el; | ||
}; | ||
return Object.assign({ defaultMessage: defaultMessage, d: defaultMessage }, el); | ||
} | ||
}]); | ||
@@ -341,0 +348,0 @@ return ReactIntlUniversal; |
{ | ||
"name": "react-intl-universal", | ||
"version": "2.7.5", | ||
"version": "2.8.0-beta1", | ||
"description": "Internationalize React apps. Not only for React component but also for Vanilla JS.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -63,3 +63,3 @@ declare module "react-intl-universal" { | ||
/** | ||
* Get the inital options | ||
* Get the inital options | ||
* @returns {Object} options includes currentLocale and locales | ||
@@ -83,3 +83,3 @@ */ | ||
* Load more locales after init | ||
* @param {Object} locales App locale data | ||
* @param {Object} locales App locale data | ||
*/ | ||
@@ -98,4 +98,5 @@ export function load(locales: { [key: string]: any }): void; | ||
escapeHtml?: boolean; | ||
debug?: boolean; | ||
} | ||
export interface ReactIntlUniversalMessageDescriptor { | ||
@@ -105,3 +106,3 @@ id: string, | ||
} | ||
const intl: { | ||
@@ -108,0 +109,0 @@ determineLocale: typeof determineLocale; |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
53016
763
1