aboutsummaryrefslogtreecommitdiff
path: root/src/calp.c
diff options
context:
space:
mode:
authorfoswret2026-05-20 12:21:51 -0500
committerfoswret2026-05-20 12:21:51 -0500
commit04fc01ab521abf48cede1e64563fd6276e781b24 (patch)
tree2b41708c80466e20d220171cd087a8b5c48e93ef /src/calp.c
parent879425cba4cc5ba85b15a01423ad6e50f526fec8 (diff)
add LANG support
Diffstat (limited to 'src/calp.c')
-rw-r--r--src/calp.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/calp.c b/src/calp.c
index 3f81aff..8acef9b 100644
--- a/src/calp.c
+++ b/src/calp.c
@@ -3,6 +3,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
+#include <langinfo.h>
+#include <locale.h>
#include <cairo/cairo-pdf.h>
#include <pango/pangocairo.h>
@@ -10,6 +12,7 @@
#include "date.h"
#include "color.h"
#include "image.h"
+#include "ezini.h"
// Metric
#define A4_WIDTH 210
@@ -33,10 +36,27 @@ int main (void) {
width = (width / 25.4) * 72.0;
height = (height / 25.4) * 72.0;
- extern char *months[];
+ //extern char *months[];
+
+
int num_of_months = 12;
+ char *months[num_of_months];
extern int days_in_month[12];
+ const nl_item nl_abmons[12] = {ABMON_1, ABMON_2, ABMON_3, ABMON_4,
+ ABMON_5, ABMON_6, ABMON_7, ABMON_8,
+ ABMON_9, ABMON_10, ABMON_11, ABMON_12};
+ const nl_item nl_months[12] = {MON_1, MON_2, MON_3, MON_4, MON_5, MON_6,
+ MON_7, MON_8, MON_9, MON_10, MON_11, MON_12};
+
+ int i;
+ setlocale(LC_ALL, "");
+ for (i = 0; i < 12; i++) {
+ printf("%d\t%s\t%s\n", i+1, nl_langinfo(nl_abmons[i]), nl_langinfo(nl_months[i]));
+ months[i] = nl_langinfo(nl_months[i]);
+ }
+
+
// Create dimensions struct to hold measurements
struct dimensions dim;
@@ -48,7 +68,7 @@ int main (void) {
// Leap year adjustment: increment February day count by one if
// it is a leap year.
- int year = 3043;
+ int year = 14;
if (isleap(year)) {
days_in_month[1]++;
}
@@ -92,20 +112,9 @@ int main (void) {
// Construction
// ------------
- // Print dimensions, for debugging
-
- if (verbose_output) {
- print_dimensions(&dim);
- }
-
-
- // Range of months to be rendered (Default: Full calendar year, 12 months)
- int first_month = 0;
- int end_month = num_of_months;
-
-
+
// Month generation loop
- for (int i = first_month; i < end_month; i++) {
+ for (int i = 0; i < num_of_months; i++) {
// Initialize month struct
month.first_day = day_of_week(1, i + 1, year);
month.num_of_days = days_in_month[i];
@@ -118,8 +127,8 @@ int main (void) {
cairo_surface_t *header = cairo_surface_create_similar(surface, CAIRO_CONTENT_COLOR_ALPHA, dim.header_width, dim.header_height);
cairo_t *ch = cairo_create(header);
- //set_color(ch, BLUE);
- //fill_bg(ch);
+
+
set_color(ch, BLACK);
draw_month_title(ch, &dim, "Sans", 40, months[i]);