admin管理员组

文章数量:1289390

I am using Yoast' method to build an HTML site map. But it needs to be translated.

It uses a page template page-sitemap.php that uses a template part

<?php get_template_part('/partials/sitemap');  ?>

In this template part I...

load_textdomain( 'site-map', TEMPLATEPATH.'/partials/languages' );

The path is right for I list the files of the folder TEMPLATEPATH.'/partials/languages' and it shows my language files.

As you see my domain name is 'site-map'. My .mo file is site-map-fr_FR.mo.

Why can't it be loaded?

Thanks for any clue, nicolas

I am using Yoast' method to build an HTML site map. But it needs to be translated.

It uses a page template page-sitemap.php that uses a template part

<?php get_template_part('/partials/sitemap');  ?>

In this template part I...

load_textdomain( 'site-map', TEMPLATEPATH.'/partials/languages' );

The path is right for I list the files of the folder TEMPLATEPATH.'/partials/languages' and it shows my language files.

As you see my domain name is 'site-map'. My .mo file is site-map-fr_FR.mo.

Why can't it be loaded?

Thanks for any clue, nicolas

Share Improve this question edited Jun 29, 2021 at 7:10 xXx 2351 silver badge4 bronze badges asked Nov 28, 2013 at 12:47 NicolasNicolas 11 bronze badge 6
  • 1 Try Debug Translations. Do you get any useful output? – fuxia Commented Nov 28, 2013 at 13:11
  • load_textdomain returns boolean value. Can you check what it returns in your case? – Chittaranjan Commented Nov 28, 2013 at 17:20
  • thanks for your answers, @Chittaranjan : It return false ! (sorry i forgot to mention this important point.) – Nicolas Commented Nov 29, 2013 at 9:31
  • @Toscho : i go for the plugin, I didn't it ! :) – Nicolas Commented Nov 29, 2013 at 9:31
  • So either the mo file is not readable or the import fails. Check here codex.wordpress/Function_Reference/load_textdomain – Chittaranjan Commented Nov 29, 2013 at 10:24
 |  Show 1 more comment

1 Answer 1

Reset to default -1

I found the answer: load_textdomain( 'site-map', TEMPLATEPATH.'/partials/languages' ); ... gives the path of the folder containing the .mo file. but the path of every individual mo file should be used in its own load_textdomain instruction :

load_textdomain('site-map', TEMPLATEPATH.'/partials/languages/site-map-fr_FR.mo'); 
load_textdomain('site-map', TEMPLATEPATH.'/partials/languages/site-map-en_US.mo'); 
load_textdomain('site-map', TEMPLATEPATH.'/partials/languages/site-map-es_ES.mo'); 
load_textdomain('site-map', TEMPLATEPATH.'/partials/languages/site-map-ru_RU.mo'); 
load_textdomain('site-map', TEMPLATEPATH.'/partials/languages/site-map-de_DE.mo');

Shame on me it is a very obvious and useless thread ... Sorry!

本文标签: templatesloadtextdomain won39t load my mo file