* Returns a localized representation of the given length measurement. * @param {Number} meters * @param {Boolean} isImperial true for U.S. customary units; false for metric * @return {string} Text to display
(meters, isImperial)
| 709 | * @return {string} Text to display |
| 710 | */ |
| 711 | displayLength(meters, isImperial) { |
| 712 | const locale = this._currLocaleCode; |
| 713 | let n = meters * (isImperial ? 3.28084 : 1); |
| 714 | let unit; |
| 715 | |
| 716 | if (isImperial) { |
| 717 | if (n >= 5280) { |
| 718 | n /= 5280; |
| 719 | unit = 'miles'; |
| 720 | } else { |
| 721 | unit = 'feet'; |
| 722 | } |
| 723 | } else { |
| 724 | if (n >= 1000) { |
| 725 | n /= 1000; |
| 726 | unit = 'kilometers'; |
| 727 | } else { |
| 728 | unit = 'meters'; |
| 729 | } |
| 730 | } |
| 731 | |
| 732 | return this.t(`units.${unit}`, { |
| 733 | quantity: n.toLocaleString(locale, { maximumSignificantDigits: 4 }) |
| 734 | }); |
| 735 | } |
| 736 | |
| 737 | |
| 738 | /** |
no test coverage detected