[wp-trac] [WordPress Trac] #49625: load_theme_textdomain() opens local files without domain in their name
WordPress Trac
noreply at wordpress.org
Wed Mar 11 17:42:59 UTC 2020
#49625: load_theme_textdomain() opens local files without domain in their name
--------------------------+-----------------------------
Reporter: marekdedic | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: I18N | Version: 5.3.2
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Hi,
I am developing a theme called `crdm-modern` and want to add translations
for the language `cs_CZ`. I want to load local `.mo` files as the
translations. In order to do that, I placed a file called `crdm-modern-
cs_CZ.mo` in the theme in the `languages` folder. I tried to use this by
calling `load_theme_textdomain( 'crdm-modern', get_stylesheet_directory()
. '/languages' )`. However this failed.
Looking at the source of the function `load_theme_textdomain()`
[https://developer.wordpress.org/reference/functions/load_theme_textdomain/],
I see the following line:
`return load_textdomain( $domain, $path . '/' . $locale . '.mo' );`
So this would load the file `languages/cs_CZ.mo`. I think this is a bug
and it should instead try to load the file `languages/crdm-modern-
cs_CZ.mo`. This would be in line with how the function
`load_plugin_textdomain()` works - that's wha I think it is a bug.
Looking at the code, I think the issue was introduced in
[https://core.trac.wordpress.org/changeset/37414] and could be solved by
replacing
`return load_textdomain( $domain, $path . '/' . $locale . '.mo' );`
with
`return load_textdomain( $domain, $path . '/' . $mofile );`
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49625>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list