![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Manage internationalization i18n in a simple way, through TypeScript, declaration file, declare your multilingual content every where in your code.
Intlayer is a suite of packages designed specifically for JavaScript developers. It is compatible with frameworks like React, Next.js, and Express.js.
The intlayer
package allows you to declare your content anywhere in your code. It converts multilingual content declarations into structured dictionaries that integrate seamlessly into your application. With TypeScript, Intlayer enhances your development by providing stronger, more efficient tools.
Install the necessary package using your preferred package manager:
npm install intlayer
pnpm add intlayer
yarn add intlayer
Intlayer provides a configuration file to set up your project. Place this file in the root of your project.
import { Locales, type IntlayerConfig } from "intlayer";
const config: IntlayerConfig = {
internationalization: {
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
defaultLocale: Locales.ENGLISH,
},
};
export default config;
For a complete list of available parameters, refer to the configuration documentation.
With Intlayer, you can declare your content in a structured way anywhere in your codebase.
By default, Intlayer scans for files with the extension .content.{ts,tsx,js,jsx,mjs,cjs}
.
can modify the default extension by setting the
contentDir
property in the configuration file.
.
├── intlayer.config.ts
└── src
├── ClientComponent
│ ├── index.content.ts
│ └── index.tsx
└── ServerComponent
├── index.content.ts
└── index.tsx
Here’s an example of content declaration:
import { type DeclarationContent, t } from "intlayer";
const clientComponentContent = {
key: "client-component",
content: {
myTranslatedContent: t({
en: "Hello World",
fr: "Bonjour le monde",
es: "Hola Mundo",
}),
numberOfCar: enu({
"<-1": "Less than minus one car",
"-1": "Minus one car",
"0": "No cars",
"1": "One car",
">5": "Some cars",
">19": "Many cars",
}),
},
} satisfies DeclarationContent;
export default clientComponentContent;
You can build your dictionaries using the intlayer-cli.
npx intlayer build
yarn intlayer build
pnpm intlayer build
This command scans all *.content.*
files, compiles them, and writes the results to the directory specified in your intlayer.config.ts
(by default, ./.intlayer
).
A typical output might look like:
.
├── .intlayer
│ ├── dictionary # Contain the dictionary of your content
│ │ ├── client-component.json
│ │ └── server-component.json
│ ├── main # Contain the entry point of your dictionary to be used in your application
│ │ ├── dictionary.cjs
│ │ └── dictionary.mjs
│ └── types # Contain the auto-generated type definitions of your dictionary
│ ├── client-component.d.ts
│ └── server-component.d.ts
└── types
└── intlayer.d.ts # Contain the auto-generated type definitions of Intlayer
Intlayer can be configured to build dictionaries for i18next. For that you need to add the following configuration to your intlayer.config.ts
file:
import { Locales, type IntlayerConfig } from "intlayer";
const config: IntlayerConfig = {
/* ... */
content: {
// Tells Intlayer to generate message files for i18next
dictionaryOutput: ["i18next"],
// The directory where Intlayer will write your message JSON files
i18nextResourcesDir: "./i18next/resources",
},
};
For a complete list of available parameters, refer to the configuration documentation.
Output:
.
└── i18next
└── resources
├── en
│ ├── client-component.json
│ └── server-component.json
├── es
│ ├── client-component.json
│ └── server-component.json
└── fr
├── client-component.json
└── server-component.json
For example, the en/client-component.json might look like:
{
"myTranslatedContent": "Hello World",
"zero_numberOfCar": "No cars",
"one_numberOfCar": "One car",
"two_numberOfCar": "Two cars",
"other_numberOfCar": "Some cars"
}
Intlayer can be configured to build dictionaries for i18next or next-intl. For that you need to add the following configuration to your intlayer.config.ts
file:
import { Locales, type IntlayerConfig } from "intlayer";
const config: IntlayerConfig = {
/* ... */
content: {
// Tells Intlayer to generate message files for i18next
dictionaryOutput: ["next-intl"],
// The directory where Intlayer will write your message JSON files
nextIntlMessagesDir: "./i18next/messages",
},
};
For a complete list of available parameters, refer to the configuration documentation.
Output:
.
└── intl
└── messages
├── en
│ ├── client-component.json
│ └── server-component.json
├── es
│ ├── client-component.json
│ └── server-component.json
└── fr
├── client-component.json
└── server-component.json
For example, the en/client-component.json might look like:
{
"myTranslatedContent": "Hello World",
"zero_numberOfCar": "No cars",
"one_numberOfCar": "One car",
"two_numberOfCar": "Two cars",
"other_numberOfCar": "Some cars"
}
Intlayer provides a CLI tool to:
Consult intlayer-cli for more information.
One your content declared, you can consume your Intlayer dictionaries in your application.
Intlayer is available as a package for your application.
To use Intlayer in your React application, you can use react-intlayer.
To use Intlayer in your Next.js application, you can use next-intlayer.
To use Intlayer in your Express application, you can use express-intlayer.
intlayer
packageThe intlayer
package also provides some functions to help you to internationalize your application.
getConfiguration()
getTranslationContent()
getEnumerationContent()
getLocaleName()
getLocaleLang()
getHTMLTextDir()
getPathWithoutLocale()
getMultilingualUrls()
getLocalizedUrl()
getPathWithoutLocale()
FAQs
Manage internationalization i18n in a simple way, through TypeScript, declaration file, declare your multilingual content every where in your code.
The npm package intlayer receives a total of 29,422 weekly downloads. As such, intlayer popularity was classified as popular.
We found that intlayer demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.