Skip to content

Commit 88d0925

Browse files
committed
Messages: Fix for Globalize.messageFormatter
Impact: There's a bug for development mode only where the overloaded Globalize.messageFormatter fails using the defaultMessage. It only happens when Globalize.messageFormatter or Globalize.formatMessage are used directly, which means this bug doesn't affect cases using the react component <FormatMessage>. Also, it only happens when the defaultMessage has characters that need to be sanitized. Summary: The function that overloads Globalize.messageFormatter to allow default message capability has an approach to guess whether the first argument represents a path or a default message. This is working just fine. During development, when it's identified that this first argument is a default message, it automatically loads this message using Globalize.loadMessage by using a path deduced from the default message by sanitizing it. The problem lies that instead of using this path, it uses the regular (non sanitized) path. This is kinda a regression, kind of not. Please, look at the changes for clarity. Fixes globalizejs#49
1 parent d91860d commit 88d0925

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/message.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ Globalize.prototype.messageFormatter = function(pathOrMessage) {
182182
aux[this.cldr.attributes.bundle] = {};
183183
aux[this.cldr.attributes.bundle][sanitizedPath] = pathOrMessage;
184184
Globalize.loadMessages(aux);
185+
sanitizedPathExists = true;
185186
}
186187

187188
arguments[0] = sanitizedPathExists ? sanitizedPath : pathOrMessage;

0 commit comments

Comments
 (0)