| Меню для TalkBack | Перевод документации |
|---|---|
| Скачать Языковой Файл RU |
|
Заданный по умолчанию пакет языка
Содержание файла Языка
Changing text in entries
Take care when editing the language file
Changing text in a custom template
Changing text in a default template
Finding the language file entry or place in the HTML to change the text
Перевод файла языка
Using multiple language packages
Adding entries to the language file
TalkBack идет с Английским пакетом языка. Пакет языка состоит из первичного файла языка, файла языка отмены и значка языка (флажок GIF). Дополнительные пакеты языка на download page.
Первичный файл языкаlanguage/english.php.
Файл языка отмены my-english.php. Позволяет настраивать индивидуальные входы языка без опасения изменений, при апгрейде на новую версию скрипта.
Файл содержит текст для всех меток, сообщений и панелей справки. Это большой файл с более чем 800 входами (70КБ) от версии 2.2. Каждый вход в файле - элемент языка, и отформатирован подобно этому:
$lang['comdisplay2'] = "There is 1 comment";
['comdisplay2'] - индивидуальное имя входа. Текст входа содержится между двойными кавычками. Некоторые из входов содержат html-тэги и/или PHP переменные:
$lang['db_error'] = "<p class='tb-center tb-stress'>Comments for this page are temporarily unavailable</p>";
$lang['comdisplay1'] = "Showing $first_row-$last_row of $total_rows Comments";
The variables ($first_row, $last_row and $total_rows in the above example) are place holders and will be replaced with actual values when the page using that entry is sent to the visitor’s browser giving, for example, the message: “Showing 1-15 of 36 comments”
Note that the file does not affect the language in which dates are displayed. See Dates – language. The last line of the file must be: require 'my-english.php';. That gets your override language file and replaces entries in the primary file with entries from your override language file.
Take care when editing the language file:
The last statement in a language file must be an include of your my language file.
If you translate english.php to another language be sure require 'my-xxxxx.php'; as the last statement in that file, where xxxxx is the name of your language file.
Some entries include PHP variables and/or HTML tags. You can shift
the position of the variables and tags but don't ortherwise alter them. Variable
names look like $variable_name and {$config['variable_name']}
If you want to use quotes or other special characters in the text, use HTML special character
codes. For example: "quoted text" produces “quoted text”. Find the list of codes at Web Monkey
If you must use a " character within the text (e.g. in HTML attributes), precede it with a backslash: <p class=\"class-name\"></p>
Changing text in a custom template:
If you are creating a custom template the easiest way to change text is to replace the $lang variable with the actual text you want to appear on the page.
For example to change the comments display template “Leave a comment label” to “Enter a comment”, change:
<p id='tb-comment-link'><a href='#entry'>{$lang['comdisplay6']}</a></p>
to:
<p id='tb-comment-link'><a href='#entry'>Enter a comment</a></p>
With a custom template you don’t have to worry about your changes being overwritten if you upgrade to a new TalkBack version in the future.
Changing text in a default template:
To protect yourself against having your changes overwritten by future releases of TalkBack, copy the english.php entry you want to change to my-english.php and change it there.
Finding the language file entry or place in the HTML to change the text:
Open the page you want to change in your browser. Copy the text from the screen to the clipboard. Example: “Your email address (will not be published)” on the comments form.
Open english.php in your text editor. Invoke the search command and paste the text into the search dialog. That would take you, in this case, to the entry for $lang['comform4']. That is the entry you want to copy and change.
$lang['moderation_return_link'] = "Return";
$lang['return_link_text'] = "Return";
So be careful with very short or generic text labels. Do a second search to be sure there is only one. If there are two, change one and see if you got the correct one. If not, undo that and change the other one.
/language directory:
DEFAULT_LANGUAGE entry.![]()
You do not have to translate all entries in the primary language file. The file is large and translating all entries would be a daunting task. At the beginning of the file, following the comments, is a table of contents. It identifies which sections contain entries that are seen by visitors to your site and which are seen only by the administrator. You may choose to translate only those sections that contain messages seen by visitors.
Make a new primary language file. Create a new text file named for the language (example: german.php). Copy the entire english.php file to it and then translate the english text in it. The last line of the file must be the include statement for the override language file, example: require 'my-german.php';.
my-english.php and rename it, for example, my-german.php. Note that the override filename must start with “my-” and the language name must be the same as the primary language file./talkback/addons/flags to /talkback/language and rename it. For example, to create a Spanish language icon you could copy one of spain.gif, mexico.gif, etc. and rename it spanish.gif.You can add your own entries to the language file. You might do this, for example, if you are using multiple language files and want to create a customized comments template. In such a case you have multiple languages but can only put text directly into the template for one language. An example that comes to mind is a greeting in a guestbook.
It is always nice to hear from people that have visited so leave a comment, ask a question or just say hi.
Normally you would place such text in your html file above the TalkBack include. Example:
<p>It is always nice to hear from people that have visited so leave a comment, ask a question or just say hi.</p> <?php require 'talkback/comments.php'; ?>
That works fine for users that have a single language site. But if your site is multi-language, the greeting is not translated because it is (1) not in the language file and (2) not inside the comments template. Read on to learn how you can rectify that.
First, add your greeting to each override language file (e.g. my-english.php and my-dutch.php). Create an entry using an entry name that won’t conflict with any other language file names. I suggest using the prefix “my_” (you can use underscores but not dashes in entry names).
$lang['my_greeting'] = "It is always nice to hear from people that have visited so leave a comment, ask a question or just say hi."
Then create a custom template by copying and renaming comments-display-tpl.php (e.g. my-comments-display-tpl.php). This prevents your changes from being overwritten if you upgrade to a new version of TalkBack. Add a new paragraph at the beginning of the template. Below is the beginning of the template, before you change it:
// +++++++++++++++++++++++++++++++++++++++++++++++
// Print the "Leave a comment" link
// +++++++++++++++++++++++++++++++++++++++++++++++
print "
<div id='tb-wrapper'>
<p id='tb-comment-link'><a href='#tb-form-div'>{$lang['comdisplay6']}</a></p>";
And here is the template after you insert your greeting paragraph:
// +++++++++++++++++++++++++++++++++++++++++++++++
// Print the "Leave a comment" link
// +++++++++++++++++++++++++++++++++++++++++++++++
print "
<div id='tb-wrapper'>
<p>{$lang['my_greeting']}</p>
<p id='tb-comment-link'><a href='#tb-form-div'>{$lang['comdisplay6']}</a></p>";
{$lang['my_greeting']} tells PHP to insert that entry from the language file into the output HTML. Note the beginning and ending braces. They are necessary, you will get a PHP error if you omit them. Where you place it in the template is up to you. You could also place it above the tb-wrapper div.
Finally, instruct TalkBack to use the new template instead of the default template. Edit the filename for “Comments display template” via admin configuration maintenance.
Действительно интересно, хотя не мешало бы чуть более развернуто написать, а то есть несколько непонятных моментов :)
Можно и подискутировать по этому поводу ... :)
Тут уже столько накомментировали до меня. Мне осталось только присоединиться.
Ну, как сказать, понравилось конечно:) Хотя я все равно практически ничего не понял. :)