diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/labelwidget.c | 24 | ||||
-rw-r--r-- | src/ui/window.c | 12 |
2 files changed, 7 insertions, 29 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) { |
diff --git a/src/ui/window.c b/src/ui/window.c index 2d1deb72..d27d252b 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -1055,12 +1055,12 @@ static void setupUserInterface_Window(iWindow *d) { | |||
1055 | setAlignVisually_LabelWidget(navMenu, iTrue); | 1055 | setAlignVisually_LabelWidget(navMenu, iTrue); |
1056 | setId_Widget(addChildFlags_Widget(navBar, iClob(navMenu), collapse_WidgetFlag), "navbar.menu"); | 1056 | setId_Widget(addChildFlags_Widget(navBar, iClob(navMenu), collapse_WidgetFlag), "navbar.menu"); |
1057 | #else | 1057 | #else |
1058 | insertMenuItems_MacOS("File", 1, fileMenuItems_, iElemCount(fileMenuItems_)); | 1058 | insertMenuItems_MacOS("${menu.title.file}", 1, fileMenuItems_, iElemCount(fileMenuItems_)); |
1059 | insertMenuItems_MacOS("Edit", 2, editMenuItems_, iElemCount(editMenuItems_)); | 1059 | insertMenuItems_MacOS("${menu.title.edit}", 2, editMenuItems_, iElemCount(editMenuItems_)); |
1060 | insertMenuItems_MacOS("View", 3, viewMenuItems_, iElemCount(viewMenuItems_)); | 1060 | insertMenuItems_MacOS("${menu.title.view}", 3, viewMenuItems_, iElemCount(viewMenuItems_)); |
1061 | insertMenuItems_MacOS("Bookmarks", 4, bookmarksMenuItems_, iElemCount(bookmarksMenuItems_)); | 1061 | insertMenuItems_MacOS("${menu.title.bookmarks}", 4, bookmarksMenuItems_, iElemCount(bookmarksMenuItems_)); |
1062 | insertMenuItems_MacOS("Identity", 5, identityMenuItems_, iElemCount(identityMenuItems_)); | 1062 | insertMenuItems_MacOS("${menu.title.identity}", 5, identityMenuItems_, iElemCount(identityMenuItems_)); |
1063 | insertMenuItems_MacOS("Help", 7, helpMenuItems_, iElemCount(helpMenuItems_)); | 1063 | insertMenuItems_MacOS("${menu.title.help}", 7, helpMenuItems_, iElemCount(helpMenuItems_)); |
1064 | #endif | 1064 | #endif |
1065 | } | 1065 | } |
1066 | /* Tab bar. */ { | 1066 | /* Tab bar. */ { |