[feature/react-intl] Internationalized page titles
See original GitHub issueBefore #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:
- Created 7 years ago
- Reactions:11
- Comments:7
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same problem, any one?
Resolved by #1346