private static String getDistance(final float farDistance, final int nearDistance,
                                      final float farFarAway, final float farNearAway, final int nearFarAway,
                                      @PluralsRes final int farId, @StringRes final int farOneId, @PluralsRes final int nearId, @StringRes final int nearOneId) {
        if (farDistance >= farFarAway) {
            // example: "5 kilometers" - always without decimal digits
            final int quantity = Math.round(farDistance);
            if (quantity == 1) {
                return getString(farOneId, quantity, String.valueOf(quantity));
            }
            return getQuantityString(farId, quantity, String.valueOf(quantity));
        }
        if (farDistance >= farNearAway) {
            // example: "2.2 kilometers" - decimals if necessary
            final float precision1 = Math.round(farDistance * 10.0f) / 10.0f;
            final float precision0 = Math.round(farDistance);
            if (Math.abs(precision1 - precision0) < 0.0001) {
                // this is an int - e.g. 2 kilometers
                final int quantity = (int) precision0;
                if (quantity == 1) {
                    return getString(farOneId, quantity, String.valueOf(quantity));
                }
                return getQuantityString(farId, quantity, String.valueOf(quantity));
            }
            // this is no int - e.g. 1.7 kilometers
            final String digits = String.format(Locale.getDefault(), "%.1f", farDistance);
            // always use the plural (9 leads to plural)
            return getQuantityString(farId, 9, digits);
        }
        // example: "34 meters"
        int quantity = nearDistance;
        if (quantity > nearFarAway) {
            // example: "120 meters" - rounded to 10 meters
            quantity = (int) Math.round(quantity / 10.0) * 10;
        }
        if (quantity == 1) {
            return getString(nearOneId, quantity, String.valueOf(quantity));
        }
        return getQuantityString(nearId, quantity, String.valueOf(quantity));
    }
Creates the output to be read by TTS.
<br>
Note: some languages need to read "one hour" as "a hour" (indefinite article). Also, other languages
use the <tt>quantity="1"</tt> plurals rule for other values than 1, such as Slovenian, so it is not
possible to store the literal value to use for 1 in this rule. For this reason, we need to have one
string for the unit quantity ("one meter") and a plurals rule for everything else.
<br>
See <a href="http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html">...</a> for rules
on unit expressions.
main/src/main/java/cgeo/geocaching/speech/TextFactory.java