1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-25 16:22:18 +01:00
Files
archived-doc-ru/reference/gettext/functions/gettext.xml
Sergey Panteleev daef8df962 Обнуление тега Reviewed (#364)
[skip-lint]
[skip-spellcheck]
2021-11-16 13:03:53 +03:00

121 lines
3.2 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 96c9d88bad9a7d7d44bfb7f26c226df7ee9ddf26 Maintainer: mch Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="function.gettext" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>gettext</refname>
<refpurpose>Ищет сообщение в текущем домене</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>gettext</methodname>
<methodparam><type>string</type><parameter>message</parameter></methodparam>
</methodsynopsis>
<para>
Ищет сообщение в текущем домене.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>message</parameter></term>
<listitem>
<para>
Переводимое сообщение.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Возвращает переведённую строку (<type>string</type>), если она найдена
в таблице перевода, иначе - переданное сообщение.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>gettext</function>-check</title>
<programlisting role="php">
<![CDATA[
<?php
// Устанавливаем русский язык
putenv('LC_ALL=ru_RU');
setlocale(LC_ALL, 'ru_RU');
// Указываем путь к таблицам переводов
bindtextdomain("myPHPApp", "./locale");
// Выбираем домен
textdomain("myPHPApp");
// Теперь поиск переводов будет идти в ./locale/ru_RU/LC_MESSAGES/myPHPApp.mo
// Выводим тестовое сообщение
echo gettext("Welcome to My PHP Application");
// Или с использованием псевдонима _()
echo _("Have a nice day");
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
<para>
Можно использовать символ подчёркивания '_' в качестве псевдонима этой функции.
</para>
</note>
<note>
<para>
На некоторых системах может быть недостаточно указания языка, в таких случаях
используйте <function>putenv</function> для указания текущей локали.
</para>
</note>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>setlocale</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->