use of com.squarespace.cldr.units.MeasurementSystem in project template-compiler by Squarespace.
the class UnitsMetricPredicate method apply.
@Override
public boolean apply(Context ctx, Arguments arguments) throws CodeExecuteException {
CLDR.Locale locale = ctx.cldrLocale();
if (locale == null) {
return true;
}
String category = (String) arguments.getOpaque();
if (category == null) {
return true;
}
UnitConverter converter = CLDR_INSTANCE.getUnitConverter(locale);
MeasurementSystem system = converter.measurementSystem();
switch(category) {
case "consumption":
case "length":
case "liquid":
case "mass":
case "speed":
case "volume":
return system == METRIC || system == METRIC_WITH_US_TEMPERATURE;
case "temperature":
return system == METRIC || system == US_WITH_METRIC_TEMPERATURE;
default:
break;
}
return true;
}
Aggregations