Libraries
git8n reads i18next JSON files, in one folder for each language. This page tells, for each library, what fits that layout and what git8n check reads in its texts. Each claim was tried with git8n check.
react-i18next and next-i18next
They read i18next JSON, so everything on i18next JSON applies. The default path of i18next-http-backend and of next-i18next is public/locales/<language>/<namespace>.json, which git8n check finds with no --locales.
i18next-icu
The files are i18next JSON, and the texts are ICU MessageFormat. Both pages apply.
vue-i18n
The texts of vue-i18n fit, with limits. Run git8n check --syntax vue-i18n: with no --syntax, the linked messages and the | plurals are text, as they are for i18next.
| vue-i18n | git8n |
|---|---|
Named {name}, {user-id} | Read, as an ICU argument |
List {0} | Read, as an ICU argument |
Plural no car | one car | {count} cars | --syntax vue-i18n: the branches are counted, {count} is read |
Linked @:common.ok, @.lower:common.ok | --syntax vue-i18n: read as @:common.ok, and its key must exist |
Literal {'@'}, escaped \@ and | | Text |
- A translation keeps the links of its source. The modifier,
.lowerin@.lower:common.ok, can change: a language can need a capital where another does not. - The key of a link names a key of a file of the source language:
ok, as one object of a language holds it once you merge the files, orcommon.okfor the keyokofcommon.json. git8n reads the merge from the links: one merge must resolve them all. When some links resolve in one merge only and others in the other only, the merge of the most links wins, and the other links are errors. With as many links in each form, no merge wins, and each of them is an error. A key that no file holds is an error ofunknown-link. vue-i18n ends the key only at a space,{,(,),|or@: in@:nav.home!, the key isnav.home!. Write@:nav.home{'!'}. - A translation has as many branches as its source. A plural of 2 branches and one of 3 do not pick the same branch for 0, so another number is a warning of
plural-branches. An application that setspluralRulesfor a language can need other numbers:--max-warningslets them pass. - A
|is a branch only in a source that has branches, and only in a text with no ICU choice: a|that a translation adds to a plain text is text. {0}and the names{user-id},{total$}are read with any--syntax.
The layout is the other limit. A vue-i18n project often keeps one file for each language (locales/en.json), or its messages in JavaScript. git8n reads neither: put the messages in locales/<language>/<name>.json, and merge the files of a language when you load them.
next-intl
next-intl writes ICU MessageFormat, which git8n check reads. Its default layout, one file for each language (messages/en.json), is not read: git8n check stops with G8N1005. Put the messages in messages/<language>/<name>.json, and merge them in the request config.
FormatJS and react-intl
The texts are ICU MessageFormat. Two habits of these projects do not fit:
- one file for each language (
lang/en.json); - flat ids that hold dots, such as
"app.title". git8n reads them, but the editor writes a key as nested objects: see The keys.
The files that formatjs extract writes hold objects ({ "defaultMessage": …, "description": … }), not strings: they are not read.
Not supported
- One file for each language, whatever the library.
- Messages in JavaScript, TypeScript, YAML, gettext, XLIFF or ARB.
- A link whose key comes from a value,
@:{name}: its key is not checked.