diff options
Diffstat (limited to 'src/ui/labelwidget.c')
-rw-r--r-- | src/ui/labelwidget.c | 24 |
1 files changed, 1 insertions, 23 deletions
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c index c3bc4392..0becd419 100644 --- a/src/ui/labelwidget.c +++ b/src/ui/labelwidget.c | |||
@@ -359,29 +359,7 @@ void updateSize_LabelWidget(iLabelWidget *d) { | |||
359 | } | 359 | } |
360 | 360 | ||
361 | static void replaceVariables_LabelWidget_(iLabelWidget *d) { | 361 | static void replaceVariables_LabelWidget_(iLabelWidget *d) { |
362 | for (const char *label = cstr_String(&d->label); *label; ) { | 362 | translate_Lang(&d->label); |
363 | iRangecc id; | ||
364 | id.start = strstr(label, "${"); | ||
365 | if (!id.start) { | ||
366 | break; | ||
367 | } | ||
368 | id.start += 2; | ||
369 | id.end = strchr(id.start, '}'); | ||
370 | iAssert(id.end != NULL); | ||
371 | /* TODO: Add a lookup that doesn't allocate anything; Lang can handle it. */ | ||
372 | const size_t len = size_Range(&id); | ||
373 | char *key = malloc(len + 1); | ||
374 | memcpy(key, id.start, len); | ||
375 | key[len] = 0; | ||
376 | const char *text = cstr_Lang(key); | ||
377 | const size_t textLen = strlen(text); | ||
378 | free(key); | ||
379 | /* Replace it. */ | ||
380 | size_t startPos = id.start - cstr_String(&d->label) - 2; | ||
381 | remove_Block(&d->label.chars, startPos, len + 3); | ||
382 | insertData_Block(&d->label.chars, startPos, text, textLen); | ||
383 | label = cstr_String(&d->label) + startPos + textLen; | ||
384 | } | ||
385 | } | 363 | } |
386 | 364 | ||
387 | void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) { | 365 | void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) { |