Comments (2)
I can work around it in the first file
const getIntl = () =>
createIntl(
{
locale,
messages: locales[locale],
defaultLocale,
onError: error => {
if (error.code === 'MISSING_TRANSLATION') {
return;
}
throw error;
},
},
cache,
);
const internalIntl = getIntl();
const formatMessageOverride: typeof internalIntl.formatMessage<string> = (
...args: Parameters<typeof internalIntl.formatMessage<string>>
) => {
const [description, values, opts] = args;
return internalIntl.formatMessage<string>(description, values, {
...(opts ?? {}),
formatters: {
// @ts-ignore
getDateTimeFormat: internalIntl.formatters.getDateTimeFormat,
getPluralRules: internalIntl.formatters.getPluralRules,
...(opts?.formatters ?? {}),
getNumberFormat: (locals, opts) => {
return {
...internalIntl.formatters.getNumberFormat(locals, opts),
format: internalIntl.formatNumber,
};
},
},
});
};
export const intl = {
...internalIntl,
formatMessage: formatMessageOverride,
$t: formatMessageOverride,
};
from formatjs.
Related Issues (20)
- How to use custom date formats with formatDate ? HOT 1
- react-intl 6.3.0 breaks react widgets embedded into preact pages HOT 11
- Quoting / Escaping does not work correctly with multiple interpolations HOT 3
- Examples are not running HOT 1
- formatMessage crashes if no `id` is passed in production environment HOT 1
- [Help wanted] Wrong formatTime with `hour12: false` only at locale: `fr-TN` HOT 1
- roundingPriority is not polyfilled HOT 1
- Importing intl-displaynames polyfill/locale-data dynamically in Next app bloats bundle size HOT 1
- @formatjs/intl-numberformat @ 8.9.0 -> 8.10.0 breaks Chrome 104 HOT 1
- cli-lib: onMsgExtracted never gets called HOT 1
- Update translation of 'last year' for Swedish locale HOT 1
- @formatjs/cli-lib is not an ESM module HOT 1
- [@formatjs/intl Error MISSING_DATA] should be a warning not an error HOT 3
- [@formatjs/intl-durationformat] package.json deprecation warning HOT 2
- jsonviewer.csv HOT 1
- @formatjs/intl-messageformat, 10.5.0: Plural rules aren't applied correctly HOT 2
- @formatjs/intl-numberformat/polyfill: roundingIncrement seems to be a no-op HOT 3
- [docs] Rich Text Formatting example doesn't work HOT 2
- Polyfill.io has been sold to a weird Chinese company and should no longer be recommended HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from formatjs.