메인 컨텐츠로 이동
버전: 3.5.2

string-literal-i18n-messages

일반 텍스트 라벨에 대해 번역 API를 강제로 호출합니다.

Docusaurus offers the docusaurus write-translations API, which statically extracts the text labels marked as translatable. Dynamic values used in <Translate> or translate() calls will fail to be extracted. 이 규칙은 모든 번역 호출이 정적으로 추출할 수 있을 때 사용할 수 있습니다.

Rule Details

Examples of incorrect code for this rule:

const text = 'Some text to be translated'

// Invalid <Translate> child
<Translate>{text}</Translate>

// Invalid message attribute
translate({message: text})

Examples of correct code for this rule:

// Valid <Translate> child
<Translate>Some text to be translated</Translate>

// Valid message attribute
translate({message: 'Some text to be translated'})

// Valid <Translate> child using values object as prop
<Translate values={{firstName: 'Sébastien'}}>
{'Welcome, {firstName}! How are you?'}
</Translate>

// Valid message attribute using values object as second argument
translate({message: 'The logo of site {siteName}'}, {siteName: 'Docusaurus'})

When Not To Use It

If you're not using the i18n feature, you can disable this rule.

Further Reading