from functools import partial
from ploneintranet.core import _


def i18n_translate(message, default):
    """A helper function to make sure Lingua picks up our messages.

    To be used as: pot-create --keyword=i18n_translate
    """
    return partial(_, message, default)


def message_variant(message_without_text, message_with_text):
    """Construct a single callable for two related message variants."""

    def chooser(mapping, show_text):
        return (
            message_with_text(mapping=mapping)
            if show_text
            else message_without_text(mapping=mapping)
        )

    return chooser
