#35442 closed defect (bug) (duplicate)
Remove ambiguousness from return value of `is_textdomain_loaded()`
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | I18N | Keywords: | has-patch has-unit-tests |
| Focuses: | Cc: |
Description
The is_textdomain_loaded() function - as per the doc block - is supposed to answer the question whether there are any translations loaded for a textdomain.
It currently does not do so.
It only checks whether the $i10n['domain'] key isset, not whether there are any translations.
As the first time the get_translations_for_domain() function is called, it will also set the text domain, this can lead to false positives, i.e. is_textdomain_loaded() reporting true for a textdomain which hasn't been loaded.
Simple example to reproduce the issue:
<?php var_dump( is_textdomain_loaded( 'does-not-exist' ) ); echo __( 'just some string', 'does-not-exist' ); var_dump( is_textdomain_loaded( 'does-not-exist' ) );
will currently result in:
false just some string true
With the patch the result will be:
false just some string false
This patch will improve the results for patch #35439 as well.
Attachments (2)
Change History (7)
Note: See
TracTickets for help on using
tickets.
Example code as unit test for this issue