Wordpress插件翻译的问题,使用翻译.PO和.MO文件不起作用



我需要制作一个多语言的Wordpress插件,我已经研究过,显然最好的方法是使用。PO和。MO文件,但我已经做了配置,也没有加载翻译。插件最初是"en_US",如果我将Wordpress语言更改为西班牙语,我想将其更改为"es_es">

这是我的代码

DiBi-Bot/es-es.po

msgid"msgstr""项目Id版本:DiBi Bot\n"POT创建日期:2018-08-03 15:59-0400\n"PO修订日期:2018-08-03 15:59-0400\n"上一个转换器:\n"语言团队:dibibot.com\n"语言:es\n"MIME版本:1.0\n"内容类型:text/plain;字符集=UTF-8 \n"内容传输编码:8位\n"X-Generator:Poedit 2.1.1\n"X-Poedit-Basepath:..\n"复数形式:nplurals=2;复数=(n!=1(;\n"X-Poedit-KeywordsList:__;_e;_n\n"X-Poedit-SearchPath-0:。\n"#:dibi-bot.php:56msgid"DibiBot用户"msgstr"Usuario de DibiBot"#:dibi-bot.php:57msgid"DibiBot操作员"msgstr"Operador de DibiBot">

DiBi-Bot/DiBi-Bot.php


<?php
/**
*
* @link              https://localhost/
* @since             1.0.0
* @package           DiBi-Bot
*
* @wordpress-plugin
* Plugin Name:       DiBi-Bot
* Plugin URI:        http://localhost
* Description:       Chatbot de soporte a Clientes
* Version:           1.0.0
* Author:            Anthony Medina
* Author URI:        https://localhost/
* License:           Copyright 2019
* License URI:       
* Text Domain:       dibibot-plugin
* Domain Path:       /languages/
*/
if ( ! defined( 'ABSPATH' ) ) exit;
define('DIBIBOT_PLUGIN_PATH' , plugin_dir_path(__FILE__)                           );
add_action( 'plugins_loaded', 'dibibot_load_textdomain');
function dibibot_load_textdomain() {
load_plugin_textdomain( 'DiBi-Bot', DIBIBOT_PLUGIN_PATH . 'languages/' );
}
// I want to add these wordpress roles in English or Spanish depending on the wordpress language
function dibibot_add_roles() {
$subscriber = get_role('subscriber');
add_role( 'dibibot_user', __('DibiBot User', 'DiBi-Bot'), $subscriber->capabilities );
add_role( 'dibibot_operator', __('DibiBot Operator', 'DiBi-Bot'), $subscriber->capabilities );
}
// Activation and deactivaticion
register_activation_hook( __FILE__, 'dibibot_add_roles' );
?>

代码被简化了,我的意思是,我删除了一些部分让你理解,但基本上,我在"diibot_add_roles"函数中使用翻译的行与我在中使用的行相对应。PO文件

请确保您的文件是wp-content/languages/plugins/您的文件,并检查您的文件名以文本域开头。

最新更新