Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@jamfury/gatsby-theme-i18n
Advanced tools
Learn more about Gatsby Themes here:\ https://www.gatsbyjs.org/blog/2018-11-11-introducing-gatsby-themes/
Learn more about Gatsby Themes here:
https://www.gatsbyjs.org/blog/2018-11-11-introducing-gatsby-themes/
> yarn global add gatsby-cli
> gatsby new we-site-i18n
> cd gatsby-site
> yarn add @jamfury/gatsby-theme-i18n@next
gatsby-config.js
file (sample repo):module.exports = {
__experimentalThemes: [
{
resolve: '@jamfury/gatsby-theme-i18n',
options: {
// these options should ideally be in constants somewhere
// hardcoding here for illustration/usage
availableLngs: ['en-US', 'de-DE'],
fallbackLng: 'en-US'
}
}
],
...
}
./locale
folder> mkdir -p ./locale/en-US && touch ./locale/en-US/messages.json
> mkdir -p ./locale/de-DE && touch ./locale/de-DE/messages.json
Just to see some localized content, let's add the default Gatsby index page copy to our messages files.
Add this to locale/en-US/messages.json
{
"Hi people": "Hi people",
"Welcome to your new Gatsby site.": "Welcome to your new Gatsby site.",
"Now go build something great.": "Now go build something great.",
"Go to page {{page}}": "Go to page {{page}}"
}
Add this to locale/de-DE/messages.json
These were taken from Google Translate, so may not be very accurate
{
"Hi people": "hallo Leute",
"Welcome to your new Gatsby site.": "Willkommen auf Ihrer neuen Gatsby-Site.",
"Now go build something great.": "Bauen Sie jetzt etwas Großes auf.",
"Go to page {{page}}": "Gehe zu Seite {{page}}"
}
Note maintaining string files are tedious, and there are ways to automate the process. One such approach can be seen here in this PR from the
labs-www
project which uses i18next-parser
Update the generated src/pages/index.js
file with the following:
import React from 'react'
import { graphql } from 'gatsby'
import { withI18next } from '@jamfury/gatsby-plugin-i18next'
import { useTranslation } from 'react-i18next'
const IndexPage = () => {
const { t } = useTranslation()
return <h1>{t('Index Page!!')}</h1>
}
export default withI18next()(IndexPage)
export const query = graphql`
query($lng: String) {
locales: allLocale(filter: { lng: { eq: $lng }, ns: { eq: "messages" } }) {
...TranslationFragment
}
}
`
> yarn develop
Once the server is up and running, navigate to http://localhost:8000/de-DE and you should see some German copy!
error The path passed to gatsby-source-filesystem does not exist on your file > system:
locale
Please pick a path to an existing directory.
The above error means you haven't created the locale
folder at the root of your project. See Getting Started instructions above
error Plugin @jamfury/gatsby-plugin-i18next returned an error
SyntaxError: Unexpected end of JSON input
If you see the above error, it usually means that your locale/en-US/messages.json
file has invalid JSON. At the very least, it needs {}
FAQs
Learn more about Gatsby Themes here:\ https://www.gatsbyjs.org/blog/2018-11-11-introducing-gatsby-themes/
We found that @jamfury/gatsby-theme-i18n demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.