Questions tagged [formatjs]

FormatJS is a modular collection of JavaScript libraries for internationalization that are focused on formatting numbers, dates, and strings for displaying to people.

FormatJS is a modular collection of JavaScript libraries for internationalization that are focused on formatting numbers, dates, and strings for displaying to people. It includes a set of core libraries that build on the JavaScript Intl built-ins and industry-wide i18n standards, plus a set of integrations for common template and component libraries.

http://formatjs.io/

50 questions
13
votes
2 answers

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( , document.getElementById('container') ); But there is only one…
qwe asd
  • 1,598
  • 3
  • 21
  • 31
13
votes
1 answer

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 Sprache " "schwere Sprache" } key2 {…
DeBoer
  • 551
  • 1
  • 7
  • 16
5
votes
3 answers

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/dist/locale-data/en locale file. if…
Ant1
  • 344
  • 5
  • 12
4
votes
3 answers

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 the entire team is always reminded to provide a…
amoedoamorim
  • 148
  • 2
  • 15
4
votes
1 answer

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 when false I want to show Night. // message string message =…
Carlton
  • 531
  • 1
  • 5
  • 19
4
votes
1 answer

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.tsx
4
votes
0 answers

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.
4
votes
1 answer

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 - 5000.00. Without repeating the symbol, where ever…
Jason Kleban
  • 20,024
  • 18
  • 75
  • 125
4
votes
0 answers

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 i18next but I found most of them not answering to…
Mikhail Chibel
  • 1,865
  • 1
  • 22
  • 34
4
votes
1 answer

React Intl v2 unable to use 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 the page fails to load and the console shows: …
Thacker
  • 41
  • 1
  • 6
3
votes
1 answer

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?
Dheeraj Vepakomma
  • 26,870
  • 17
  • 81
  • 104
3
votes
2 answers

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/facebook/create-react-app/issues/6560. When using…
PJRobot
  • 1,306
  • 13
  • 14
3
votes
2 answers

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 description of its message. I tried to follow the…
3
votes
2 answers

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 I expect it to render: Service fee: 6.25% But I get a…
Ramon Balthazar
  • 3,907
  • 3
  • 25
  • 34
3
votes
0 answers

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 this message in every different combination for all…
djskinner
  • 8,035
  • 4
  • 49
  • 72
1
2 3 4