[{"data":1,"prerenderedAt":1997},["ShallowReactive",2],{"i-mdi:close":3,"i-bx:menu":8,"i-ph:translate":10,"i-flag:br-4x3":13,"i-flag:us-4x3":17,"post-intl-native-javascript":19},{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":7},0,24,false,"\u003Cpath fill=\"currentColor\" d=\"M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12z\"/>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":9},"\u003Cpath fill=\"currentColor\" d=\"M4 6h16v2H4zm0 5h16v2H4zm0 5h16v2H4z\"/>",{"left":4,"top":4,"width":11,"height":11,"rotate":4,"vFlip":6,"hFlip":6,"body":12},256,"\u003Cpath fill=\"currentColor\" d=\"m247.15 212.42l-56-112a8 8 0 0 0-14.31 0l-21.71 43.43A88 88 0 0 1 108 126.93A103.65 103.65 0 0 0 135.69 64H160a8 8 0 0 0 0-16h-56V32a8 8 0 0 0-16 0v16H32a8 8 0 0 0 0 16h87.63A87.76 87.76 0 0 1 96 116.35a87.7 87.7 0 0 1-19-31a8 8 0 1 0-15.08 5.34A103.6 103.6 0 0 0 84 127a87.55 87.55 0 0 1-52 17a8 8 0 0 0 0 16a103.46 103.46 0 0 0 64-22.08a104.2 104.2 0 0 0 51.44 21.31l-26.6 53.19a8 8 0 0 0 14.31 7.16L148.94 192h70.11l13.79 27.58A8 8 0 0 0 240 224a8 8 0 0 0 7.15-11.58M156.94 176L184 121.89L211.05 176Z\"/>",{"left":4,"top":4,"width":14,"height":15,"rotate":4,"vFlip":6,"hFlip":6,"body":16},640,480,"\u003Cg stroke-width=\"1pt\">\u003Cpath fill=\"#229e45\" fill-rule=\"evenodd\" d=\"M0 0h640v480H0z\"/>\u003Cpath fill=\"#f8e509\" fill-rule=\"evenodd\" d=\"m321.4 436l301.5-195.7L319.6 44L17.1 240.7z\"/>\u003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1-1.2 1.1-3.7q.1-2.4-1-3.6a4 4 0 0 0-2.7-1.3a4 4 0 0 0-2.8 1.2q-1.1 1.2-1.2 3.6\"/>\u003C/g>\u003Cg stroke-opacity=\".5\">\u003Cpath fill=\"#309e3a\" d=\"m233 198.5l.2-14h6q2.2 0 3.2.5q1 .3 1.6 1.3c.6 1 .6 1.4.6 2.3a4 4 0 0 1-1 2.6a5 5 0 0 1-2.7 1.2l1.5 1.2q.6.6 1.5 2.3l1.7 2.8h-3.4l-2-3.2l-1.4-2l-.9-.6l-1.4-.2h-.6v5.8z\"/>\u003Cpath fill=\"#fff\" d=\"M236 190.5h2q2.1 0 2.6-.2q.5-.1.8-.5q.4-.6.3-1q0-.9-.4-1.2q-.3-.4-1-.6h-2l-2.3-.1z\"/>\u003C/g>\u003Cg stroke-opacity=\".5\">\u003Cpath fill=\"#309e3a\" d=\"m249 185.2l5.2.3q1.7 0 2.6.3a5 5 0 0 1 2 1.4a6 6 0 0 1 1.2 2.4q.4 1.4.3 3.3a9 9 0 0 1-.5 3q-.6 1.5-1.7 2.4a5 5 0 0 1-2 1q-1 .3-2.5.2l-5.3-.3z\"/>\u003Cpath fill=\"#fff\" d=\"m251.7 187.7l-.5 9.3h3.8q.8 0 1.2-.5q.5-.4.8-1.3t.4-2.6l-.1-2.5a3 3 0 0 0-.8-1.4l-1.2-.7l-2.3-.3z\"/>\u003C/g>\u003Cg stroke-opacity=\".5\">\u003Cpath fill=\"#309e3a\" d=\"m317.6 210.2l3.3-13.6l4.4 1l3.2 1q1.1.6 1.6 1.9t.2 2.8q-.3 1.2-1 2a4 4 0 0 1-3 1.4q-1 0-3-.5l-1.7-.5l-1.2 5.2z\"/>\u003Cpath fill=\"#fff\" d=\"m323 199.6l-.8 3.8l1.5.4q1.6.4 2.2.3a2 2 0 0 0 1.6-1.5q0-.7-.2-1.3a2 2 0 0 0-1-.9l-1.9-.5l-1.3-.3z\"/>\u003C/g>\u003Cg stroke-opacity=\".5\">\u003Cpath fill=\"#309e3a\" d=\"m330.6 214.1l4.7-13.2l5.5 2q2.2.8 3 1.4q.8.7 1 1.8c.2 1.1.2 1.5 0 2.3q-.6 1.5-1.8 2.2q-1.2.6-3 .3q.6.7 1 1.6l.8 2.7l.6 3.1l-3.1-1.1l-1-3.6l-.7-2.4l-.6-.8q-.3-.4-1.3-.7l-.5-.2l-2 5.6z\"/>\u003Cpath fill=\"#fff\" d=\"m336 207.4l1.9.7q2 .7 2.5.7t.9-.3q.5-.3.6-.9q.3-.6 0-1.2l-.8-.9l-2-.7l-2-.7l-1.2 3.3z\"/>\u003C/g>\u003Cg stroke-opacity=\".5\">\u003Cpath fill=\"#309e3a\" d=\"M347 213.6a9 9 0 0 1 1.7-3.2l1.8-1.5l2-.7q1.5-.1 3.1.4a7 7 0 0 1 4.2 3.3q1.2 2.4.2 5.7a7 7 0 0 1-3.4 4.5q-2.3 1.3-5.2.4a7 7 0 0 1-4.2-3.3a7 7 0 0 1-.2-5.6\"/>\u003Cpath fill=\"#fff\" d=\"M349.8 214.4q-.7 2.3 0 3.8c.7 1.5 1.2 1.6 2.3 2q1.5.5 3-.4q1.4-.8 2.1-3.2q.8-2.2 0-3.7a4 4 0 0 0-2.2-2a4 4 0 0 0-3 .3q-1.5.8-2.2 3.2\"/>\u003C/g>\u003Cg stroke-opacity=\".5\">\u003Cpath fill=\"#309e3a\" d=\"m374.3 233.1l6.4-12.4l5.3 2.7a10 10 0 0 1 2.7 1.9q.8.7.8 1.9c0 1.2 0 1.5-.4 2.2a4 4 0 0 1-2 2q-1.5.4-3.1-.2q.6 1 .8 1.7q.3.9.4 2.8l.2 3.2l-3-1.5l-.4-3.7l-.3-2.5l-.5-1l-1.2-.7l-.5-.3l-2.7 5.2z\"/>\u003Cpath fill=\"#fff\" d=\"m380.5 227.2l1.9 1q1.8 1 2.3 1t1-.2q.4-.2.7-.8t.2-1.2l-.7-1l-1.8-1l-2-1z\"/>\u003C/g>\u003Cg stroke-opacity=\".5\">\u003Cpath fill=\"#309e3a\" d=\"M426.1 258.7a9 9 0 0 1 2.5-2.6a7 7 0 0 1 2.2-.9a6 6 0 0 1 2.2 0q1.5.3 2.8 1.2a7 7 0 0 1 3 4.4q.4 2.6-1.4 5.5a7 7 0 0 1-4.5 3.3a7 7 0 0 1-5.2-1.1a7 7 0 0 1-3-4.4q-.4-2.7 1.4-5.4\"/>\u003Cpath fill=\"#fff\" d=\"M428.6 260.3q-1.4 2-1.1 3.6a4 4 0 0 0 1.6 2.5q1.5 1 3 .6t2.9-2.4q1.4-2.1 1.1-3.6t-1.6-2.6c-1.4-1.1-2-.8-3-.5q-1.5.3-3 2.4z\"/>\u003C/g>\u003Cpath fill=\"#309e3a\" d=\"m301.8 204.5l2.3-9.8l7.2 1.7l-.3 1.6l-5.3-1.2l-.5 2.2l4.9 1.1l-.4 1.7l-4.9-1.2l-.6 2.7l5.5 1.3l-.4 1.6z\"/>\u003C/g>",{"left":4,"top":4,"width":14,"height":15,"rotate":4,"vFlip":6,"hFlip":6,"body":18},"\u003Cpath fill=\"#bd3d44\" d=\"M0 0h640v480H0\"/>\u003Cpath stroke=\"#fff\" stroke-width=\"37\" d=\"M0 55.3h640M0 129h640M0 203h640M0 277h640M0 351h640M0 425h640\"/>\u003Cpath fill=\"#192f5d\" d=\"M0 0h364.8v258.5H0\"/>\u003Cmarker id=\"SVGEq3dreKJ\" markerHeight=\"30\" markerWidth=\"30\">\u003Cpath fill=\"#fff\" d=\"m14 0l9 27L0 10h28L5 27z\"/>\u003C/marker>\u003Cpath fill=\"none\" marker-mid=\"url(#SVGEq3dreKJ)\" d=\"m0 0l16 11h61h61h61h61h60L47 37h61h61h60h61L16 63h61h61h61h61h60L47 89h61h61h60h61L16 115h61h61h61h61h60L47 141h61h61h60h61L16 166h61h61h61h61h60L47 192h61h61h60h61L16 218h61h61h61h61h60z\"/>",{"id":20,"title":21,"body":22,"description":65,"description_en":1982,"description_pt":1983,"draft":6,"extension":1984,"meta":1985,"navigation":139,"path":1986,"publishDate":1987,"seo":1988,"slug":1989,"stem":1990,"tags":1991,"title_en":1994,"title_pt":1995,"__hash__":1996},"blog/blog/intl-native-javascript.md","Intl Native Javascript",{"type":23,"value":24,"toc":1972},"minimark",[25,45,59,254,273,288,348,353,358,472,477,482,567,572,577,701,726,745,787,794,801,1132,1137,1142,1167,1221,1260,1352,1361,1369,1529,1537,1544,1629,1641,1651,1758,1791,1816,1952,1960,1968],[26,27,29,38],"lang-block",{"lang":28},"pt",[30,31,32,33,37],"p",{},"O ",[34,35,36],"code",{},"Intl"," é uma API do Javascript que fornece funcionalidades para criação de textos internacionalizados. Entretanto, ela pode ser usada em qualquer caso que você precise formatar informações de Javascript em textos, removendo a necessidade de bibliotecas externas.",[30,39,40,41,44],{},"Uma das funcionalidades mais conhecidas é o ",[34,42,43],{},"Intl.DateTimeFormat",", que está disponível desde 2017. Ele é usado para formatar datas e horas:",[26,46,48,53],{"lang":47},"en",[30,49,50,52],{},[34,51,36],{}," is a JavaScript API that provides functionality for creating internationalized text. However, it can be used in any case where you need to format JavaScript information into text, removing the need for external libraries.",[30,54,55,56,58],{},"One of the most well-known features is ",[34,57,43],{},", which has been available since 2017. It's used to format dates and times:",[60,61,66],"pre",{"className":62,"code":63,"language":64,"meta":65,"style":65},"language-ts shiki shiki-themes github-dark github-dark github-light","const portugueseFormatter = new Intl.DateTimeFormat(\"pt-BR\", {\n  dateStyle: \"full\",\n  timeStyle: \"short\",\n});\n\nconst englishFormatter = new Intl.DateTimeFormat(\"en-US\", {\n  dateStyle: \"full\",\n  timeStyle: \"short\",\n});\n\nconst date = new Date(\"2025-05-01T12:00:00Z\");\nconsole.log(portugueseFormatter.format(date)); // Thursday, May 1, 2025 at 9:00 AM (in PT)\nconsole.log(englishFormatter.format(date)); // Thursday, May 1, 2025 at 9:00 AM\n","ts","",[34,67,68,105,117,128,134,141,164,173,182,187,192,215,237],{"__ignoreMap":65},[69,70,73,77,81,84,87,91,95,98,102],"span",{"class":71,"line":72},"line",1,[69,74,76],{"class":75},"s6ubI","const",[69,78,80],{"class":79},"sXWYR"," portugueseFormatter",[69,82,83],{"class":75}," =",[69,85,86],{"class":75}," new",[69,88,90],{"class":89},"sAvwS"," Intl.",[69,92,94],{"class":93},"s5n6i","DateTimeFormat",[69,96,97],{"class":89},"(",[69,99,101],{"class":100},"s4Y1p","\"pt-BR\"",[69,103,104],{"class":89},", {\n",[69,106,108,111,114],{"class":71,"line":107},2,[69,109,110],{"class":89},"  dateStyle: ",[69,112,113],{"class":100},"\"full\"",[69,115,116],{"class":89},",\n",[69,118,120,123,126],{"class":71,"line":119},3,[69,121,122],{"class":89},"  timeStyle: ",[69,124,125],{"class":100},"\"short\"",[69,127,116],{"class":89},[69,129,131],{"class":71,"line":130},4,[69,132,133],{"class":89},"});\n",[69,135,137],{"class":71,"line":136},5,[69,138,140],{"emptyLinePlaceholder":139},true,"\n",[69,142,144,146,149,151,153,155,157,159,162],{"class":71,"line":143},6,[69,145,76],{"class":75},[69,147,148],{"class":79}," englishFormatter",[69,150,83],{"class":75},[69,152,86],{"class":75},[69,154,90],{"class":89},[69,156,94],{"class":93},[69,158,97],{"class":89},[69,160,161],{"class":100},"\"en-US\"",[69,163,104],{"class":89},[69,165,167,169,171],{"class":71,"line":166},7,[69,168,110],{"class":89},[69,170,113],{"class":100},[69,172,116],{"class":89},[69,174,176,178,180],{"class":71,"line":175},8,[69,177,122],{"class":89},[69,179,125],{"class":100},[69,181,116],{"class":89},[69,183,185],{"class":71,"line":184},9,[69,186,133],{"class":89},[69,188,190],{"class":71,"line":189},10,[69,191,140],{"emptyLinePlaceholder":139},[69,193,195,197,200,202,204,207,209,212],{"class":71,"line":194},11,[69,196,76],{"class":75},[69,198,199],{"class":79}," date",[69,201,83],{"class":75},[69,203,86],{"class":75},[69,205,206],{"class":93}," Date",[69,208,97],{"class":89},[69,210,211],{"class":100},"\"2025-05-01T12:00:00Z\"",[69,213,214],{"class":89},");\n",[69,216,218,221,224,227,230,233],{"class":71,"line":217},12,[69,219,220],{"class":89},"console.",[69,222,223],{"class":93},"log",[69,225,226],{"class":89},"(portugueseFormatter.",[69,228,229],{"class":93},"format",[69,231,232],{"class":89},"(date)); ",[69,234,236],{"class":235},"sxXm1","// Thursday, May 1, 2025 at 9:00 AM (in PT)\n",[69,238,240,242,244,247,249,251],{"class":71,"line":239},13,[69,241,220],{"class":89},[69,243,223],{"class":93},[69,245,246],{"class":89},"(englishFormatter.",[69,248,229],{"class":93},[69,250,232],{"class":89},[69,252,253],{"class":235},"// Thursday, May 1, 2025 at 9:00 AM\n",[26,255,256,262,267],{"lang":28},[30,257,258,259,261],{},"Entretanto, existem outras APIs menos conhecidas (mas muito úteis) que também estão disponíveis através do ",[34,260,36],{},".",[263,264,266],"h2",{"id":265},"intlnumberformat","Intl.NumberFormat",[30,268,32,269,272],{},[34,270,271],{},"NumberFormat"," é muito útil para aplicativos em português, já que utilizamos vírgula para representar casas decimais.",[26,274,275,280,283],{"lang":47},[30,276,277,278,261],{},"However, there are other less known (but very useful) APIs that are also available through ",[34,279,36],{},[263,281,266],{"id":282},"intlnumberformat-1",[30,284,285,287],{},[34,286,271],{}," is very useful for applications in Portuguese, since we use commas to represent decimal places.",[60,289,291],{"className":62,"code":290,"language":64,"meta":65,"style":65},"const conversionRate = 3.7;\nconst portugueseNumberFormatter = Intl.NumberFormat(\"pt-BR\");\n\nconsole.log(portugueseNumberFormatter.format(conversionRate)); // 3,7\n",[34,292,293,308,327,331],{"__ignoreMap":65},[69,294,295,297,300,302,305],{"class":71,"line":72},[69,296,76],{"class":75},[69,298,299],{"class":79}," conversionRate",[69,301,83],{"class":75},[69,303,304],{"class":79}," 3.7",[69,306,307],{"class":89},";\n",[69,309,310,312,315,317,319,321,323,325],{"class":71,"line":107},[69,311,76],{"class":75},[69,313,314],{"class":79}," portugueseNumberFormatter",[69,316,83],{"class":75},[69,318,90],{"class":89},[69,320,271],{"class":93},[69,322,97],{"class":89},[69,324,101],{"class":100},[69,326,214],{"class":89},[69,328,329],{"class":71,"line":119},[69,330,140],{"emptyLinePlaceholder":139},[69,332,333,335,337,340,342,345],{"class":71,"line":130},[69,334,220],{"class":89},[69,336,223],{"class":93},[69,338,339],{"class":89},"(portugueseNumberFormatter.",[69,341,229],{"class":93},[69,343,344],{"class":89},"(conversionRate)); ",[69,346,347],{"class":235},"// 3,7\n",[26,349,350],{"lang":28},[30,351,352],{},"Também é possível definir um valor mínimo ou máximo de dígitos depois da vírgula (com a possibilidade de definir a estratégia de arredondamento):",[26,354,355],{"lang":47},[30,356,357],{},"It's also possible to define a minimum or maximum number of digits after the comma (with the possibility of defining the rounding strategy):",[60,359,361],{"className":62,"code":360,"language":64,"meta":65,"style":65},"const winningRate = 1.2345653;\nconst zero = 0;\n\nconst portugueseNumberFormatter = Intl.NumberFormat(\"pt-BR\", {\n  maximumFractionDigits: 3,\n  minimumFractionDigits: 3,\n});\n\nconsole.log(portugueseNumberFormatter.format(winningRate)); // 1,235\nconsole.log(portugueseNumberFormatter.format(zero)); // 0,000\n",[34,362,363,377,391,395,413,423,432,436,440,456],{"__ignoreMap":65},[69,364,365,367,370,372,375],{"class":71,"line":72},[69,366,76],{"class":75},[69,368,369],{"class":79}," winningRate",[69,371,83],{"class":75},[69,373,374],{"class":79}," 1.2345653",[69,376,307],{"class":89},[69,378,379,381,384,386,389],{"class":71,"line":107},[69,380,76],{"class":75},[69,382,383],{"class":79}," zero",[69,385,83],{"class":75},[69,387,388],{"class":79}," 0",[69,390,307],{"class":89},[69,392,393],{"class":71,"line":119},[69,394,140],{"emptyLinePlaceholder":139},[69,396,397,399,401,403,405,407,409,411],{"class":71,"line":130},[69,398,76],{"class":75},[69,400,314],{"class":79},[69,402,83],{"class":75},[69,404,90],{"class":89},[69,406,271],{"class":93},[69,408,97],{"class":89},[69,410,101],{"class":100},[69,412,104],{"class":89},[69,414,415,418,421],{"class":71,"line":136},[69,416,417],{"class":89},"  maximumFractionDigits: ",[69,419,420],{"class":79},"3",[69,422,116],{"class":89},[69,424,425,428,430],{"class":71,"line":143},[69,426,427],{"class":89},"  minimumFractionDigits: ",[69,429,420],{"class":79},[69,431,116],{"class":89},[69,433,434],{"class":71,"line":166},[69,435,133],{"class":89},[69,437,438],{"class":71,"line":175},[69,439,140],{"emptyLinePlaceholder":139},[69,441,442,444,446,448,450,453],{"class":71,"line":184},[69,443,220],{"class":89},[69,445,223],{"class":93},[69,447,339],{"class":89},[69,449,229],{"class":93},[69,451,452],{"class":89},"(winningRate)); ",[69,454,455],{"class":235},"// 1,235\n",[69,457,458,460,462,464,466,469],{"class":71,"line":189},[69,459,220],{"class":89},[69,461,223],{"class":93},[69,463,339],{"class":89},[69,465,229],{"class":93},[69,467,468],{"class":89},"(zero)); ",[69,470,471],{"class":235},"// 0,000\n",[26,473,474],{"lang":28},[30,475,476],{},"E se você pensou que essa é a solução para manter preços sempre dentro do estilo necessário, existe algo melhor, uma opção específica para formatar preços e moedas:",[26,478,479],{"lang":47},[30,480,481],{},"And if you thought this is the solution to keep prices always in the necessary style, there's something better, a specific option to format prices and currencies:",[60,483,485],{"className":62,"code":484,"language":64,"meta":65,"style":65},"const ticketPrice = 5.9;\n\nconst realFormatter = new Intl.NumberFormat(\"pt-BR\", {\n  style: \"currency\",\n  currency: \"BRL\",\n});\nconsole.log(realFormatter.format(ticketPrice)); // R$ 5,90\n",[34,486,487,501,505,526,536,546,550],{"__ignoreMap":65},[69,488,489,491,494,496,499],{"class":71,"line":72},[69,490,76],{"class":75},[69,492,493],{"class":79}," ticketPrice",[69,495,83],{"class":75},[69,497,498],{"class":79}," 5.9",[69,500,307],{"class":89},[69,502,503],{"class":71,"line":107},[69,504,140],{"emptyLinePlaceholder":139},[69,506,507,509,512,514,516,518,520,522,524],{"class":71,"line":119},[69,508,76],{"class":75},[69,510,511],{"class":79}," realFormatter",[69,513,83],{"class":75},[69,515,86],{"class":75},[69,517,90],{"class":89},[69,519,271],{"class":93},[69,521,97],{"class":89},[69,523,101],{"class":100},[69,525,104],{"class":89},[69,527,528,531,534],{"class":71,"line":130},[69,529,530],{"class":89},"  style: ",[69,532,533],{"class":100},"\"currency\"",[69,535,116],{"class":89},[69,537,538,541,544],{"class":71,"line":136},[69,539,540],{"class":89},"  currency: ",[69,542,543],{"class":100},"\"BRL\"",[69,545,116],{"class":89},[69,547,548],{"class":71,"line":143},[69,549,133],{"class":89},[69,551,552,554,556,559,561,564],{"class":71,"line":166},[69,553,220],{"class":89},[69,555,223],{"class":93},[69,557,558],{"class":89},"(realFormatter.",[69,560,229],{"class":93},[69,562,563],{"class":89},"(ticketPrice)); ",[69,565,566],{"class":235},"// R$ 5,90\n",[26,568,569],{"lang":28},[30,570,571],{},"E até unidades podem ser utilizadas:",[26,573,574],{"lang":47},[30,575,576],{},"And even units can be used:",[60,578,580],{"className":62,"code":579,"language":64,"meta":65,"style":65},"const distanceKilometers = 90;\nconst timeInHours = 0.4;\n\nconst velocity = distanceKilometers / timeInHours;\n\nconst velocityFormatter = new Intl.NumberFormat(\"pt-BR\", {\n  style: \"unit\",\n  unit: \"kilometer-per-hour\",\n});\n\nconsole.log(velocityFormatter.format(velocity)); // 225 km/h\n",[34,581,582,596,610,614,632,636,657,666,676,680,684],{"__ignoreMap":65},[69,583,584,586,589,591,594],{"class":71,"line":72},[69,585,76],{"class":75},[69,587,588],{"class":79}," distanceKilometers",[69,590,83],{"class":75},[69,592,593],{"class":79}," 90",[69,595,307],{"class":89},[69,597,598,600,603,605,608],{"class":71,"line":107},[69,599,76],{"class":75},[69,601,602],{"class":79}," timeInHours",[69,604,83],{"class":75},[69,606,607],{"class":79}," 0.4",[69,609,307],{"class":89},[69,611,612],{"class":71,"line":119},[69,613,140],{"emptyLinePlaceholder":139},[69,615,616,618,621,623,626,629],{"class":71,"line":130},[69,617,76],{"class":75},[69,619,620],{"class":79}," velocity",[69,622,83],{"class":75},[69,624,625],{"class":89}," distanceKilometers ",[69,627,628],{"class":75},"/",[69,630,631],{"class":89}," timeInHours;\n",[69,633,634],{"class":71,"line":136},[69,635,140],{"emptyLinePlaceholder":139},[69,637,638,640,643,645,647,649,651,653,655],{"class":71,"line":143},[69,639,76],{"class":75},[69,641,642],{"class":79}," velocityFormatter",[69,644,83],{"class":75},[69,646,86],{"class":75},[69,648,90],{"class":89},[69,650,271],{"class":93},[69,652,97],{"class":89},[69,654,101],{"class":100},[69,656,104],{"class":89},[69,658,659,661,664],{"class":71,"line":166},[69,660,530],{"class":89},[69,662,663],{"class":100},"\"unit\"",[69,665,116],{"class":89},[69,667,668,671,674],{"class":71,"line":175},[69,669,670],{"class":89},"  unit: ",[69,672,673],{"class":100},"\"kilometer-per-hour\"",[69,675,116],{"class":89},[69,677,678],{"class":71,"line":184},[69,679,133],{"class":89},[69,681,682],{"class":71,"line":189},[69,683,140],{"emptyLinePlaceholder":139},[69,685,686,688,690,693,695,698],{"class":71,"line":194},[69,687,220],{"class":89},[69,689,223],{"class":93},[69,691,692],{"class":89},"(velocityFormatter.",[69,694,229],{"class":93},[69,696,697],{"class":89},"(velocity)); ",[69,699,700],{"class":235},"// 225 km/h\n",[26,702,703,713,717,723],{"lang":28},[30,704,705,706,261],{},"Outras opções e exemplos estão disponíveis no ",[707,708,712],"a",{"href":709,"rel":710},"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat",[711],"nofollow","MDN",[263,714,716],{"id":715},"intlpluralrules","Intl.PluralRules",[718,719,720],"blockquote",{},[30,721,722],{},"1 usuário online",[30,724,725],{},"É muito fácil de esquecer de incluir regras de plural. E verificar manualmente pode ser repetitivo.",[26,727,728,734,737,742],{"lang":47},[30,729,730,731,261],{},"Other options and examples are available on ",[707,732,712],{"href":709,"rel":733},[711],[263,735,716],{"id":736},"intlpluralrules-1",[718,738,739],{},[30,740,741],{},"1 users online",[30,743,744],{},"It's very easy to forget to include plural rules. And checking manually can be repetitive.",[60,746,748],{"className":62,"code":747,"language":64,"meta":65,"style":65},"`${userCount} ${ userCount > 1 ? \"users\" : \"user\" } online`;\n",[34,749,750],{"__ignoreMap":65},[69,751,752,755,758,761,764,767,770,773,776,779,782,785],{"class":71,"line":72},[69,753,754],{"class":100},"`${",[69,756,757],{"class":89},"userCount",[69,759,760],{"class":100},"} ${",[69,762,763],{"class":89}," userCount",[69,765,766],{"class":75}," >",[69,768,769],{"class":79}," 1",[69,771,772],{"class":75}," ?",[69,774,775],{"class":100}," \"users\"",[69,777,778],{"class":75}," :",[69,780,781],{"class":100}," \"user\"",[69,783,784],{"class":100}," } online`",[69,786,307],{"class":89},[26,788,789],{"lang":28},[30,790,32,791,793],{},[34,792,716],{}," fornece ajuda retornando a categoria cardinal baseado no número:",[26,795,796],{"lang":47},[30,797,798,800],{},[34,799,716],{}," provides help by returning the cardinal category based on the number:",[60,802,804],{"className":62,"code":803,"language":64,"meta":65,"style":65},"const enCardinalRules = new Intl.PluralRules(\"en-US\");\nconst enNumberFormatter = new Intl.NumberFormat(\"en-US\", {\n  notation: \"compact\",\n  compactDisplay: \"long\",\n});\n\nfunction userCountText(userCount: number) {\n  const category = enCardinalRules.select(userCount);\n  const userCountDisplay = enNumberFormatter.format(userCount);\n\n  if (category === \"one\") {\n    return `${userCountDisplay} user online`;\n  }\n\n  if (category === \"other\") {\n    return `${userCountDisplay} users online`;\n  }\n\n  // Would you remember this case?\n  if (category === \"many\") {\n    return `${userCountDisplay} of users online`;\n  }\n}\n\nconsole.log(userCountText(1)); // 1 user online\nconsole.log(userCountText(2)); // 2 users online\nconsole.log(userCountText(2000000)); // 2 million users online\n",[34,805,806,828,849,859,869,873,877,899,918,934,938,954,970,975,980,994,1008,1013,1018,1024,1038,1052,1057,1063,1067,1090,1111],{"__ignoreMap":65},[69,807,808,810,813,815,817,819,822,824,826],{"class":71,"line":72},[69,809,76],{"class":75},[69,811,812],{"class":79}," enCardinalRules",[69,814,83],{"class":75},[69,816,86],{"class":75},[69,818,90],{"class":89},[69,820,821],{"class":93},"PluralRules",[69,823,97],{"class":89},[69,825,161],{"class":100},[69,827,214],{"class":89},[69,829,830,832,835,837,839,841,843,845,847],{"class":71,"line":107},[69,831,76],{"class":75},[69,833,834],{"class":79}," enNumberFormatter",[69,836,83],{"class":75},[69,838,86],{"class":75},[69,840,90],{"class":89},[69,842,271],{"class":93},[69,844,97],{"class":89},[69,846,161],{"class":100},[69,848,104],{"class":89},[69,850,851,854,857],{"class":71,"line":119},[69,852,853],{"class":89},"  notation: ",[69,855,856],{"class":100},"\"compact\"",[69,858,116],{"class":89},[69,860,861,864,867],{"class":71,"line":130},[69,862,863],{"class":89},"  compactDisplay: ",[69,865,866],{"class":100},"\"long\"",[69,868,116],{"class":89},[69,870,871],{"class":71,"line":136},[69,872,133],{"class":89},[69,874,875],{"class":71,"line":143},[69,876,140],{"emptyLinePlaceholder":139},[69,878,879,882,885,887,890,893,896],{"class":71,"line":166},[69,880,881],{"class":75},"function",[69,883,884],{"class":93}," userCountText",[69,886,97],{"class":89},[69,888,757],{"class":889},"sAzo5",[69,891,892],{"class":75},":",[69,894,895],{"class":79}," number",[69,897,898],{"class":89},") {\n",[69,900,901,904,907,909,912,915],{"class":71,"line":175},[69,902,903],{"class":75},"  const",[69,905,906],{"class":79}," category",[69,908,83],{"class":75},[69,910,911],{"class":89}," enCardinalRules.",[69,913,914],{"class":93},"select",[69,916,917],{"class":89},"(userCount);\n",[69,919,920,922,925,927,930,932],{"class":71,"line":184},[69,921,903],{"class":75},[69,923,924],{"class":79}," userCountDisplay",[69,926,83],{"class":75},[69,928,929],{"class":89}," enNumberFormatter.",[69,931,229],{"class":93},[69,933,917],{"class":89},[69,935,936],{"class":71,"line":189},[69,937,140],{"emptyLinePlaceholder":139},[69,939,940,943,946,949,952],{"class":71,"line":194},[69,941,942],{"class":75},"  if",[69,944,945],{"class":89}," (category ",[69,947,948],{"class":75},"===",[69,950,951],{"class":100}," \"one\"",[69,953,898],{"class":89},[69,955,956,959,962,965,968],{"class":71,"line":217},[69,957,958],{"class":75},"    return",[69,960,961],{"class":100}," `${",[69,963,964],{"class":89},"userCountDisplay",[69,966,967],{"class":100},"} user online`",[69,969,307],{"class":89},[69,971,972],{"class":71,"line":239},[69,973,974],{"class":89},"  }\n",[69,976,978],{"class":71,"line":977},14,[69,979,140],{"emptyLinePlaceholder":139},[69,981,983,985,987,989,992],{"class":71,"line":982},15,[69,984,942],{"class":75},[69,986,945],{"class":89},[69,988,948],{"class":75},[69,990,991],{"class":100}," \"other\"",[69,993,898],{"class":89},[69,995,997,999,1001,1003,1006],{"class":71,"line":996},16,[69,998,958],{"class":75},[69,1000,961],{"class":100},[69,1002,964],{"class":89},[69,1004,1005],{"class":100},"} users online`",[69,1007,307],{"class":89},[69,1009,1011],{"class":71,"line":1010},17,[69,1012,974],{"class":89},[69,1014,1016],{"class":71,"line":1015},18,[69,1017,140],{"emptyLinePlaceholder":139},[69,1019,1021],{"class":71,"line":1020},19,[69,1022,1023],{"class":235},"  // Would you remember this case?\n",[69,1025,1027,1029,1031,1033,1036],{"class":71,"line":1026},20,[69,1028,942],{"class":75},[69,1030,945],{"class":89},[69,1032,948],{"class":75},[69,1034,1035],{"class":100}," \"many\"",[69,1037,898],{"class":89},[69,1039,1041,1043,1045,1047,1050],{"class":71,"line":1040},21,[69,1042,958],{"class":75},[69,1044,961],{"class":100},[69,1046,964],{"class":89},[69,1048,1049],{"class":100},"} of users online`",[69,1051,307],{"class":89},[69,1053,1055],{"class":71,"line":1054},22,[69,1056,974],{"class":89},[69,1058,1060],{"class":71,"line":1059},23,[69,1061,1062],{"class":89},"}\n",[69,1064,1065],{"class":71,"line":5},[69,1066,140],{"emptyLinePlaceholder":139},[69,1068,1070,1072,1074,1076,1079,1081,1084,1087],{"class":71,"line":1069},25,[69,1071,220],{"class":89},[69,1073,223],{"class":93},[69,1075,97],{"class":89},[69,1077,1078],{"class":93},"userCountText",[69,1080,97],{"class":89},[69,1082,1083],{"class":79},"1",[69,1085,1086],{"class":89},")); ",[69,1088,1089],{"class":235},"// 1 user online\n",[69,1091,1093,1095,1097,1099,1101,1103,1106,1108],{"class":71,"line":1092},26,[69,1094,220],{"class":89},[69,1096,223],{"class":93},[69,1098,97],{"class":89},[69,1100,1078],{"class":93},[69,1102,97],{"class":89},[69,1104,1105],{"class":79},"2",[69,1107,1086],{"class":89},[69,1109,1110],{"class":235},"// 2 users online\n",[69,1112,1114,1116,1118,1120,1122,1124,1127,1129],{"class":71,"line":1113},27,[69,1115,220],{"class":89},[69,1117,223],{"class":93},[69,1119,97],{"class":89},[69,1121,1078],{"class":93},[69,1123,97],{"class":89},[69,1125,1126],{"class":79},"2000000",[69,1128,1086],{"class":89},[69,1130,1131],{"class":235},"// 2 million users online\n",[26,1133,1134],{"lang":28},[30,1135,1136],{},"Entretanto, algo estranho acontece quando usamos o zero:",[26,1138,1139],{"lang":47},[30,1140,1141],{},"However, something strange happens when we use zero:",[60,1143,1145],{"className":62,"code":1144,"language":64,"meta":65,"style":65},"console.log(userCountText(0)); // 0 users online\n",[34,1146,1147],{"__ignoreMap":65},[69,1148,1149,1151,1153,1155,1157,1159,1162,1164],{"class":71,"line":72},[69,1150,220],{"class":89},[69,1152,223],{"class":93},[69,1154,97],{"class":89},[69,1156,1078],{"class":93},[69,1158,97],{"class":89},[69,1160,1161],{"class":79},"0",[69,1163,1086],{"class":89},[69,1165,1166],{"class":235},"// 0 users online\n",[26,1168,1169,1202],{"lang":28},[30,1170,1171,1172,1175,1176,1181,1182,1184,1185,1187,1188,1191,1192,1194,1195,1198,1199,1201],{},"A realidade é que a especificação do ",[34,1173,1174],{},"CLDR"," sobre ",[707,1177,1180],{"href":1178,"rel":1179},"https://www.unicode.org/cldr/charts/43/supplemental/language_plural_rules.html",[711],"regras de plurais",", em que o ",[34,1183,716],{}," se baseia, considera que ",[34,1186,1161],{}," está dentro de ",[34,1189,1190],{},"one"," para o locale ",[34,1193,28],{}," (como ",[34,1196,1197],{},"pt-BR"," está ausente na lista, os navegadores utilizam ",[34,1200,28],{}," de \"fallback\").",[30,1203,1204,1205,1210,1211,1213,1214,1217,1218,261],{},"Existe uma discussão na língua portuguesa a respeito do ",[707,1206,1209],{"href":1207,"rel":1208},"https://ciberduvidas.iscte-iul.pt/artigos/rubricas/idioma/zero-com-ou-sem-plural/2837",[711],"uso do plural com o 0",", mas ela está fora do escopo desse artigo. Para fazer o ",[34,1212,1161],{}," ser parte da categoria ",[34,1215,1216],{},"other",", você pode utilizar o locale ",[34,1219,1220],{},"pt-PT",[26,1222,1223,1243],{"lang":47},[30,1224,1225,1226,1230,1231,1233,1234,1236,1237,1239,1240,1242],{},"The reality is that the CLDR specification on ",[707,1227,1229],{"href":1178,"rel":1228},[711],"plural rules",", which ",[34,1232,716],{}," is based on, considers that ",[34,1235,1161],{}," is within ",[34,1238,1216],{}," for the ",[34,1241,47],{}," locale.",[30,1244,1245,1246,1250,1251,1253,1254,1256,1257,1259],{},"There's a discussion in Portuguese about the ",[707,1247,1249],{"href":1207,"rel":1248},[711],"use of plurals with 0",", but it's outside the scope of this article. To make ",[34,1252,1161],{}," part of the ",[34,1255,1216],{}," category, you can use the ",[34,1258,1220],{}," locale for Portuguese.",[60,1261,1263],{"className":62,"code":1262,"language":64,"meta":65,"style":65},"const ptBRplural = new Intl.PluralRules(\"pt-BR\");\nconst ptPTplural = new Intl.PluralRules(\"pt-PT\");\n\nconsole.log(ptBRplural.select(0)); // one\nconsole.log(ptPTplural.select(0)); // other\n",[34,1264,1265,1286,1308,1312,1332],{"__ignoreMap":65},[69,1266,1267,1269,1272,1274,1276,1278,1280,1282,1284],{"class":71,"line":72},[69,1268,76],{"class":75},[69,1270,1271],{"class":79}," ptBRplural",[69,1273,83],{"class":75},[69,1275,86],{"class":75},[69,1277,90],{"class":89},[69,1279,821],{"class":93},[69,1281,97],{"class":89},[69,1283,101],{"class":100},[69,1285,214],{"class":89},[69,1287,1288,1290,1293,1295,1297,1299,1301,1303,1306],{"class":71,"line":107},[69,1289,76],{"class":75},[69,1291,1292],{"class":79}," ptPTplural",[69,1294,83],{"class":75},[69,1296,86],{"class":75},[69,1298,90],{"class":89},[69,1300,821],{"class":93},[69,1302,97],{"class":89},[69,1304,1305],{"class":100},"\"pt-PT\"",[69,1307,214],{"class":89},[69,1309,1310],{"class":71,"line":119},[69,1311,140],{"emptyLinePlaceholder":139},[69,1313,1314,1316,1318,1321,1323,1325,1327,1329],{"class":71,"line":130},[69,1315,220],{"class":89},[69,1317,223],{"class":93},[69,1319,1320],{"class":89},"(ptBRplural.",[69,1322,914],{"class":93},[69,1324,97],{"class":89},[69,1326,1161],{"class":79},[69,1328,1086],{"class":89},[69,1330,1331],{"class":235},"// one\n",[69,1333,1334,1336,1338,1341,1343,1345,1347,1349],{"class":71,"line":136},[69,1335,220],{"class":89},[69,1337,223],{"class":93},[69,1339,1340],{"class":89},"(ptPTplural.",[69,1342,914],{"class":93},[69,1344,97],{"class":89},[69,1346,1161],{"class":79},[69,1348,1086],{"class":89},[69,1350,1351],{"class":235},"// other\n",[26,1353,1354,1358],{"lang":28},[263,1355,1357],{"id":1356},"intllistformat","Intl.ListFormat",[30,1359,1360],{},"Formata uma lista, seguindo as regras da língua.",[26,1362,1363,1366],{"lang":47},[263,1364,1357],{"id":1365},"intllistformat-1",[30,1367,1368],{},"Formats a list, following the rules of the language.",[60,1370,1372],{"className":62,"code":1371,"language":64,"meta":65,"style":65},"const formatter = new Intl.ListFormat(\"en\", {\n  type: \"conjunction\",\n});\n\nconst users = [\"John\"];\nconsole.log(formatter.format(users)); // John\n\nusers.push(\"Lennon\");\nconsole.log(formatter.format(users)); // John and Lennon\n\nusers.push(\"Ringo\");\nusers.push(\"George\");\nconsole.log(formatter.format(users)); // John, Lennon, Ringo, and George\n",[34,1373,1374,1397,1407,1411,1415,1433,1450,1454,1469,1484,1488,1501,1514],{"__ignoreMap":65},[69,1375,1376,1378,1381,1383,1385,1387,1390,1392,1395],{"class":71,"line":72},[69,1377,76],{"class":75},[69,1379,1380],{"class":79}," formatter",[69,1382,83],{"class":75},[69,1384,86],{"class":75},[69,1386,90],{"class":89},[69,1388,1389],{"class":93},"ListFormat",[69,1391,97],{"class":89},[69,1393,1394],{"class":100},"\"en\"",[69,1396,104],{"class":89},[69,1398,1399,1402,1405],{"class":71,"line":107},[69,1400,1401],{"class":89},"  type: ",[69,1403,1404],{"class":100},"\"conjunction\"",[69,1406,116],{"class":89},[69,1408,1409],{"class":71,"line":119},[69,1410,133],{"class":89},[69,1412,1413],{"class":71,"line":130},[69,1414,140],{"emptyLinePlaceholder":139},[69,1416,1417,1419,1422,1424,1427,1430],{"class":71,"line":136},[69,1418,76],{"class":75},[69,1420,1421],{"class":79}," users",[69,1423,83],{"class":75},[69,1425,1426],{"class":89}," [",[69,1428,1429],{"class":100},"\"John\"",[69,1431,1432],{"class":89},"];\n",[69,1434,1435,1437,1439,1442,1444,1447],{"class":71,"line":143},[69,1436,220],{"class":89},[69,1438,223],{"class":93},[69,1440,1441],{"class":89},"(formatter.",[69,1443,229],{"class":93},[69,1445,1446],{"class":89},"(users)); ",[69,1448,1449],{"class":235},"// John\n",[69,1451,1452],{"class":71,"line":166},[69,1453,140],{"emptyLinePlaceholder":139},[69,1455,1456,1459,1462,1464,1467],{"class":71,"line":175},[69,1457,1458],{"class":89},"users.",[69,1460,1461],{"class":93},"push",[69,1463,97],{"class":89},[69,1465,1466],{"class":100},"\"Lennon\"",[69,1468,214],{"class":89},[69,1470,1471,1473,1475,1477,1479,1481],{"class":71,"line":184},[69,1472,220],{"class":89},[69,1474,223],{"class":93},[69,1476,1441],{"class":89},[69,1478,229],{"class":93},[69,1480,1446],{"class":89},[69,1482,1483],{"class":235},"// John and Lennon\n",[69,1485,1486],{"class":71,"line":189},[69,1487,140],{"emptyLinePlaceholder":139},[69,1489,1490,1492,1494,1496,1499],{"class":71,"line":194},[69,1491,1458],{"class":89},[69,1493,1461],{"class":93},[69,1495,97],{"class":89},[69,1497,1498],{"class":100},"\"Ringo\"",[69,1500,214],{"class":89},[69,1502,1503,1505,1507,1509,1512],{"class":71,"line":217},[69,1504,1458],{"class":89},[69,1506,1461],{"class":93},[69,1508,97],{"class":89},[69,1510,1511],{"class":100},"\"George\"",[69,1513,214],{"class":89},[69,1515,1516,1518,1520,1522,1524,1526],{"class":71,"line":239},[69,1517,220],{"class":89},[69,1519,223],{"class":93},[69,1521,1441],{"class":89},[69,1523,229],{"class":93},[69,1525,1446],{"class":89},[69,1527,1528],{"class":235},"// John, Lennon, Ringo, and George\n",[26,1530,1531],{"lang":28},[30,1532,1533,1534,892],{},"Para utilizar \"ou\", utilizamos ",[34,1535,1536],{},"type: \"disjunction\"",[26,1538,1539],{"lang":47},[30,1540,1541,1542,892],{},"To use \"or\", we use ",[34,1543,1536],{},[60,1545,1547],{"className":62,"code":1546,"language":64,"meta":65,"style":65},"const formatter = new Intl.ListFormat(\"en\", {\n  type: \"disjunction\",\n});\n\nconst meansOfTransport = [\"Car\", \"Bicycle\", \"Bus\"];\nconsole.log(formatter.format(meansOfTransport)); // Car, Bicycle, or Bus\n",[34,1548,1549,1569,1578,1582,1586,1613],{"__ignoreMap":65},[69,1550,1551,1553,1555,1557,1559,1561,1563,1565,1567],{"class":71,"line":72},[69,1552,76],{"class":75},[69,1554,1380],{"class":79},[69,1556,83],{"class":75},[69,1558,86],{"class":75},[69,1560,90],{"class":89},[69,1562,1389],{"class":93},[69,1564,97],{"class":89},[69,1566,1394],{"class":100},[69,1568,104],{"class":89},[69,1570,1571,1573,1576],{"class":71,"line":107},[69,1572,1401],{"class":89},[69,1574,1575],{"class":100},"\"disjunction\"",[69,1577,116],{"class":89},[69,1579,1580],{"class":71,"line":119},[69,1581,133],{"class":89},[69,1583,1584],{"class":71,"line":130},[69,1585,140],{"emptyLinePlaceholder":139},[69,1587,1588,1590,1593,1595,1597,1600,1603,1606,1608,1611],{"class":71,"line":136},[69,1589,76],{"class":75},[69,1591,1592],{"class":79}," meansOfTransport",[69,1594,83],{"class":75},[69,1596,1426],{"class":89},[69,1598,1599],{"class":100},"\"Car\"",[69,1601,1602],{"class":89},", ",[69,1604,1605],{"class":100},"\"Bicycle\"",[69,1607,1602],{"class":89},[69,1609,1610],{"class":100},"\"Bus\"",[69,1612,1432],{"class":89},[69,1614,1615,1617,1619,1621,1623,1626],{"class":71,"line":143},[69,1616,220],{"class":89},[69,1618,223],{"class":93},[69,1620,1441],{"class":89},[69,1622,229],{"class":93},[69,1624,1625],{"class":89},"(meansOfTransport)); ",[69,1627,1628],{"class":235},"// Car, Bicycle, or Bus\n",[26,1630,1631,1635],{"lang":28},[263,1632,1634],{"id":1633},"intlrelativetimeformat","Intl.RelativeTimeFormat",[30,1636,32,1637,1640],{},[34,1638,1639],{},"RelativeTimeFormat"," permite converter uma unidade em tempo relativo.",[26,1642,1643,1646],{"lang":47},[263,1644,1634],{"id":1645},"intlrelativetimeformat-1",[30,1647,1648,1650],{},[34,1649,1639],{}," allows converting a unit into relative time.",[60,1652,1654],{"className":62,"code":1653,"language":64,"meta":65,"style":65},"const relativeTime = new Intl.RelativeTimeFormat(\"en\");\n\nconsole.log(relativeTime.format(2, \"day\")); // in 2 days\nconsole.log(relativeTime.format(12, \"years\")); // in 12 years\nconsole.log(relativeTime.format(-1, \"week\")); // 1 week ago\n",[34,1655,1656,1677,1681,1706,1731],{"__ignoreMap":65},[69,1657,1658,1660,1663,1665,1667,1669,1671,1673,1675],{"class":71,"line":72},[69,1659,76],{"class":75},[69,1661,1662],{"class":79}," relativeTime",[69,1664,83],{"class":75},[69,1666,86],{"class":75},[69,1668,90],{"class":89},[69,1670,1639],{"class":93},[69,1672,97],{"class":89},[69,1674,1394],{"class":100},[69,1676,214],{"class":89},[69,1678,1679],{"class":71,"line":107},[69,1680,140],{"emptyLinePlaceholder":139},[69,1682,1683,1685,1687,1690,1692,1694,1696,1698,1701,1703],{"class":71,"line":119},[69,1684,220],{"class":89},[69,1686,223],{"class":93},[69,1688,1689],{"class":89},"(relativeTime.",[69,1691,229],{"class":93},[69,1693,97],{"class":89},[69,1695,1105],{"class":79},[69,1697,1602],{"class":89},[69,1699,1700],{"class":100},"\"day\"",[69,1702,1086],{"class":89},[69,1704,1705],{"class":235},"// in 2 days\n",[69,1707,1708,1710,1712,1714,1716,1718,1721,1723,1726,1728],{"class":71,"line":130},[69,1709,220],{"class":89},[69,1711,223],{"class":93},[69,1713,1689],{"class":89},[69,1715,229],{"class":93},[69,1717,97],{"class":89},[69,1719,1720],{"class":79},"12",[69,1722,1602],{"class":89},[69,1724,1725],{"class":100},"\"years\"",[69,1727,1086],{"class":89},[69,1729,1730],{"class":235},"// in 12 years\n",[69,1732,1733,1735,1737,1739,1741,1743,1746,1748,1750,1753,1755],{"class":71,"line":136},[69,1734,220],{"class":89},[69,1736,223],{"class":93},[69,1738,1689],{"class":89},[69,1740,229],{"class":93},[69,1742,97],{"class":89},[69,1744,1745],{"class":75},"-",[69,1747,1083],{"class":79},[69,1749,1602],{"class":89},[69,1751,1752],{"class":100},"\"week\"",[69,1754,1086],{"class":89},[69,1756,1757],{"class":235},"// 1 week ago\n",[26,1759,1760,1788],{"lang":28},[30,1761,1762,1763,1602,1766,1602,1769,1602,1772,1602,1775,1602,1778,1602,1781,1784,1785,261],{},"As unidades possíveis são:\n",[34,1764,1765],{},"year",[34,1767,1768],{},"quarter",[34,1770,1771],{},"month",[34,1773,1774],{},"week",[34,1776,1777],{},"day",[34,1779,1780],{},"hour",[34,1782,1783],{},"minute"," ou ",[34,1786,1787],{},"second",[30,1789,1790],{},"Por padrão, o resultado é sempre númerico, mas você pode permitir o uso de frases idiomáticas:",[26,1792,1793,1813],{"lang":47},[30,1794,1795,1796,1602,1798,1602,1800,1602,1802,1602,1804,1602,1806,1602,1808,1810,1811,261],{},"The possible units are:\n",[34,1797,1765],{},[34,1799,1768],{},[34,1801,1771],{},[34,1803,1774],{},[34,1805,1777],{},[34,1807,1780],{},[34,1809,1783],{},", or ",[34,1812,1787],{},[30,1814,1815],{},"By default, the result is always numeric, but you can allow the use of idiomatic phrases:",[60,1817,1819],{"className":62,"code":1818,"language":64,"meta":65,"style":65},"const relativeTime = new Intl.RelativeTimeFormat(\"en\", {\n  numeric: \"auto\",\n});\n\nconsole.log(relativeTime.format(2, \"day\")); // day after tomorrow\nconsole.log(relativeTime.format(0, \"years\")); // this year\nconsole.log(relativeTime.format(1, \"week\")); // next week\nconsole.log(relativeTime.format(0, \"second\")); // now\n",[34,1820,1821,1841,1851,1855,1859,1882,1905,1928],{"__ignoreMap":65},[69,1822,1823,1825,1827,1829,1831,1833,1835,1837,1839],{"class":71,"line":72},[69,1824,76],{"class":75},[69,1826,1662],{"class":79},[69,1828,83],{"class":75},[69,1830,86],{"class":75},[69,1832,90],{"class":89},[69,1834,1639],{"class":93},[69,1836,97],{"class":89},[69,1838,1394],{"class":100},[69,1840,104],{"class":89},[69,1842,1843,1846,1849],{"class":71,"line":107},[69,1844,1845],{"class":89},"  numeric: ",[69,1847,1848],{"class":100},"\"auto\"",[69,1850,116],{"class":89},[69,1852,1853],{"class":71,"line":119},[69,1854,133],{"class":89},[69,1856,1857],{"class":71,"line":130},[69,1858,140],{"emptyLinePlaceholder":139},[69,1860,1861,1863,1865,1867,1869,1871,1873,1875,1877,1879],{"class":71,"line":136},[69,1862,220],{"class":89},[69,1864,223],{"class":93},[69,1866,1689],{"class":89},[69,1868,229],{"class":93},[69,1870,97],{"class":89},[69,1872,1105],{"class":79},[69,1874,1602],{"class":89},[69,1876,1700],{"class":100},[69,1878,1086],{"class":89},[69,1880,1881],{"class":235},"// day after tomorrow\n",[69,1883,1884,1886,1888,1890,1892,1894,1896,1898,1900,1902],{"class":71,"line":143},[69,1885,220],{"class":89},[69,1887,223],{"class":93},[69,1889,1689],{"class":89},[69,1891,229],{"class":93},[69,1893,97],{"class":89},[69,1895,1161],{"class":79},[69,1897,1602],{"class":89},[69,1899,1725],{"class":100},[69,1901,1086],{"class":89},[69,1903,1904],{"class":235},"// this year\n",[69,1906,1907,1909,1911,1913,1915,1917,1919,1921,1923,1925],{"class":71,"line":166},[69,1908,220],{"class":89},[69,1910,223],{"class":93},[69,1912,1689],{"class":89},[69,1914,229],{"class":93},[69,1916,97],{"class":89},[69,1918,1083],{"class":79},[69,1920,1602],{"class":89},[69,1922,1752],{"class":100},[69,1924,1086],{"class":89},[69,1926,1927],{"class":235},"// next week\n",[69,1929,1930,1932,1934,1936,1938,1940,1942,1944,1947,1949],{"class":71,"line":175},[69,1931,220],{"class":89},[69,1933,223],{"class":93},[69,1935,1689],{"class":89},[69,1937,229],{"class":93},[69,1939,97],{"class":89},[69,1941,1161],{"class":79},[69,1943,1602],{"class":89},[69,1945,1946],{"class":100},"\"second\"",[69,1948,1086],{"class":89},[69,1950,1951],{"class":235},"// now\n",[26,1953,1954],{"lang":28},[30,1955,1956,1957,1959],{},"Entretanto, eu acho a API do ",[34,1958,1639],{}," pequena em relação à quantidade de possibilidades. Eu acho sempre muito difícil trabalhar com Tempo e Duração no Javascript com bibliotecas externas. Novas APIs estão por vir para facilitar essas tarefas, mas isso é assunto para outro post.",[26,1961,1962],{"lang":47},[30,1963,1964,1965,1967],{},"However, I find the ",[34,1966,1639],{}," API small compared to the number of possibilities. I always find it very difficult to work with Time and Duration in JavaScript with external libraries. New APIs are coming to facilitate these tasks, but that's a topic for another post.",[1969,1970,1971],"style",{},"html pre.shiki code .s6ubI, html code.shiki .s6ubI{--shiki-default:#F97583;--shiki-dark:#F97583;--shiki-light:#D73A49}html pre.shiki code .sXWYR, html code.shiki .sXWYR{--shiki-default:#79B8FF;--shiki-dark:#79B8FF;--shiki-light:#005CC5}html pre.shiki code .sAvwS, html code.shiki .sAvwS{--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8;--shiki-light:#24292E}html pre.shiki code .s5n6i, html code.shiki .s5n6i{--shiki-default:#B392F0;--shiki-dark:#B392F0;--shiki-light:#6F42C1}html pre.shiki code .s4Y1p, html code.shiki .s4Y1p{--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF;--shiki-light:#032F62}html pre.shiki code .sxXm1, html code.shiki .sxXm1{--shiki-default:#6A737D;--shiki-dark:#6A737D;--shiki-light:#6A737D}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html pre.shiki code .sAzo5, html code.shiki .sAzo5{--shiki-default:#FFAB70;--shiki-dark:#FFAB70;--shiki-light:#E36209}",{"title":65,"searchDepth":107,"depth":107,"links":1973},[1974,1975,1976,1977,1978,1979,1980,1981],{"id":265,"depth":107,"text":266},{"id":282,"depth":107,"text":266},{"id":715,"depth":107,"text":716},{"id":736,"depth":107,"text":716},{"id":1356,"depth":107,"text":1357},{"id":1365,"depth":107,"text":1357},{"id":1633,"depth":107,"text":1634},{"id":1645,"depth":107,"text":1634},"Converting JavaScript values to text, without needing an external library","Convertendo valores de Javascript em texto, sem a necessidade de uma biblioteca externa","md",{},"/blog/intl-native-javascript","2025-05-01",{"title":21,"description":65},"intl-native-javascript","blog/intl-native-javascript",[1992,1993],"javascript","intl","Intl: Native Solutions for Formatting in JavaScript","Intl: Soluções Nativas para Formatação em JavaScript","ev5dEDc9zldnyFNdvKrd1uplbt0gcZm8Oavd0ZEqR5k",1777685535961]