It looks like the other answer on that post you linked topost you linked to is quite relevant. It references hook_menu_alter()
as a tool to:
... add a title callback that will be called every time a link to the menu item will be rendered
However, I'm not sure if that solution would work for manually-created menu links items with custom title text. The other, possibly more universal, option that I can think of is using hook_menu_link_alter()
along with hook_translated_menu_link_alter()
. The former is used to "flag" a link as alterable (when the link is saved), and the latter is used to actually alter it (at render time).
Actually, it looks like this postthis post covers both these options in even more detail, so I won't repeat any of their code samples here.
This distinction about which alter hooks fire at save/cache-clear time vs. render time is important as it often means that you have to leverage a hook + callback, or 2 hooks, to implement dynamic alterations. For example, if you choose the second option you use hook_menu_link_alter()
to declare the link as alterable, and though that hook does not fire each time the link is rendered, it "registers" the fact that hook_translated_menu_link_alter()
should in fact be called at render time for that specific link.