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.

[feature/react-intl] Internationalized page titles

See original GitHub issue

Before #849 we could use injectIntl and then context.setTitle() to have page titles in different languages like this:

const messages = defineMessages({
  title: {
    id: 'title',
    defaultMessage: 'My title',
    description: 'A page title',
  },
})
...
const { formatMessage } = props.intl;
const title = formatMessage(messages.title)
context.setTitle(title);
...
export default injectIntl(Page);

Is there a new way to do this since we can’t use formatMessage in for example routes/home/index.js, where the title is now set?

(formatMessage only works inside a React component)

Something like this is what I’m looking for:

const messages = defineMessages({
  title: {
    id: 'title',
    defaultMessage: 'My title',
    description: 'A page title',
  },
})
...
async action(context) {
  return {
    component: <Home />,
    title: formatMessage(messages.title) // <- does not work
  };
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:11
  • Comments:7

github_iconTop GitHub Comments

1reaction
lookiscommented, Apr 25, 2017

Same problem, any one?

0reactions
langpavelcommented, Jul 2, 2017

Resolved by #1346

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Intl: Internationalize your React apps - LogRocket Blog
With the React Intl library, learn how to internationalize any React project to seamlessly change language and currency within web apps.
Read more >
Overview | Format.JS
React Intl has two ways to format data, through React components and its API. The components provide an idiomatic-React way of integrating internationalization...
Read more >
React i18n: A step-by-step guide to React-intl - Lokalise Blog
This article is a thorough guide on how to work with React-intl to internationalize your React application. We will discuss the following ...
Read more >
React internationalization with react-intl - Localizely
In this article, we will show you how to internationalize (i18n) your React app with the React Intl library. React is one of...
Read more >
Quick Introduction to Internationalization in React with react-intl
In this article we will see how to internationalize React applications with the react-intl library. React Intl helps to translate React ...
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