[Github-comments] [geany/geany] Use a format string instead of repeating almost the same string 9 times (#1058)

Colomban Wendling notifications at xxxxx
Wed Jul 6 20:57:02 UTC 2016


> Another way might be like:
> 
> ```c
#define ADD_KB_CUSTOM_COMMAND(n, key, mod) \
	add_kb(group, GEANY_KEYS_FORMAT_SENTOCMD##n, NULL, key, mod, \
		"edit_sentocmd"#n, _("Send to Custom Command "#n), NULL)
```

That's not acceptable, because translators need to be able to move the number if needed.

> Alternatively, we could use `g_intern_string()` which will copy the given string, then we can free our formatted one, to avoid "leaking" it

Mmyeah, not really different, but indeed.

> Not sure it's a worthwhile improvement. It replaces one line with another (although shorter) one but adds the macro. plus having to malloc.

Me neither.  It actually looks kinda ugly to me, that's why I PRd it for opinions.  The advantage is that ther's then only 1 translation instead of 9, but the code here isn't very nice, and the translations now already exist, so…

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/1058#issuecomment-230904073
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20160706/1323be1b/attachment.html>


More information about the Github-comments mailing list