Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Become a backer! 😃`,
},
};
if (message) {
messages['en-US'][template] = message;
}
if (!messages['en-US'][template]) {
console.error('Invalid tweet template', template);
return;
}
const thankyou = '\n\nThank you! 🙏';
const compiled = new IntlMessageFormat(messages['en-US'][template], 'en-US');
let tweet = compiled.format(data);
if (template === 'monthlyStats') {
// A URL always takes 23 chars (+ space)
if (tweet.length < 280 - 24 - thankyou.length) {
tweet += thankyou;
}
}
return tweet;
};
it('formats AST message with placeholders', () => {
const {locale, messages} = config;
const mf = new IntlMessageFormat(messages.ast_var, locale);
const values = {name: 'Eric'};
expect(formatMessage({id: 'ast_var'}, values)).toBe(mf.format(values));
});
static getLocalizedString(id, values) {
try {
const lang = this.getLanguage();
const locale = this.locales[id] || this.defaultLocales[id];
const formater = new IntlMessageFormat(locale, lang);
return formater.format(values);
} catch (e) {
console.error(`Localized string error for key: ${id} n`);
return '';
}
}
const createMessage = (pattern: string, language: string, params: Object): string =>
params.currency != null
? new IntlMessageFormat(
pattern, language, {
number: {
CUR: {
style : 'currency',
currency: params.currency,
}
}
}
).format(params)
: new IntlMessageFormat(
pattern, language
).format(params);
content={blogPost.summary}
key="og:description"
/>
{availableLocales
.filter(locale => locale !== currentLocale)
.map(locale => (
))}
{
const imageURL = new URL(url.href);
imageURL.pathname = "/static/profile.jpg";
return imageURL.href;
export const getLocalizedText = (localization, language, id, values = {}) =>
new IntlMessageFormat(localization[id], language).format(values);
formatMessage(message, values={}) {
const store = this.dispatcher.getStore("IntlStore");
const msg = new IntlMessageFormat(store.getMessage(message), store.getLocales());
return msg.format(values);
}
report(src, callback) {
const removeBtnId = 0;
const cancelBtnId = 1;
showMessageBox({
type: 'error',
buttons: [
new IntlMessageFormat(messages[locale]['playerError.remove'], locale).format(),
new IntlMessageFormat(messages[locale]['common.cancel'], locale).format()
],
cancelId: cancelBtnId,
message: new IntlMessageFormat(messages[locale]['playerError.message'], locale).format(),
detail: new IntlMessageFormat(messages[locale]['playerError.detail'], locale).format({ src })
}, (buttonIndex) => {
if (buttonIndex === removeBtnId) {
callback();
}
});
}
};
memoizedI18nPartial.format = function(values) {
const str = getLangString(locale, data, _path);
const formatter = new IntlMessageFormat(str, locale);
return formatter.format(values);
}
export default (key, values) => {
const msg = new IntlMessageFormat(messages[key])
return msg.format(values)
}