# 确保您的翻译升级安全

与其他所有插件一样，WooCommerce 将翻译文件保存在 `wp-content/languages/plugins` 目录中。

但是，如果您想包含自定义翻译，您可以将它们添加到 `wp-content/languages/woocommerce` 目录，或者您可以使用一段代码来加载存储在其他位置的自定义翻译：

```php
// 代码应放置在您主题的 functions.php 文件或自定义插件文件中。
add_filter( 'load_textdomain_mofile', 'load_custom_plugin_translation_file', 10, 2 );

/*
 * 将 'textdomain' 替换为您的插件的文本域名。例如，'woocommerce'。
 * 文件的命名方式，例如，yourtranslationfile-en_GB.mo
 * 文件的放置位置，例如，wp-content/lanaguages/textdomain/yourtranslationfile-en_GB.mo
 */
function load_custom_plugin_translation_file( $mofile, $domain ) {
  if ( 'textdomain' === $domain ) {
    $mofile = WP_LANG_DIR . '/textdomain/yourtranslationfile-' . get_locale() . '.mo';
  }
  return $mofile;
}
```