సహాయం:చమత్కార పదాలు: కూర్పుల మధ్య తేడాలు

చి Bot: Migrating interwiki links, now provided by Wikidata on d:q4483522
చి →‎ఫార్మాటింగు: (అంగ్ల వికీనుండి విభాగం తాజా)
పంక్తి 271:
 
=== ఫార్మాటింగు ===
=== Formatting === <!--T:189-->
{| class="wikitable" border="2" cellpadding="4" cellspacing="0" width="100%"
</translate>
! పదం
 
! ఉదాహరణ
{| class="wikitable"
! వివరణ
! width="10%" | <translate><!--T:190--> Usage</translate>
! width="40%" | <translate><!--T:191--> Input → Output</translate>
! <translate><!--T:192--> Description</translate>
! width="10%" | <translate><!--T:193--> Version</translate>
|-
| <code><nowiki>{{#languageformatnum:</nowiki>''unformatted number''<nowiki>}}</nowiki></code> <br />
| <code><nowiki>{{#languageformatnum:da}}</nowiki> = ''formatnum-formatted&nbsp;number''<codenowiki>{{#language:da|R}}</nowiki></code> <br />
<code><nowiki>{{formatnum:</nowiki>''unformatted number''<nowiki>|NOSEP}}</nowiki></code>
| '''[MW1.7+]''' Native name of language code.
|
* <translate><!--T:194--> Simple:</translate>
** <code><nowiki>{{formatnum:987654321.654321}}</nowiki></code> <br/> → {{formatnum:987654321.654321}}
** <code><nowiki>{{formatnum:</nowiki>{{formatnum:987654321.654321}}<nowiki>|R}}</nowiki></code> <br/> → {{formatnum:{{formatnum:987654321.654321}}|R}}
* <translate><!--T:195--> Advanced:</translate>
** <code><nowiki>{{formatnum:{{formatnum:987654321.654321}}|R}}</nowiki></code> <br/> → {{formatnum:{{formatnum:987654321.654321}}|R}} <translate><!--T:196--> (on any locale)</translate>
** <code><nowiki>{{formatnum:00001}}</nowiki></code> <br/> → {{formatnum:00001}}
** <code><nowiki>{{formatnum:987654321.654321 |NOSEP}}</nowiki></code> <br/> → {{formatnum:987654321.654321 |NOSEP}}
** <translate><!--T:197--> Examples with [[w:Bengali numerals|{{#language:bn|en}} locale]]:</translate>
*** <code><nowiki>{{formatnum:987654321.654321}}</nowiki></code> <br/> → ৯৮,৭৬,৫৪,৩২১.৬৫৪৩২১
*** <code><nowiki>{{formatnum:987654321.654321 |NOSEP}}</nowiki></code> <br/> → ৯৮৭৬৫৪৩২১.৬৫৪৩২১
*** <code><nowiki>{{formatnum:৯৮,৭৬,৫৪,৩২১.৬৫৪৩২১ |R}}</nowiki></code> <br/> → 987654321.654321
----
<translate><!--T:198--> Unsupported:</translate> <br />
<code><nowiki>{{formatnum:{{formatnum:987.654.321}}}}</nowiki></code> <br/> → 987 654 321 <translate><!--T:199--> (e.g. with Italian locale)</translate>
----
<translate><!--T:200--> Examples of wrong input (unreliable output), with or without <code>|R</code>:</translate> <br />
<code><nowiki>{{formatnum:987,654.321|R}}</nowiki></code> <translate><!--T:201--> (the least broken)</translate> <br/>
<code><nowiki>{{formatnum:987.654,321|R}}</nowiki></code> <br/>
<code><nowiki>{{formatnum:987 654,321|R}}</nowiki></code> <br/>
<code><nowiki>{{formatnum:987&amp;nbsp;654,321|R}}</nowiki></code>
| <translate><!--T:202-->
Takes an unformatted number ([[w:Arabic numerals|Arabic]], no group separators and <code>.</code> as decimal separator) and outputs it in the localized digit script and formatted with decimal and decimal group separators, according to the wiki's default locale. <br />
The <code><nowiki>|R</nowiki></code> parameter can be used to reverse the behavior, for use in mathematical situations: it's reliable and should be used only to deformat numbers which are known to be formatted exactly as formatnum formats them with the wiki's locale.</translate><br/>
<translate><!--T:205--> The <code>NOSEP</code> ("no separators") parameter means that no group / decimal separators are changed; formatnum will only transform the digits themselves in languages which don't use the [[w:en:Hindu–Arabic numeral system|Hindu–Arabic numeral system]]. <code>NOSEP</code> can also prevent non-standard digit groupings you wouldn't expect.</translate>
 
{{warning|1=<translate><!--T:203--> Leading zeroes are not removed, you can use <nowiki>{{#expr:00001}}</nowiki> instead if you have <tvar|ext-pf>{{ll|Extension:ParserFunctions}}</> installed.</translate>}}<br />
 
{{warning|1=<translate><!--T:204--> If you don't input numbers in the exact format required, don't expect any reliable output, especially on non-English wikis.</translate>}}<br />
----
 
<translate>
<!--T:206-->
If you really need to format (according the wiki's locale) a number in unknown input format, you could try and use <code>formatnum</code> two times (but not if it can have a decimal group, or its separator will be eaten or the number won't be formatted). Be aware that this is more a hack than a regular way to proceed, thus the output may be not reliable.
</translate>
 
| {{MW version|version=1.7|compact=y|comment=and after}} <br />{{MW version|version=1.13|compact=y|comment=and after|r=32012}}
|-
|
| <nowiki>{{lc:}}</nowiki>
| <code><nowiki>{{lc#dateformat:AbC dEf}}</nowiki> = ''date''<codenowiki>{{lc:AbC dEf}}</nowiki></code><br />
<code><nowiki>{{#formatdate:</nowiki>''date''<nowiki>}}</nowiki></code><br />
| '''[MW1.5+]''' LowerCase
<code><nowiki>{{#dateformat:</nowiki>''date''{{!}}''format''<nowiki>}}</nowiki></code><br />
<code><nowiki>{{#formatdate:</nowiki>''date''{{!}}''format''<nowiki>}}</nowiki></code>
|
<code><nowiki>{{#dateformat:25 dec 2009|ymd}}</nowiki></code> <br/>
→ {{#dateformat:25 dec 2009|ymd}} <translate><!--T:207--> (your pref), 2009 Dec 25 (default)</translate> <br/>
<code><nowiki>{{#formatdate:dec 25,2009|dmy}}</nowiki></code> <br/>
→ {{#formatdate:dec 25,2009|dmy}} <translate><!--T:208--> (your pref), 25 Dec 2009 (default)</translate> <br/>
<code><nowiki>{{#dateformat:2009-12-25|mdy}}</nowiki></code> <br/>
→ {{#dateformat:2009-12-25|mdy}} <translate><!--T:209--> (your pref), December 25, 2009 (default)</translate> <br/>
<code><nowiki>{{#formatdate:2009 dec 25|ISO 8601}}</nowiki></code> <br/>
→ {{#formatdate:2009 dec 25|ISO 8601}} <translate><!--T:210--> (your pref), 2009-12-25 (default)</translate> <br/>
<code><nowiki>{{#dateformat:25 decEmber|mdy}}</nowiki></code> <br/>
→ {{#dateformat:25 decEmber|mdy}} <translate><!--T:211--> (your pref), DecEmber 25 (default)</translate> <br/>
<translate><!--T:212-->
''Note:'' In the example hereinbefore, "your pref" refers to your date preference on the current MediaWiki wiki only.
</translate>
 
| <translate><!--T:213--> Formats an unlinked date based on user "date format" preference, and adds metadata tagging it as a formatted date. For logged-out users and those who have not set a date format in their preferences, dates can be given a default: <code>mdy</code>, <code>dmy</code>, <code>ymd</code>, <code>ISO&nbsp;8601</code> (all case sensitive). If only the month and day are given, only <code>mdy</code> and <code>dmy</code> are valid. If a format is not specified or is invalid, the input format is used as a default. If the supplied date is not recognized as a valid date (specifically, if it contains any metadata such as from a nested use of these or similar templates), it is rendered unchanged, and no (additional) metadata is generated.</translate> <br/>
 
{{warning|1=<translate><!--T:214--> Although the ISO 8601 standard requires that dates be in the Gregorian calendar, the ISO parameter in this function will still format dates that fall outside the usual Gregorian range (e.g. dates prior to 1583). Also, the magic word cannot properly convert between negative years (used with ISO 8601) and years BC or years BCE (used in general writing).</translate>}}
 
| {{MW version|version=1.15|compact=y|comment=and after|r=48249}}
|-
| <code><nowiki>{{lcfirstlc:</nowiki>''string''<nowiki>}}</nowiki></code>
| <code><nowiki>{{lcfirstlc:AbDATA CdCENTER}}</nowiki> = </code>{{lcfirstlc:AbDATA CdCENTER}}</code>
| {{Anchor|lc|Lc|LC}}<translate><!--T:215--> The lowercase input.</translate>
| '''[MW1.5+]''' LC first char.
| {{MW version|version=1.5|compact=y|comment=and after}}
|-
| <code><nowiki>{{uclcfirst:</nowiki>''string''<nowiki>}}</nowiki></code>
| <code><nowiki>{{uclcfirst:aBcDATA DeFcenter}}</nowiki> = </code>{{uclcfirst:aBcDATA DeFcenter}}</code>
| {{Anchor|lcfirst|Lcfirst|LCFIRST}}<translate><!--T:216--> The input with the <u>very first</u> character lowercase.</translate>
| '''[MW1.5+]''' UpperCase
| {{MW version|version=1.5|compact=y|comment=and after}}
|-
| <code><nowiki>{{ucfirstuc:</nowiki>''string''<nowiki>}}</nowiki></code>
| <code><nowiki>{{ucfirstuc:aBtext cDtransform}}</nowiki> = </code>{{ucfirstuc:aBtext cDtransform}}</code>
| {{Anchor|uc|Uc|UC}}<translate><!--T:217--> The uppercase input.</translate>
| '''[MW1.5+]''' UC first char.
| {{MW version|version=1.5|compact=y|comment=and after}}
|-
| <code><nowiki>{{formatnumucfirst:</nowiki>''string''<nowiki>}}</nowiki></code>
| <code><nowiki>{{formatnumucfirst:-299792458.56789text tRAnSFORM}}</nowiki> = </code>{{formatnumucfirst:-299792458.56789text tRAnSFORM}}</code>
| {{Anchor|ucfirst|Ucfirst|UCFIRST}}<translate><!--T:218--> The input with the <u>very first</u> character uppercase.</translate>
| '''[MW1.7+]''' Add [[w:Decimal_separator#Thousands_separator|decimal separators]] according to the wiki's default locale. Leading minus and plus are recognized.
| {{MW version|version=1.5|compact=y|comment=and after}}
|-
| <code><nowiki>{{padleft:}}xyz|</nowiki>''stringlength''<br /nowiki>}}<br /nowiki><br /code><br /><br /><nowiki>{{padright:}}</nowiki><br />
<code><nowiki>{{padleft:xyz|</nowiki>''strlen''<nowiki>|</nowiki>''char''<nowiki>}}</nowiki></code> <br />
|
<code><nowiki>{{padleft:7xyz|3|0}}</nowiki> = ''strlen''<codenowiki>{{padleft:7|3|0}}</codenowiki>''string''<nowiki>}}<br/nowiki><br/code>
| <code><nowiki>{{padleft:0xyz|3|05}}</nowiki> = </code>{{padleft:0xyz|3|05}}</code> (bug)<br/><br />
<code><nowiki>{{padleft:bcdxyz|65|a_}}</nowiki> = </code>{{padleft:bcdxyz|65|a_}}</code> <br />
<code><nowiki>{{padleft:caféxyz|85|-abc}}</nowiki> = </code>{{padleft:caféxyz|85|-abc}}</code>(<==Bug effect)<br />
<code><nowiki>{{padleft:cafexyz|8|-2}}</nowiki> = </code>{{padleft:cafexyz|8|-2}}</code> <br />
<code><nowiki>{{padleft:|1|xyz}}</nowiki></code> → {{padleft:|1|xyz}}
<translate><!--T:219--> (first character of the string)</translate> <br />
| <translate><!--T:220-->
Inserts a string of padding characters (character chosen in third parameter; default "0") of a specified length (second parameter) next to a chosen base character or variable (first parameter). The final digits or characters in the base replace the final characters in the padding; i.e. <code><nowiki>{{padleft:44|3|0}}</nowiki></code> produces {{padleft:44|3}}. The padding string may be truncated if its length does not evenly divide the required number of characters.
 
<!--T:221-->
<nowiki>{{padleft:bcd|6|{{!}}}}</nowiki> = <code>{{padleft:bcd|6|{{!}}}}</code><br/>
Only the first character of the third parameter is used in versions up to 1.12, but by version 1.15, all the characters are used.
<br/>
<nowiki>{{padright:bcd|6|a}}</nowiki> = <code>{{padright:bcd|6|a}}</code><br />
<nowiki>{{padright:0|6|a}}</nowiki> = <code>{{padright:0|6|a}}</code> (bug)<br />
 
<!--T:222-->
|valign="top"|<br />First case is, for example, applicable to years in a category... giving an ordered year to sort by pipetricks order, or any such ordering where left extended zeros allow a proper sorting.<br /><br /> '''[MW1.8+]''' Pads a string with a character to the specified width. Note that there's a little bug that interprets non-[[w:US-ASCII|US-ASCII]] characters as two, instead of one character (see the difference in''' ''café'' and ''cafe'' '''in the examples.)
'''[[<tvar|1>bugzilla:16852</>|Bug]] (fixed in <tvar|2>[[rev:45734|r45734]]</>):''' multibyte characters are interpreted as two characters, which can skew width. These also cannot be used as padding characters.</translate>
 
| {{MW version|version=1.8|compact=y|comment=and after}}
It does not seem possible to use padleft and padright for padding with characters with a multi-character code, such as <code>&amp;nbsp;</code>, which would be useful with padleft for [[Help:Sorting|sorting tables]] with Javascript.
|-
 
| <code><nowiki>{{padright:xyz|</nowiki>''stringlength''<nowiki>}}</nowiki></code> <br /><code><nowiki>{{padright:xyz|</nowiki>''strlen''<nowiki>|</nowiki>''char''<nowiki>}}</nowiki></code> <br /><code><nowiki>{{padright:xyz|</nowiki>''strlen''<nowiki>|</nowiki>''string''<nowiki>}}</nowiki></code>
Padding "0" does not work, it returns the same. This seems to be a bug.<ref>Function pad in includes/CoreParserFunctions.php puts, oddly, the $string itself as a condition for the padding. To be reported as bug.</ref>
| <code><nowiki>{{padright:xyz|5}}</nowiki></code> → {{padright:xyz|5}} <br />
|}{{-}}
<code><nowiki>{{padright:xyz|5|_}}</nowiki></code> → {{padright:xyz|5|_}} <br />
<code><nowiki>{{padright:xyz|5|abc}}</nowiki></code> → {{padright:xyz|5|abc}} <br />
<code><nowiki>{{padright:xyz|2}}</nowiki></code> → {{padright:xyz|2}} <br />
<code><nowiki>{{padright:|1|xyz}}</nowiki></code> → {{padright:|1|xyz}} <br />
| <translate><!--T:223--> Identical to <code>padleft</code> but adds padding characters to the right side.</translate>
| {{MW version|version=1.8|compact=y|comment=and after}}
|}
<translate><!--T:224-->
'''See also:''' <tvar|ext-stringfunctions>{{ll|Extension:StringFunctions}}</>.
</translate>
 
{{anchor|Localization|Localisation}}
With regard to #language and {{tim|n local}}, see also:
<translate>
*[[List of Wikipedias/local names]] - shows both names for all languages, without automatic comparison
*[[List of Wikipedias/local names/diff]] - values of [[Help:Magic words#Formatting|#language]] for which <nowiki>{{n local}}</nowiki> contains a different name.
*[[List of Wikipedias/local names/diff 1]] - for languages where the two names are different, shows both; due to the {{peisl}} the end of the table is messed up
 
==మూస మార్పిడులు ==