question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tc decimal handling

See original GitHub issue

vue & vue-i18n version vue 2.6.8 vue-i18n 8.11.2

Steps to reproduce

  {{ $tc('daysCounter', days, {count: days}) }}


  i18n: {
    messages: {
   daysCounter: ' 0 jour | {count} jour | {count} jours'
   }
}

What is Expected? if days is 0.5 or 1.5 the singular option should be selected and output ‘0.5 jour’ or ‘1.5 jour’

What is the result? vue-i18n displays ‘0 jours | 0.5 jour | 0.5 jours’

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

3reactions
exoegocommented, Aug 2, 2019

I think $tc should warn if it received a non-int value (float, string, array or whatever). Warning like $tc's second argument should be int but ... given. If you want to pass non-int number to the chosen message, consider $tc(messageKey, round(f), {count: f}) so that we can avoid confusing like this situation.

I think we can add int-ness check and warning around inside the below https://github.com/kazupon/vue-i18n/blob/6ffc60190d4d7910964186fd3904b77fd422a399/src/index.js#L517-L525

3reactions
exoegocommented, Aug 2, 2019

This is because $tc’s second argument is supposed to be a index to choose message from case of 0 | 1 | 2 and more, so it must be int right now.

I think you may get expcted result if you round or ceil before passing days to $tc I made an example of that: http://jsfiddle.net/5mxgauwf/1/

Read more comments on GitHub >

github_iconTop Results From Across the Web

tc(8) - Linux manual page
Tc is used to configure Traffic Control in the Linux kernel. ... Processing of traffic is controlled by three kinds of objects: qdiscs,...
Read more >
Measurement Difference in decimal place in NX12 and ...
In NX12 , we are able to display multiple decimal places. After import to TC, TC only shows 2 decimal place.
Read more >
Town Creator - Decimal Game (Place value & Rounding)
An Online game to practice decimal place value and decimal rounding.
Read more >
Fanuc Series Oi-TC - numbers displayed after decimal place
ANYWAY, "we" were finally able to change the parameter to set the control to a 4-place decimal display. I actually gave the info...
Read more >
Set variables' output format
%-tC. %-td date. %-td etc. There are many variations allowed. ... set dp sets the symbol that Stata uses to represent the decimal...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found