Class used to register built-in translation warnings.

since 1.0.0
package GlotPress

 Methods

Registers all methods starting with `warning_` as built-in warnings.

add_all(\GP_Translation_Warnings $translation_warnings) 

Parameters

$translation_warnings

\GP_Translation_Warnings

Instance of GP_Translation_Warnings.

Checks whether lengths of source and translation differ too much.

warning_length(string $original, string $translation, \GP_Locale $locale) : string | true
since 1.0.0
access public

Parameters

$original

string

The source string.

$translation

string

The translation.

$locale

\GP_Locale

The locale of the translation.

Returns

stringtrueTrue if check is OK, otherwise warning message.

Checks whether PHP placeholders are missing or have been added.

warning_placeholders(string $original, string $translation, \GP_Locale $locale) : string | true
since 1.0.0
access public

Parameters

$original

string

The source string.

$translation

string

The translation.

$locale

\GP_Locale

The locale of the translation.

Returns

stringtrueTrue if check is OK, otherwise warning message.

Checks whether a translation does begin on newline.

warning_should_begin_on_newline(string $original, string $translation, \GP_Locale $locale) : string | true
since 1.0.0
access public

Parameters

$original

string

The source string.

$translation

string

The translation.

$locale

\GP_Locale

The locale of the translation.

Returns

stringtrueTrue if check is OK, otherwise warning message.

Checks whether a translation does end on newline.

warning_should_end_on_newline(string $original, string $translation, \GP_Locale $locale) : string | true
since 1.0.0
access public

Parameters

$original

string

The source string.

$translation

string

The translation.

$locale

\GP_Locale

The locale of the translation.

Returns

stringtrueTrue if check is OK, otherwise warning message.

Checks whether a translation doesn't begin on newline.

warning_should_not_begin_on_newline(string $original, string $translation, \GP_Locale $locale) : string | true
since 1.0.0
access public

Parameters

$original

string

The source string.

$translation

string

The translation.

$locale

\GP_Locale

The locale of the translation.

Returns

stringtrueTrue if check is OK, otherwise warning message.

Checks whether a translation doesn't end on newline.

warning_should_not_end_on_newline(string $original, string $translation, \GP_Locale $locale) : string | true
since 1.0.0
access public

Parameters

$original

string

The source string.

$translation

string

The translation.

$locale

\GP_Locale

The locale of the translation.

Returns

stringtrueTrue if check is OK, otherwise warning message.

Checks whether HTML tags are missing or have been added.

warning_tags(string $original, string $translation, \GP_Locale $locale) : string | true
since 1.0.0
access public

Parameters

$original

string

The source string.

$translation

string

The translation.

$locale

\GP_Locale

The locale of the translation.

Returns

stringtrueTrue if check is OK, otherwise warning message.

Counts the placeholders in a string.

_placeholders_counts(string $string, string $re) : array
since 1.0.0
access private

Parameters

$string

string

The string to search.

$re

string

Regular expressions to match placeholders.

Returns

arrayAn array with counts per placeholder.

 Properties

 

List of locales which are excluded from length checks.

$length_exclude_languages : array

Default

array('art-xemoji', 'ja', 'ko', 'zh', 'zh-hk', 'zh-cn', 'zh-sg', 'zh-tw')
since 1.0.0
access public
 

Lower bound for length checks.

$length_lower_bound : float

Default

0.2
since 1.0.0
access public
 

Upper bound for length checks.

$length_upper_bound : float

Default

5.0
since 1.0.0
access public