Question

I'm using RRDtool through a Perl script (RRDs) to visualize temperature readings. As I want everything in the graph to be shown in Swedish (weekdays etc), I set the locale to sv_SE.UTF-8 in my Perl script with:

use POSIX qw(locale_h);
setlocale(LC_ALL, "sv_SE.UTF-8");

RRDtool gets this, and prints weekday names in Swedish. However, numerical values that are written under the RRDtool graph with GPRINT use dots instead of commas as decimal separators (XX.xx), and I'm not sure why. In Swedish, commas should be used (XX,xx). I use GPRINT like this:

GPRINT:temp_out:MIN: Min\\: %6.1lf

I've tried setting LC_NUMERIC and LC_CTYPE to sv_SE.UTF-8 as well, but without result. I've tried using sv_SE.iso8859-1, but no go. I've also read various printf documentation, but have yet to come up with a solution.

Has anyone managed to make RRDtool use commas instead of dots as decimal separators? Thanks!

Edit:

If I create the graph using rrdtool graph at the command line and have set LC_NUMERIC=sv_SE, I get commas as decimal separators. This leads me to believe that my Perl script doesn't pick up on my setlocale. Still investigating...

Was it helpful?

Solution

rrdtool is actually forcing LC_NUMERIC in multiple places to 'C' in order to prevent stray commas from showing up in odd places ...

to see commas in generated charts, one would have to enhance this logic a bit further in rrd_graph.c to explicitly re-enable the users original LC_NUMERIC setting prior to rendering GPRINT statements.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top