Files
php-doc-ru/reference/intl/numberformatter/set-text-attribute.xml
Sergey Panteleev 6d43fd64d7 Исправление форматирования
[skip-spellcheck]
[skip-lint]
2022-12-27 03:42:36 +03:00

154 lines
5.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: 1976eae0d815797af97a1e16c5cd90ffc2868395 Maintainer: sergey Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="numberformatter.settextattribute" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>NumberFormatter::setTextAttribute</refname>
<refname>numfmt_set_text_attribute</refname>
<refpurpose>Устанавливает текстовый атрибут</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<para>
&style.oop;
</para>
<methodsynopsis role="NumberFormatter">
<modifier>public</modifier> <type>bool</type><methodname>NumberFormatter::setTextAttribute</methodname>
<methodparam><type>int</type><parameter>attribute</parameter></methodparam>
<methodparam><type>string</type><parameter>value</parameter></methodparam>
</methodsynopsis>
<para>
&style.procedural;
</para>
<methodsynopsis>
<type>bool</type><methodname>numfmt_set_text_attribute</methodname>
<methodparam><type>NumberFormatter</type><parameter>formatter</parameter></methodparam>
<methodparam><type>int</type><parameter>attribute</parameter></methodparam>
<methodparam><type>string</type><parameter>value</parameter></methodparam>
</methodsynopsis>
<para>
Устанавливает текстовый атрибут, связанный со средством форматирования. Примером текстового атрибута
является суффикс для положительных чисел. Если средство форматирования не понимает атрибут,
выдаётся ошибка <constant>U_UNSUPPORTED_ERROR</constant>.
Средства форматирования на основе правил понимают только <constant>NumberFormatter::DEFAULT_RULESET</constant> и
<constant>NumberFormatter::PUBLIC_RULESETS</constant>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>formatter</parameter></term>
<listitem>
<para>
Объект <classname>NumberFormatter</classname>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>attribute</parameter></term>
<listitem>
<para>
Спецификатор атрибута - одна из констант
<link linkend="intl.numberformatter-constants.unumberformattextattribute">текстового атрибута</link>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
Текст для значения атрибута.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success;
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title>Пример использования <function>numfmt_set_text_attribute</function></title>
<programlisting role="php">
<![CDATA[
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL );
echo "Префикс: ".numfmt_get_text_attribute($fmt, NumberFormatter::NEGATIVE_PREFIX)."\n";
echo numfmt_format($fmt, -1234567.891234567890000)."\n";
numfmt_set_text_attribute($fmt, NumberFormatter::NEGATIVE_PREFIX, "MINUS");
echo "Префикс: ".numfmt_get_text_attribute($fmt, NumberFormatter::NEGATIVE_PREFIX)."\n";
echo numfmt_format($fmt, -1234567.891234567890000)."\n";
?>
]]>
</programlisting>
</example>
<example>
<title>Пример использования в объектно-ориентированном стиле</title>
<programlisting role="php">
<![CDATA[
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
echo "Префикс: ".$fmt->getTextAttribute(NumberFormatter::NEGATIVE_PREFIX)."\n";
echo $fmt->format(-1234567.891234567890000)."\n";
$fmt->setTextAttribute(NumberFormatter::NEGATIVE_PREFIX, "MINUS");
echo "Префикс: ".$fmt->getTextAttribute(NumberFormatter::NEGATIVE_PREFIX)."\n";
echo $fmt->format(-1234567.891234567890000)."\n";
?>
]]>
</programlisting>
</example>
&example.outputs;
<screen>
<![CDATA[
Префикс: -
-1.234.567,891
Префикс: MINUS
MINUS1.234.567,891
]]>
</screen>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>numfmt_get_error_code</function></member>
<member><function>numfmt_get_text_attribute</function></member>
<member><function>numfmt_set_attribute</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
-->