===================
Expanding templates
===================

PEP 292 defines a simplified string template, where substitution variables are
identified by a leading $-sign.  The substitution dictionary names the keys
and values that should be interpolated into the template.  string.Template
uses ** keyword arguments, but Python requires that ** dictionaries have str
keys.   Specifically, the keys may not be unicodes.

For our purposes they keys should always be ascii, so this helper ensures that
the keys are of str type.

    >>> key_1 = 'key_1'
    >>> key_2 = 'key_2'

The repr of the keys shows that they are unicodes.

    >>> key_1
    u'key_1'
    >>> key_2
    u'key_2'

The substitution still works.

    >>> from flufl.i18n import expand
    >>> print expand(
    ...     '$key_2 is different than $key_1', {
    ...         key_1: 'the first key',
    ...         key_2: 'the second key',
    ...         })
    the second key is different than the first key
