question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Intl.RelativeTimeFormat is undefined even if jscFlavor includes intl

See original GitHub issue

Please provide all the information requested. Issues that do not follow this format are likely to stall.

Description

console.log(Intl.RelativeTimeFormat) outputs undefined even if I define in my app/build.gradle the jscFlavor = 'org.webkit:android-jsc-intl:+'. The jscFlavor partially works because I can use the Intl.DateTimeFormat with some options that weren’t working before the flavor change.

React Native version:

0.63.2

Expected Results

Intl.RelativeTimeFormat should be usable

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
podenborgcommented, May 8, 2022

For anyone else having this issue, I was able to get it to work by installing the following poyfills: yarn add @formatjs/intl-locale @formatjs/intl-relativetimeformat

And then in the entry point for my app I added the following:

import { registerRootComponent } from 'expo'
import { Platform } from 'react-native'
import App from './App'

if (Platform.OS === 'android') {
  require('@formatjs/intl-locale/polyfill')
  require('@formatjs/intl-relativetimeformat/polyfill')
  require('@formatjs/intl-relativetimeformat/locale-data/en') // locale-data for en
}

registerRootComponent(App)

You will need to follow these steps after you change the jsc flavor in the app gradle to use the 'org.webkit:android-jsc-intl:+' flavor.

0reactions
cortinicocommented, May 9, 2022

Thanks for sharing @podenborg

Closing as a workaround was suggested 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Intl properly in Android React Native app - Stack Overflow
Though it still says ReferenceError: Can't find variable: Intl . Then I gave up and tried to include custom JSC (I've confirmed that...
Read more >
Intl.RelativeTimeFormat - JavaScript - MDN Web Docs - Mozilla
Returns an Array of objects representing the relative time format in parts that can be used for custom locale-aware formatting. Intl.RelativeTimeFormat.
Read more >
Relative Date Internationalization In JavaScript
The formatter is specifically called Intl.RelativeTimeFormat . ... es-es for Spain spanish, or even undefined to infer the user's locale.
Read more >
react-native-v8 - Bountysource
There are still some tweaks to publish as library. ... and adding the intl in the jscFlavor, the Intl.RelativeTimeFormat isn't available yet (is...
Read more >
Intl.RelativeTimeFormat details - ECMAScript Proposals
Popular localization libraries like Moment.js, Format.js, Globalize, and others have implemented a formatting process for relative time values as well. It is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found