个人工具
名字空间
变换
操作

WordPress:Files For Direct Translation

来自站长百科
跳转到: 导航, 搜索

目录

Introduction

介绍

Although WordPress displays in U.S. English by default, the software has the built-in capability to be used in any language, or 'localized' (see WordPress:WordPress in Your Language for more information). The main capability for localization in WordPress uses the Gnu gettext system (see WordPress:Translating WordPress for more information). In the gettext system, text messages produced by WordPress's PHP files are run through a look-up function, which finds and uses the non-English equivalent of the default English word or phrase in a file. This works well for most of WordPress; however, there are a few components of WordPress that do not lend themselves to localization with gettext. This article explains why that is the case, and also shows how to localize those components of WordPress.

虽然WordPress默认情况下,显示为美式英语,WordPress本质上能在任何语言中使用,或者'本地化'(更多的信息,请看看英语外其它语言的WordPress)。WordPress主要使用Gnu gettext系统实现本地化(更多的信息,请看看翻译WordPress)。在gettext系统中,WordPress PHP文件产生的文本信息在look-up函数中运行,这个函数使用文件中默认英语单词和词组的非英语对等翻译。对于WordPress的大部分内容,gettext能够很好的操作翻译内容,但是WordPress中的少数内容不能够使用gettext翻译。这篇文章解释了这些内容为什么不能够使用gettext翻译以及怎样将WordPress的这些部分本地化。

Where gettext Doesn't Work

gettext不能够操作的内容

There are several components of WordPress that cannot or should not be translated or localized with gettext:

WordPress中有几个部分,不能够由gettext翻译或者本地化:

  • The main WordPress README file -- it's a static HTML file, not a PHP file, so it cannot be run through the gettext functions.
  • WordPress主要的自述文件—这是个静态的HTML文件,而不是个PHP文件,因此不能够在gettext函数中运行。
  • A few error messages are generated very early in the WordPress loading cycle, before gettext is loaded.
  • 在WordPress载入时,gettext还没有载入的时候,产生了一些错误信息。
  • WordPress includes some JavaScript functionality, which runs on the users' browser (unlike PHP, which runs on the web server), and therefore does not have gettext available.
  • WordPress包含了一些JavaScript函数,这些函数在用户的浏览器上运行(与PHP不同,PHP在网络服务器上运行),因此没有gettext。

Internationalizing Non-gettext Components

将非gettext的组成部分国际化

In order to internationalize or localize components of WordPress that cannot use gettext, you will need to replace the English version of the files with a modified version, where the English text has been replaced by text in your language. A list of the files you will need to translate is below.

为了将WordPress中不能够使用gettext的部分国际化或者本地化,你需要使用已更改的版本替换英语版本,在以更改的版本,英语文本已经替换为你的母语文本。你需要翻译的文件如下:

One note: if you are planning to release your localized files for use by others, be careful about WordPress versions! You will need to keep track of which version of WordPress they correspond to, or release different versions of the files for different versions of WordPress. You can find different versions of WordPress in the Release Archive, or if you want to get down to even more detail, the Trac Browser (a browser for the SVN source-code repository for WordPress).

注意:如果你计划发行你的本地化文件供他人使用,注意是哪个版本的WordPress!你需要了解你翻译的WordPress对应的是哪个版本的WordPress,或者为不同版本的WordPress发行不同版本的文件。你可以在版本归档中找到不同版本的WordPress,如果你希望了解更加详细的信息,Trac 浏览器(WordPress SVN源代码库浏览器)。

List of Files to Translate

需要翻译的文件列表

Core files (up to WP 2.5)

核心文件 (直到WP 2.5)

  • readme.html - it's a static HTML file, not a PHP file, so it cannot be run through the gettext functions. The whole file needs to be translated.
  • readme.html -这是个静态的HTML文件,而不是PHP文件,因此不能够在gettext函数中运行。整个文件都需要翻译。
  • wp-blog-header.php - only the error for non-existent wp-config.php needs to be translated.
  • wp-blog-header.php -只有不存在的wp-config.php的错误,需要翻译。
  • wp-settings.php - some die commands could happen before the gettext engine is loaded, so they need to be translated.
  • wp-settings.php - 载入gettext引擎之前,会出现一些命令,因此这些命令需要翻译。
  • wp-config-sample.php - see below.
  • wp-config-sample.php -请看看下面的。
  • wp-admin/install.php - only the error for non-existent wp-config.php needs to be translated.
  • wp-admin/install.php -只有不存在的wp-config.php的错误需要翻译。
  • wp-admin/setup-config.php - this is a script for automatic generation of wp-config.php, and as it runs independent of WordPress, there is no gettext. The whole file needs to be translated.
  • wp-admin/upgrade.php - only the warning message at the top of the file needs to be translated.
  • wp-admin/setup-config.php -这是自动产生wp-config.php的脚本,而且这个脚本独立于WordPress之外运行,没有gettext。整个文件都需要翻译。
  • wp-admin/upgrade.php -只有文件顶上方出现的警示信息需要翻译。
  • wp-includes/functions.php - there's a database error message at the end of the file that needs to be translated.


  • wp-includes/functions.php -文件的结尾部分出现有数据库错误信息,这个信息需要翻译。
  • wp-includes/wp-db.php - database error messages need to be translated, because database loading happens early in WordPress loading.
  • wp-includes/wp-db.php -需要翻译数据库错误信息,因为数据库载入发生在载入WordPress的早期。

Core files (WP 2.6)

核心文件 (WP 2.6)

  • readme.html - it's a static HTML file, not a PHP file, so it cannot be run through the gettext functions. The whole file needs to be translated.
  • readme.html -是个静态的HTML文件,而不是PHP文件,因此不能够在gettext函数上运行。整个文件需要翻译。
  • wp-config-sample.php - see below.
  • wp-config-sample.php -请看看下面的。
  • wp-admin/setup-config.php - this is a script for automatic generation of wp-config.php, and as it runs independent of WordPress, there is no gettext. The whole file needs to be translated.
  • wp-admin/setup-config.php -这是自动创建wp-config.php的脚本,因为独立与WordPress之外运行,没有gettext。整个文件都需要翻译。

wp-config-sample.php

wp-config-sample.php

Translate the instructions in the PHP comments (so that someone who doesn't speak English can figure out how to configure WordPress), and set the WPLANG variable to the correct locale. For example change:
define ('WPLANG', '');
to
define ('WPLANG', 'bg_BG');
if you are using the bg_BG locale

翻译PHP命令中的指示(这样不说英语的人,能够了解怎样配置WordPress),将WPLANG变数设置为正确的locale。例如更改:
define ('WPLANG', '');
to
定义 ('WPLANG', 'bg_BG');
如果你正使用 bg_BG locale。

Replace 'put your unique phrase here' with a similar phrase in your language. Then, in wp-content/languages/<your-locale>.php put:

将'在这里放上你的唯一的词组'更改为你的母语中对应的词组。然后,在wp-content/languages/<your-locale>.php中放入:

$wp_default_secret_key = '<the-translated-phrase>';

$wp_default_secret_key = '<the-translated-phrase>';

For example, here is what the Bulgarian files look like:

例如,这里是保加利亚语文件的样式:

dist/wp-config-sample.php:

[...]
define('AUTH_KEY', 'вашата супер-ултра-уникална фраза сложете тук');
define('SECURE_AUTH_KEY', 'вашата супер-ултра-уникална фраза сложете тук');
define('LOGGED_IN_KEY', 'вашата супер-ултра-уникална фраза сложете тук');
[...]

dist/wp-content/languages/bg_BG.php:

<?php
$wp_default_secret_key = 'вашата супер-ултра-уникална фраза сложете тук';
?>


dist/wp-config-sample.php:

[...]
define('AUTH_KEY', 'вашата супер-ултра-уникална фраза сложете тук');
define('SECURE_AUTH_KEY', 'вашата супер-ултра-уникална фраза сложете тук');
define('LOGGED_IN_KEY', 'вашата супер-ултра-уникална фраза сложете тук');
[...]

dist/wp-content/languages/bg_BG.php:

<?php
$wp_default_secret_key = 'вашата супер-ултра-уникална фраза сложете тук';
?>


TinyMCE files (up to WP 2.3 only)

TinyMCE 文件(只直到WP 2.3)

Note: From WordPress 2.5 on there is no more need for direct translation of TinyMCE files, since their strings are contained within the main WordPress POT file.

注:从WordPress2.5开始,更需要直接翻译TinyMCE文件,因为这些字符串包含在WordPress主要的POT文件中。


TinyMCE is the HTML editor included in WordPress. It is written in JavaScript, and therefore uses a different system for localization. To localize TinyMCE, you will need to do the following:

TinyMCE是WordPress中包含的HTML编辑器,使用JavaScript编写的,因此为本地化使用不同的系统。要本地化TinyMCE,你需要执行以下的操作:

  • wp-includes/js/tinymce/langs/ - create and add a file named ll_cc.js, where ll is the lower-case language code for your locale, and cc is the lower-case country code. For example, the bg_BG locale files should be named bg_bg.js. This file should contain the translations of strings in en.js (text for buttons and descriptions).


  • wp-includes/js/tinymce/langs/ -创建并且添加名称为ll_cc.js的文件,ll 是你的locale的小写字母语言代码,cc是小写字母国家代码。例如,bg_BG本地化文件应该命名为bg_bg.js。这个文件应该在en.js中包含了字符串的翻译(按钮和描述的文本)。
  • Several sub-directories of TinyMCE also have language directories, where you will need to do the same type of translation of their text:
  • TinyMCE的几个子目录也有语言目录,你需要同样地翻译这些文本:
    • wp-includes/js/tinymce/plugins/wphelp/langs/
    • wp-includes/js/tinymce/plugins/directionality/langs/
    • wp-includes/js/tinymce/plugins/spellchecker/langs/
    • wp-includes/js/tinymce/plugins/autosave/langs/
    • wp-includes/js/tinymce/plugins/wordpress/langs/
    • wp-includes/js/tinymce/plugins/paste/langs/
    • wp-includes/js/tinymce/langs/
    • wp-includes/js/tinymce/themes/advanced/langs/



    • wp-includes/js/tinymce/plugins/wphelp/langs/
    • wp-includes/js/tinymce/plugins/directionality/langs/
    • wp-includes/js/tinymce/plugins/spellchecker/langs/
    • wp-includes/js/tinymce/plugins/autosave/langs/
    • wp-includes/js/tinymce/plugins/wordpress/langs/
    • wp-includes/js/tinymce/plugins/paste/langs/
    • wp-includes/js/tinymce/langs/
    • wp-includes/js/tinymce/themes/advanced/langs/
    • Possibly others, if you have different TinyMCE plugins or themes -- search your TinyMCE directory structure for other langs directories.
    • 也许还有其它的,如果你有不同的TinyMCE插件或者主题—为其它的langs目录,搜索你的TinyMCE目录结构。

Default theme

默认主题

The Default WordPress theme is entirely in English. All of its files (contained in wp-content/theme/default) need to be translated. You may also want to provide other themes for your locale.

默认WordPress主题完全是用英语写的。所有这些文件(包含在wp-content/theme/default中)需要翻译。你可能也想为你的locale提供其它的主题。

Besides the English-only version of the default theme, a gettext one also exists. It can be found in the theme folder of the wordpress-i18n svn repository.

除了英语版本的默认主题之外,还有个gettext版本的。可以在wordpress-i18n svn 库主题文件夹中找到。

Do not translate

不要翻译

  • license.txt - Should be kept in place for legal reasons. A translated version can be added to the archive.
  • license.txt -因为合法性需要存在在WordPress中。可以将翻译的版本添加到归档上。

留言