53 questions
0
votes
1
answer
372
views
how to use formatjs plugin in rspack's swc loader
Recently I migrated a application from webpack to rspack.
Previously we were using babel-loader to transpile. Now we decided to use rspack's builtin swc-loader.
We are using formatjs for intl support.
...
0
votes
0
answers
640
views
Adding line break to defaultMessage
How to add multiple line breaks to a long sentence using intl.formatmessage?
I tried the following solution but it didn't work for me. Any idea/solutions?
intl.formatMessage(
{
description: 'A ...
0
votes
1
answer
1k
views
Getting "createContext only works in Client Components" while using createIntl
I'm using NextJS 13 with the app router. In a server action I'm trying to obtain localized text. For this I've created the following function:
import { createIntl, createIntlCache, IntlShape } from &...
1
vote
0
answers
841
views
Extracting messages with react-intl and babel-plugin-formatjs doesn't work when default messages are variables
In a CRA project, I am trying to use react-intl and extract all the messages used in all the <FormattedMessage /> components following the documentation, with babel-plugin-formatjs and @formatjs/...
2
votes
1
answer
1k
views
IntlProvider not injecting ids on FormattedMessage
I'm following the guide here to setup automatic id generation for FormattedMessage components under the IntlProvider but it doesn't appear to be injecting the ids at run time since I'm receiving this ...
1
vote
0
answers
148
views
react-intl - Custom date formatter
I would like to specify the date format based on what the user has selected.
When defining the Intl object I can specify the values I would like to include for a date but I can't specify the ordering ...
1
vote
0
answers
1k
views
Error: [@formatjs/intl Error MISSING_DATA] Missing locale data
My project that I am working on is using @formatjs/intl library. And one of the used locales is non existing 'la' locale. I need to figure out a workaround for this locale, the best way would be to ...
4
votes
1
answer
5k
views
Formatjs / react-intl with Vite
Formatjs provides a babel plugin for modules that use react-intl to inject message IDs and remove description. How can I use it with Vite?
1
vote
0
answers
217
views
Unable to add library(intl-messageformat) to ojet project
I am trying to add intl-messageformat to my project, but i am getting undefined
when i tried to load the module.
In path_mapping.json
{
...
"libs": {
...
"intl-...
0
votes
0
answers
72
views
In ReactJS application Using Format.js library how can I convert date to date and time
I am new to React & Format.js. I need to do a small task which I am not able to do so. Please help me to convert date to date and time in my react js app format.js they used as a component it is ...
0
votes
1
answer
157
views
How do I convert ICU formatted strings into an TMX (Translation memory exchange) file?
I am attempting to aggregate multiple data sources and locales into a single TMX translation memory file.
I cannot seem to find any good documentation/existing tools on how converting into TMX format ...
4
votes
3
answers
1k
views
How to make description prop mandatory in FormattedMessage components with eslint
I'm using react-intl and need all uses of FormattedMessage to contain a description prop so that the translators get some context about that string. I also need to enforce it with an eslint rule so ...
2
votes
1
answer
2k
views
Intil.DisplayNames() undefined in Safari version < 14.1
The Intl.Displaynames() constructor enables the translation of language, region and script display names in Javascript.
Unfortunately, this is not supported in Safari versions < 14.1. (see https://...
0
votes
1
answer
1k
views
Any way to pluralize with translations using formatjs?
I originally misunderstood the usage of , as it seems it's only used for single-language applications.
Is there a way to pluralize message that use translations as well? For example, we have a simple ...
6
votes
1
answer
7k
views
If/else in FormatJS / React-intl
Is it possible to have an if/else in a FormatJS message?
Example
I have a boolean variable isDay that should determine what message is shown. When true I want to show the wording "Day" and ...
-1
votes
1
answer
1k
views
Gatsby: WebpackError [React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry
I'm using React Intl for internationalisation in my Gatsby app. The app runs fine as expected with npm start, but the build fails with an error during execution of npm run build command.
Code
// ...
4
votes
2
answers
1k
views
Ignoring specific file path during Format.Js message extraction
When using Create React App and TypeScript, a file is auto-generated in the src directory: react-app-env.d.ts. This file seems necessary to support image imports as discussed here: https://github.com/...
0
votes
1
answer
305
views
How to retain order of translations with FormatJS CLI?
When the messages are extracted they are ordered in the extraction file alphabetically according to their randomly generated ids. Is there any way to prevent that and have them ordered in the exact ...
4
votes
2
answers
5k
views
How to use intl.formatRelativeTime() in the correct way
In my React app, I have to show info saying create 1 hour ago or 1 day ago and also plural as 10 minutes ago or 3 days ago. To achieve that I'm trying to use this API FormatJS and in the specific intl....
2
votes
1
answer
1k
views
How to extract Text in a React application to json react-intl translation files
So I'm trying to add languages support to a React application using react-intl.
The application has the Text in the JSX code.
Is there a tool that can scan the code and generate ids for each Text and ...
5
votes
1
answer
4k
views
How to implement i18n into a micro-frontend application using Module Federation
What would you recommend for implementing i18n in a module federation micro-frontend next.js app?
At the moment (just starting) I got it working with react-intl by declaring the provider in the _app....
0
votes
1
answer
2k
views
FormatJS CLI Extract
I'm trying to get formatjs setup for use with my app which uses react-intl, and i'm running into an issue when doing an extract using their CLI. I currently have custom components that embed the ...
4
votes
2
answers
4k
views
No messages returned when running formatjs extract on project. Any ideas of why?
So, I'm implementing a project in Electron and wanted to implement internationalization into it. I have a simple component that uses react-intl's FormattedMessage and a messages.js file with a ...
0
votes
1
answer
1k
views
Getting a @formatjs/ecma402-abstract version1.3 found error: DateTimeFormat/skeleton.d.ts(4,13) ',' expected. TS1005 Error
In the React project I'm using "react-intl": "^5.6.8" and all of sudden it started breaking when running a dev server or building, throwing an error related to the formatjs:
/...
1
vote
1
answer
389
views
Adding new translations
I'm using FormatJS to localize my app. There's a handy CLI to extract all the translations from the code base. I can generate the en.json file, and send it to the translator. When I get the ...
1
vote
1
answer
3k
views
Error: Debug Failure. Output generation failed when running formatjs extract
When running formatjs extract this is what we got. From the stack trace it seems that the issue is from formatjs themselves. Feel like I am stuck on what the issue is here.
$ formatjs extract './src/**...
2
votes
1
answer
2k
views
React-intl parse json array in locale file
I'm currently working with React-intl v. ^4.7.6. I have a folder called translations where all my locale translations are in. I use IntlProvider to select which file to load based on the user's ...
0
votes
1
answer
1k
views
How to run formatjs compile?
How to run formatjs compile command without replacement of already translated messages?
Now I run it this way:
../../node_modules/.bin/formatjs compile lang/ru.json --out-file compiled-lang/ru.json
2
votes
1
answer
3k
views
How do I configure react-intl to have all dialect locales fall back to their parent language?
I've built a site that translates nicely between en and zh locales, using a select element. Now, I'd like to have my code choose the initial locale based on the value of navigator.language. This led ...
1
vote
2
answers
5k
views
react-intl become formatJs , how re-addlocaledata in react-native
I use react-intl for internationalization and in a component i get and set the locale-data
like that :
import fr from 'react-intl/locale-data/fr';
import en from 'react-intl/locale-data/en';
...
...
4
votes
0
answers
298
views
How to use format.js with node.js
I want to translate error messages on the backend written with the node using https://formatjs.io/ (REST API). Is it possible? I will do the translations based not "accept-language" header.
2
votes
1
answer
2k
views
FormattedHTMLMessage not working after package-update (looking for alternative/fix)
We have recently updated our website's npm packages (react-intl version 4.5.1) and we are using react-intl. The problem is, that we used the FormattedHTMLMessage component which doesn't seem to be ...
2
votes
0
answers
7k
views
Casing of react-intl does not match the underlying filesystem
Current behavior
import { FormattedMessage } from 'react-intl
throws eslint error
module "<path>/node_modules/react-intl/lib/react-intl"
Casing of react-intl does not match the underlying ...
2
votes
1
answer
780
views
How do I use formatJS/CLI with create-react-app
Really dumb question - what's the correct glob format? I'm trying to run
formatjs extract ./src/**/*.js
But it's only going one level deep.
5
votes
3
answers
4k
views
Where to find locale for US in @formatjs/intl-relativetimeformat/dist/locale-data/
I'm migrating react-intl to version 3.0, and need to polyfill locale-data for IE. Specifically I want to load a polyfill of locale data for en-US. I can only find @formatjs/intl-relativetimeformat/...
3
votes
2
answers
9k
views
How to format a number to percentage with two decimals using FormatJs Message Syntax?
Using react-intl I have the following message:
serviceFee: {
en: 'Service fee: ({fee, number, percent})',
...
},
When I call
<FormatMessage id="serviceFee" values={{ fee: 0.0625 }} />
I ...
0
votes
2
answers
3k
views
How to internationalize ReactJS Web Application including Arabic language?
Looking for something compatible with ReactJS to make my Web Application multilingual along with RTL to LTR and vice-versa.
As per my research, I found NPM package called "react-intl" backed by Yahoo ...
0
votes
2
answers
2k
views
Is it possible to reuse `intl` context from IntlProvider?
I have a component (popup) that renders outside of the tree (aka portal), therefore losing the context of IntlProvider:
<IntlProvider locale="en">
<App />
</IntlProvider>
// * &...
0
votes
1
answer
824
views
Formatted message using Complex Message syntax plurar
I try to use FormattedMesage(React intl) to using formatting API. how to create one formatted message, with the plural?
Now:
const outputTimeOutValues = [
{value:'00:00:01', translationId:'...
3
votes
0
answers
206
views
react-intl composite message
I'm struggling to work out the best way to structure messages whereby one of the dynamic values also needs a translation.
For example if I have the message 'Type in Spanish...' I would like to use ...
2
votes
1
answer
3k
views
react-intl render react component as placeholder in formatMessage
I have a component, that uses the injectIntl-HOC, and returns a message
...
return (
<Message>
{intl.formatMessage({
id: 'page.checkout.hint'
}, {
link: <b>{intl....
4
votes
1
answer
621
views
Localizing a currency range
A combination of formatjs & javascript's native Intl.NumberFormat() supports formatting of numbers as currency in various cultures and units. But how can I format a range of currency as $1,000.00 ...
4
votes
0
answers
1k
views
Use java resource bundles for i18n in React
I'm migrating relatively large java application to React and need to implement internationalisation in React application. Sure, there are many libraries available for i18n in React, like FormaJS and ...
13
votes
2
answers
24k
views
React-intl multi language app: changing languages and translations storage
I have react-router app and would like to add i18n. In react-intl example root component wrapped in IntlProvider:
ReactDOM.render(
<IntlProvider locale="en">
<App />
</IntlProvider&...
1
vote
1
answer
7k
views
Time zone issue when using REST Api and JS
I'm using FormatJS library along with Handlebars to display a list of events that occured in the past. I'm calling for an endpoint on my server's REST API which returns me the list of events in Json, ...
0
votes
1
answer
944
views
How can I output long datetime format which includes timzone with moment-timezone and react-intl?
I have some client code which is using react-intl to display currency, language, and date time values in a the user's defined language and region (culture/locale). In addition to these requirements I ...
0
votes
1
answer
3k
views
babel v6 + react-intl v2 + webpack extraction of messages to file
I would like to extract the messages from the source code to a JSON file, using Babel v6, react-intl v2, and webpack. It's all compiling fine, but not extracting anything. How do I make v2 of react-...
4
votes
1
answer
4k
views
React Intl v2 unable to use <FormattedDate> with date from SQL
I've been building an demo with React and came across react-intl. I tried to use the FormattedDate component with a 'value' that is returned from an API call and is stored in 'this.state'
However ...
3
votes
0
answers
247
views
Editor for FormatJS messages
We are using FormatJS and React Intl for a web application of ours, to translate the UI. What we are currently missing is an editor for the messages files.
Does anybody know of a any decent editor ...
13
votes
1
answer
11k
views
i18n for react, formatjs, react-intl
I want to use ICU standard for my i18n in my react app. I want to store my language files like http://userguide.icu-project.org/locale/localizing#TOC-.txt-resource-bundles :
de {
key1 { "Deutsche ...