Jump to content

Template talk:US$

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
(Redirected from Template talk:US$/testcases)

Generalize?

[edit]

Can a more general version be produced to handle any ISO currency code? There's a discussion started at Wikipedia_talk:Manual_of_Style_(dates_and_numbers)/Archive_99#Currencies_query. I'm thinking something that would take {{Price|USD|100.00|CAD|2006}} and render it as "US$100.00 (CAD$130.34 in 2006)" or whatever the FOREX histories show.LeadSongDog (talk) 18:23, 18 April 2008 (UTC)[reply]

Template does not agree with MOS

[edit]

The recommendations by the Manual of Style differ from this template. Can you please look into this and fix either one or the other: Wikipedia:Manual_of_Style_(dates_and_numbers)#Currency

Samsara (talkcontribs) 15:16, 19 May 2006 (UTC)[reply]

I have changed the template to be in accordance with the Manual of Style. I think this template maybe should be deleted. It requires more typing than not using the template and it is highly doubtful that the standard will be changed from the English standard usage there now. - Centrx 19:33, 19 May 2006 (UTC)[reply]
Actually, to link the US$, it requires less typing. - Centrx 19:36, 19 May 2006 (UTC)[reply]
Before it can be deleted, the pages that use it have to be changed. There are only about 20 of them. Can you do this? - Samsara (talkcontribs) 18:13, 24 May 2006 (UTC)[reply]

I am content, possibly, to let that template remain, because it is somewhat useful, in that {{USD|100}} is shorter to type than [[United States dollar|US$]]100, though maybe this just clutters the namespace for something that won't be used much or might be vandalized? Still, any article that uses it should use the "subst" part so that the text of the template is put right in the article, rather than referenced, which referencing apparently taxes the server. I am going to do that now. - Centrx 03:58, 26 May 2006 (UTC)[reply]

Template:documentation

[edit]

{{editprotected}}

Template:US$/doc is done. See Template:Documentation/doc.

Replace current noinclude section with:

<noinclude>

{{documentation}}<!--

Add categories and interwikis to the /doc subpage, not here!

--></noinclude>

—Preceding unsigned comment added by William Allen Simpson (talkcontribs) 16:25, 19 April 2009 (UTC)[reply]

Done, thanks. Amalthea 17:09, 19 April 2009 (UTC)[reply]

Minor edits

[edit]

{{editprotected}} Requesting sync with the new sandbox for a minor tweak to allow for the parameter to be omitted. Chris Cunningham (not at work) - talk 09:58, 21 August 2009 (UTC)[reply]

 Done — Martin (MSGJ · talk) 10:49, 21 August 2009 (UTC)[reply]

Purpose and use

[edit]

I would like to put forward two questions:

  1. Is this template necessary or useful?
  2. If yes, then should it be transcluded or substituted?

On the question of substitution, I note that substituting {{US$|100}} would add only a small amount of code to an article: [[United States dollar|US$]]100.

On the question of utility, it seems to me that it would be just as easy to type [[US$]]100 instead of {{US$|100}}. The only difference is that US$ is a redirect, whereas this template contains a piped link to United States dollar. It seems to me that the template is useful only if it is substituted, since {{US$|100}} requires fewer keystrokes than [[United States dollar|US$]]100—17 versus 31. Whether that usefulness is enough to justify keeping the template is another question...

I noticed that these questions were discussed in the section #Template does not agree with MOS and that the original documentation for the template required substitution, but that requirement was removed in this edit. If there is a reason to keep the template, then I propose that we alter the documentation to indicate that it should be substituted; and if there is conensus for that, then I can substitute the ~250 current transclusions using AWB. –Black Falcon (talk) 19:00, 25 January 2010 (UTC)[reply]

I like this template because:
  1. editors don't have to remember what the MOS says (US$, USD, usd, us$, US $, etc),
  2. we don't have to update every page when the MOS changes (rare),
  3. it opens up the possibility to display the US amount and a conversion to a registered reader's home currency - eg US$100 (AU$150),
  4. it opens up the possibility to link to a page that queries for a non US currency and do a conversion (similar to what ISBN 1-4133-0454-0 does for books).
Items 2-4 would require transclusion instead of substitution.  Stepho  (talk) 09:14, 5 February 2010 (UTC)[reply]
I have reservations about the idea of displaying currency conversions within articles, mostly because it is immensely difficult under such an approach to account for inflation and changes in exchange rates over time. A conversion of US$100 (2005) to at the 2005 exchange rate could be useful (although, exchange rates fluctuate even during the course of a single year), but a conversion of US$100 (2005) to at the current exchange rate would be misleading.
Still, the possibility of adding functionality, which I admit I had not considered, is enough to substantially weaken my belief in my original position (that the template is "useful only if it is substituted"), and I thank you for your thoughtful reply. –Black Falcon (talk) 20:30, 9 February 2010 (UTC)[reply]

Year parameter

[edit]

{{editprotected}} Could we get a year or date paramater? The dollar has incurred notable inflation over time. $10 in 1990 would get you $16.21 worth today, and $10 today would be worth $5.83 in 1990. See inflation calculator.Smallman12q (talk) 22:44, 14 April 2010 (UTC)[reply]

I've written the code for this to work using the Bureau of Labor Statistics' inflation calculator. See below (a subpage will need to be created at Template:US$/Inflation).. --Yarnalgo talk to me 07:02, 12 May 2010 (UTC)[reply]

Code removed to improve readability. — Martin (MSGJ · talk)

Examples:

{{USD|100|2009}} US$100 (equivalent to $142.02 in 2023)
{{USD|100|1950}} US$100 (equivalent to $1,266 in 2023)
{{USD|100|2000}} US$100 (equivalent to $176.93 in 2023)
{{USD|100}} US$100

If I understand the code correctly, we could use something like 'In 1950 it cost {{USD|100|1950}}' to show 'In 1950 it cost US$100 (about $903 in 2010)'. As long as the year parameter is optional (it appears to be), then it sounds fine to me.  Stepho  (talk) 14:24, 12 May 2010 (UTC)[reply]

Is this code ready to go? Has it been tested? I notice that a "required subtemplate" is still a redlink ... Some clarification please. — Martin (MSGJ · talk) 21:10, 12 May 2010 (UTC)[reply]
Its been tested in my sandbox (examples here). It's fully ready to go... I'll create the subpage right now. --Yarnalgo talk to me 22:36, 12 May 2010 (UTC)[reply]
Could you stick it in Template:US$/sandbox, removing all the links to your userspace? — Martin (MSGJ · talk) 11:07, 13 May 2010 (UTC)[reply]
I put it there with the testcases at Template:US$/testcases. --Yarnalgo talk to me 23:10, 13 May 2010 (UTC)[reply]
Looks good! plus Added — Martin (MSGJ · talk) 20:54, 16 May 2010 (UTC)[reply]

Just one problem - the template does not fail gracefully when present or future years are entered. Could you do something about that? — Martin (MSGJ · talk) 20:56, 16 May 2010 (UTC)[reply]

I updated the sandbox to simply not display the parenthetical if the year is outside the 1913–2009 range (see the testcases). I could also make it display a simple error message (something like Please specify a year from 1913–2009). --Yarnalgo talk to me 21:49, 16 May 2010 (UTC)[reply]
I think this template should use the calculation (or at least the data) from {{Inflation}}, so that it doesn't have to be maintained in both places. Amalthea 22:07, 16 May 2010 (UTC)[reply]
Wow... I wish I'd seen that template earlier haha. I did a quick update so this template is now using that template's data but I'll update the sandbox so that it will just use that template completely. --Yarnalgo talk to me 00:08, 17 May 2010 (UTC)[reply]

{{edit protected}}

Okay, I changed it to use the {{Inflation}} template and am requesting a sync with the sandbox. --Yarnalgo talk to me 03:53, 17 May 2010 (UTC)[reply]
 Done Tim Song (talk) 05:08, 17 May 2010 (UTC)[reply]

Improved rounding for inflation

[edit]

{{editprotected}} Requesting a sync with the sandbox. I've improved the rounding for inflation: It will automatically round to the nearest dollar (instead of cent) if it is over $1000. Also, a new round parameter can be used to control the rounding to any amount. (see testcases for examples). --Yarnalgo talk to me 23:20, 27 May 2010 (UTC)[reply]

 Done  Ronhjones  (Talk) 23:41, 28 May 2010 (UTC)[reply]

nbsp

[edit]

According to WP:NBSP, "US$5.3 million" should be coded as "US$5.3&nbsp;million" or its {{Nowrap}} equivalent, so it won't word wrap to the next line between "5.3" and "million". That can be accomplished by coding {{US$|5.3&nbsp;million}}. But perhaps your template should make the nbsp automatic, because most editors won't remember it otherwise – and also because the above workaround looks as if it won't work, even though it does. Art LaPella (talk) 04:39, 22 July 2010 (UTC)[reply]

Trivially fixed by wrapping the template in a nowrap span. I also removed the non-breaking space before the optional value for equivalence, as WP:NBSP says nothing about it being undesirable to wrap before parentheses. Can you test the code in the sandbox to see if this resolves the problem for you? Chris Cunningham (user:thumperward: not at work) - talk 08:56, 22 July 2010 (UTC)[reply]
Yes. I've never done such a test before, but it works for this and this (it didn't work for {{US$/sandbox|42 million|1916|round=0}}, but the non-sandbox version doesn't handle that case either). I unmaximized that page and stretched the window in and out, and the nbsp's worked as intended. So thank you. Art LaPella (talk) 21:23, 22 July 2010 (UTC)[reply]
Just to confirm: are there still cases where there are bugs, before I make a request to get this live? Chris Cunningham (user:thumperward: not at work) - talk 09:40, 23 July 2010 (UTC)[reply]
I would make it live. The bug I described already exists, even if you don't make the change. Art LaPella (talk) 18:02, 23 July 2010 (UTC)[reply]
I've now  Done this (first ever use of my new admin bit, woo!). If there are any problems please let me know ASAP. Chris Cunningham (user:thumperward: not at work) - talk 08:54, 4 August 2010 (UTC)[reply]
apparently the latest changes made leaves an unwanted trailing space that interferes with punctuation. example: US$4 million♦. --emerson7 15:28, 1 September 2010 (UTC)[reply]
Fixed in sandbox, tested, and deployed. Chris Cunningham (user:thumperward: not at work) - talk 16:10, 1 September 2010 (UTC)[reply]
great!....i took the liberty of ripping off adapting your work for {{NZ$}} and {{AU$}}. --emerson7 18:53, 1 September 2010 (UTC)[reply]

Linking

[edit]

{{editprotect}} As per WP:Linking, the instances where United States dollar ought to be linked are few and far between. However, this template's use proliferates this common term. I ask that the wikilink be removed. Thanks, --Ohconfucius ¡digame! 03:33, 8 October 2010 (UTC)[reply]

Ah, saw this in OC's contribs, and am alarmed that this is still linked, contrary to the style guides. In fact, my other concern is that the style guides say US$ are the default currency: the "US" should generally not be used unless there is reason to disambiguate it with other dollar currencies (say, in an article on Fiji, or Australia—and then, only once in the context where it's subsequently clear). Is this template encouraging editors into the opposite? If so, we should change the style guides. Tony (talk) 03:37, 8 October 2010 (UTC)[reply]
Here's the MOS: Wikipedia:Manual of Style (dates and numbers)#Currencies
I read it as needing the currencies to be disambiguated whenever it is not clear whcih currency is in use. As an Australian, I find it confusing when an article says $. Was it written by an American who habitually uses $ without thinking (ie US$)? Was it written by a Australian doing the same thing (AU$)? Or was it written by an Australian trying to be global (ie US$)? Similarly for HK$, TW$, CA$ and probably others I'm not yet aware of.
Also, before this template started, many editors were trying to make it explicit by doing $45.00, US$45.00, us$45.00, usd45.00, USD45.00, USD$45.00, $45.00(US) and many other variations - quite often in the same article. If we dropped the US ouput of this template then many editors will start putting in their own US specifiers again and will be back in the mess that we started in.
Howvere, I do agree that a link for every use is over the top. It is hard to make it automatically link only on the first invocation in an article, so perhaps we can turn the link off by default and have a named parameter to explicitly re-enable the link when the editor wants it.  Stepho  (talk) 08:39, 8 October 2010 (UTC)[reply]

 Done. I've delinked it by default, but it may be linked by using |link=yes — Martin (MSGJ · talk) 12:02, 8 October 2010 (UTC)[reply]

Price ranges

[edit]

Is is possible to offer the option to handle price ranges, such as how {{convert}} handles ranges? – VisionHolder « talk » 08:37, 9 January 2011 (UTC)[reply]

I think that should be possible and would be a good feature. I don't have time to do it myself in the next month though.  Stepho  (talk) 23:33, 12 January 2011 (UTC)[reply]

Request for shortening of large numbers

[edit]

Currently, the template displays large currency values in their entirety or in scientific notation. Since large currency values are discussed in millions, billions, and trillions of dollars, there should be an option to display large currency values with the corresponding abbreviations (e.g. $1M for $1,000,000 $10bn for $10,000,000,000). If you know how to code this in the template, please do so. –Temporal User (Talk) 01:52, 27 August 2011 (UTC)[reply]

It's a good idea but a bit beyond my current skills. Perhaps one of the other editors can have a crack at it.  Stepho  talk  08:45, 27 August 2011 (UTC)[reply]
Have a look at Draft:Template:FXConvert/Wordify. I extended it from Template:INRConvert/Wordify. Trigenibinion (talk) 18:43, 3 January 2021 (UTC)[reply]
+1 on this, it would be a nice feature to have. Something like |scaled= and T, B or M (trillion, billion or million) to force a specific scale (even if such a scale results in something like 0.75M or 1,500M) or a simple 0 (disabled) or 1 (enabled) to have the template automagically decide based on the input value to use million (for values > 1 million but < 1 billion), billion (for values > 1 billion but < 1 trillion) or trillion (for values > 1 trillion). —Locke Coletc 17:09, 18 January 2024 (UTC)[reply]

Protection?

[edit]
  • After reading through the talk page I'm not going to request any edits anyway, but I wanted to ask: why is this template is protected at all? According to the transclusion count tool it's only used on ~1500 pages (currently).
    — V = IR (Talk • Contribs) 17:38, 31 March 2012 (UTC)[reply]
Only 1500? Sounds like a lot of article to screw up, either deliberately or by accident.  Stepho  talk  10:53, 1 April 2012 (UTC)[reply]
Yes, only. Compare 1500 with the 472103 transclusions of Template:Convert or the 1554308 transclusions of Template:Citation/core. Those are high-risk templates.
— V = IR (Talk • Contribs) 15:08, 1 April 2012 (UTC)[reply]
  • The original protecting was done at 16:42, 26 December 2008 by User:Nick with the stated reason Wikipedia:High-risk templates (Highly visible template). See http://wiki.riteme.site/w/index.php?title=Special:Log&page=Template%3AUSD . Anthony Appleyard (talk) 16:07, 1 April 2012 (UTC)[reply]
    Alright well... I assume that you're saying "ask User:Nick", so I dropped a note on his talk page. He hasn't edited since early December though (outside of one edit on March 1), so we'll see what happens. I guess that I'll just drop a note on RFPP if nothing happens in the next few days.
    — V = IR (Talk • Contribs) 01:32, 2 April 2012 (UTC)[reply]
  • This needs a rewrite to reduce template expansion depth

    [edit]

    The inflation/year feature uses up 33 of the 40 levels of "expansion depth" allowed by MediaWiki software. This means if something like {{US$|1|2001}} is used in a template that itself has 7 levels of "expansion depth" surrounding the use of this template, the page will have problems.

    Note that {{Inflation}} uses 21 of these 33 levels.

    I've updated the documentation.

    The best solution would be to turn this or {{inflation}} or both into a module. Other options include re-coding it to have less expansion depth. davidwr/(talk)/(contribs) 22:45, 13 February 2020 (UTC)[reply]

    Since {{Inflation}} is the more complex template and uses up more levels, I would choose that one to make into a module.  Stepho  talk  13:24, 14 February 2020 (UTC)[reply]

    Integration with Template:Format price?

    [edit]

    Could we add a parameter that'd allow input here to be formatted using {{Format price}}? {{u|Sdkb}}talk 19:38, 21 September 2020 (UTC)[reply]

    If this is done, care must be taken not to increase the "expansion depth" until the issues from February are eliminated, or it could cause problems on some pages that use the template. Whoever does this please please please test it out in a sandbox and compare the "template expansion depth" to make sure it doesn't "cost" a layer under any circumstances. In the alternative, address the issues raised in February first. davidwr/(talk)/(contribs) 20:08, 21 September 2020 (UTC)[reply]
    That would be great, because I constantly refer to how I optimized it in the lead of Great Flood of 1951. — Smuckola(talk) 08:49, 7 August 2022 (UTC)[reply]

    Index

    [edit]

    This template always uses the US inflation index. For some things one has to use the US-GDP index. Trigenibinion (talk) 01:25, 21 December 2020 (UTC)[reply]

    Prose for repeated prices

    [edit]

    On Nintendo_64_Game_Pak#Manufacturing_cost, please let me know if you think that my inflation calculation prose is ok, because inflation is important to a section about comparing many intricate costs at a certain historical mark. I mean, with a list of numerous prices like that, I just abbreviated it as direct parentheses without the repeated "equivalent to". But I reiterated the full statement with each paragraph. Kind of like how I do "long=yes" at the first instance in a whole article. The inflation calculator template policy is very against original research in numbers but it doesn't give examples on how to do this. Shouldn't there be an argument added to Template:US$ to eliminate "equivalent to" for this case? Or to change the accessory text, like we have in Template:As of so it doesn't only output "as of". — Smuckola(talk) 08:47, 7 August 2022 (UTC)[reply]

    Template-protected edit request on 27 December 2022

    [edit]

    Merge from sandbox, add showyear=yes parameter,

    {{#if:{{{showyear|}}}|{{#if:{{{year|{{{2|}}}}}}|in {{{year|{{{2|}}}}}}}}}}

    to show the year of the currency between the amount and the conversion e.g.

    US$100 in 1950 (equivalent to $1,126 in 2021).

    instead of

    US$100 (equivalent to $1,126 in 2021).

    for better sentence structuring in specific cases. — TheThomanski | t | c | 00:40, 27 December 2022 (UTC)[reply]

     DoneMdaniels5757 (talk • contribs) 17:23, 28 December 2022 (UTC)[reply]

    minus sign

    [edit]

    Should the minus sign be placed before (-$1) or after ($-1) the dollar sign? 79.185.136.221 (talk) 21:23, 29 December 2022 (UTC)[reply]

    WP doesn't seem to have an explicit policy on this but various style guides recommend, for US dollars, that the negative sign goes first. Other currencies may differ. See https://learn.microsoft.com/en-us/globalization/locale/currency-formatting . {{currency}} puts the dollar sign first - although this may have been arbitrary choice. You should try to avoid negative amounts if possible - eg "the company made a loss of $1,000,000" instead of "the yearly profits were -$1,000,000".  Stepho  talk  00:32, 30 December 2022 (UTC)[reply]

    Pages with non-numeric formatnum arguments?

    [edit]

    I've noticed that a lot of articles that use this template with more than just numbers are part of this category. Ex: 200 Pounds Beauty, which has

    {{USD|42,013,016}}

    Is there any way to prevent this from being labeled as a non-numeric formatnum argument without messing up how it looks? All I can think of is replacing the aforementioned text with

    {{USD|42}},013,016

    but it might look awkward in source mode. - OpalYosutebito (talk) 01:47, 23 March 2024 (UTC)[reply]

    Template-protected edit request on 22 July 2024

    [edit]

    Can Template:Euro please be added to the see also section at the bottom of the template? Cheers! Johnson524 04:55, 22 July 2024 (UTC)[reply]

     Done  Stepho  talk  05:55, 22 July 2024 (UTC)[reply]

    Move discussion in progress

    [edit]

    There is a discussion at template talk:CNY#Requested move 8 September 2024 which may be relevant to users of this template. 𝕁𝕄𝔽 (talk) 09:24, 8 September 2024 (UTC)[reply]