use of com.squarespace.cldrengine.api.DecimalFormatOptions in project template-compiler by Squarespace.
the class DecimalFormatter method apply.
@Override
public void apply(Context ctx, Arguments args, Variables variables) throws CodeExecuteException {
Variable var = variables.first();
Decimal number = GeneralUtils.nodeToDecimal(var.node());
if (number == null) {
var.setMissing();
return;
}
CLDR cldr = ctx.cldr();
DecimalFormatOptions opts = (DecimalFormatOptions) args.getOpaque();
String result = cldr.Numbers.formatDecimal(number, opts);
var.set(result);
}
use of com.squarespace.cldrengine.api.DecimalFormatOptions in project template-compiler by Squarespace.
the class DecimalFormatter method validateArgs.
@Override
public void validateArgs(Arguments args) throws ArgumentsException {
DecimalFormatOptions opts = OptionParsers.decimal(args);
args.setOpaque(opts);
}
use of com.squarespace.cldrengine.api.DecimalFormatOptions in project template-compiler by Squarespace.
the class MessageFormats method decimal.
/**
* Number / decimal message formatter.
*/
private String decimal(List<Object> args, List<String> options) {
if (args.isEmpty()) {
return "";
}
JsonNode node = (JsonNode) args.get(0);
if (node == null) {
return "";
}
Decimal value = this.converter.asDecimal(node);
DecimalFormatOptions opts = OptionParsers.decimal(options);
return cldr.Numbers.formatDecimal(value, opts);
}
use of com.squarespace.cldrengine.api.DecimalFormatOptions in project template-compiler by Squarespace.
the class OptionParsers method decimal.
public static DecimalFormatOptions decimal(List<String> args) {
DecimalFormatOptions options = new DecimalFormatOptions();
parse(args, options, OptionParsers::decimalOption);
return options;
}
Aggregations