Skip to content

Latest commit

 

History

History
26 lines (17 loc) · 847 Bytes

i18n-text-domain.md

File metadata and controls

26 lines (17 loc) · 847 Bytes

Enforce passing valid text domains (i18n-text-domain)

Translation functions must be called with a valid string literal as the text domain.

Rule details

Examples of incorrect code for this rule:

__( 'Hello World' ); // unless allowedTextDomain contains 'default'
__( 'Hello World', 'default' ); // with allowedTextDomain = [ 'default' ]
__( 'Hello World', foo );

Examples of correct code for this rule:

__( 'Hello World' ); // with allowedTextDomain = [ 'default' ]
__( 'Hello World', 'foo-bar' ); // with allowedTextDomain = [ 'foo-bar' ]

Options

This rule accepts a single options argument:

  • Set allowedTextDomain to specify the list of allowed text domains, e.g. [ 'foo', 'bar' ]. The default is [ 'default' ].