Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
react-i18n-viz
Advanced tools
Visualization of i18n-strings, inspired by railslove/i18n_viz.
...or view the Demo.
In developoment.
This Library provides a Higher-Order Component to wrap around i18n Components. If you hover over such a Component, a Tooltip will be visible with the id and description of the i18n String. This is very useful if you want to check in your Browser which String belongs to which id.
It also includes support for popular i18n Libraries:
Those Components are simply the Components of their Libraries, wrapped with the HOC.
It has nearly no impact on the size of your bundle in Production (or other environments, where the visualization should not be visible). If it isn't used, it won't be bundled.
react-i18n-viz is turned off by default. This prevents that the tooltips are visible in environments, which you don't specify. To enable the Tooltips add a special Environment Variable:
REACT_APP_SHOW_I18N_VIZ=true
You can find a working App in /example.
Instead of importing FormattedMessage
and FormattedHTMLMessage
from react-intl, import them from react-i18n-viz/lib/react-intl
. You can use those components like their react-intl counterparts.
import React from 'react'
import { IntlProvider } from 'react-intl'
import { FormattedMessage } from 'react-i18n-viz/lib/react-intl'
export default class MyComponent extends React.Component {
render() {
return (
<IntlProvider locale="en" messages={/* ... */}>
<div>
<FormattedMessage
id="app.greeting"
description="A friendly greeting."
values={{ name: 'John' }}
/>
</div>
</IntlProvider>
)
}
}
Instead of importing Trans
from react-i18next, import it from react-i18n-viz/lib/react-i18next
. You can use it like the Trans
-Component from react-i18next.
To show a description in the i18n-viz Tolltip, you can provide the description
prop.
import React from 'react'
import { I18nextProvider } from 'react-i18next'
import { Trans } from 'react-i18n-viz/lib/react-i18next'
export default class MyComponent extends React.Component {
render() {
return (
<I18nextProvider i18n={i18n}>
<div>
<Trans i18nKey="app_greeting" description="A friendly greeting.">
Hello {{ name }}, how are you today
</Trans>
</div>
</I18nextProvider>
)
}
}
Example
import { withI18nViz } from 'react-i18n-viz'
class MyCustomI18nComponent {
static propTypes = {
myI18nId: PropTypes.string,
myI18nDescription: PropTypes.string
}
// ...
}
const mapVizProps = props => ({
id: props.myI18nId, // required
description: props.myI18nDescription // optional
})
export default withI18nViz(mapVizProps)(MyCustomI18nComponent)
withI18nViz(mapVizProps)
Enhances a React Component with the i18n visualization.
{ id, description }
.npm install
npm link && cd example && npm link react-i18n-viz
npm start
to bundle the library in dev modecd example && npm start
in a separate shell to start the example appMIT © 2018 - present, Railslove GmbH.
Made for you with 💚 by Railslove.
FAQs
Visualization of i18n-strings for react
We found that react-i18n-viz demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.