Simple i18n NextSimple i18n Next

Camel case convention

The generated constants and functions use camelCase convention. For example, if you have the following locales/en/messages.json file:

locales/en/messages.json
{
  "hello": "Hello world!",
  "greeting": "Hello {{name}}!",
  "home": "Home",
  "world-cup": "World cup"
}

the CLI will generate the following:

export type StringKeys = 'hello' | 'greeting' | 'home' | 'worldCup';

export const worldCup = (lang: SupportedLanguage) => {
  // content
};

export const hello = (lang: SupportedLanguage) => {
  // content
};

type greetingProps = {
  name: string;
};
export const greeting = (lang: SupportedLanguage, data: greetingProps) => {
  // content
};

export const home = (lang: SupportedLanguage) => {
  // content
};

Plural keys

For the plural keys, the CLI will generate functions with the format: <key>WithCount for cardinal numbers and <key>WithOrdinalCount for ordinal numbers.

For example, if you have the following locales/en/messages.json file:

{
  "apple_one": "An apple",
  "apple_other": "{{count}} apples",
  "cat_ordinal_one": "1st cat",
  "cat_ordinal_two": "2nd cat",
  "cat_ordinal_few": "3rd cat",
  "cat_ordinal_other": "{{count}}th cat"
}

Then the CLI will generate the following:

export const appleWithCount = (count: number) => {
  // content
};

export const catWithOrdinalCount = (count: number) => {
  // content
};

On this page