Missing Translations

If a translation on a specific locale is missing, by default Transifex Native will return the string in the source language. However, you can change that behaviour by providing a different missing policy.

Source String

This is the default policy, where the source string will appear when a translation is missing.

TRANSIFEX_MISSING_POLICY = 'transifex.native.rendering.SourceStringPolicy'
# _t("Hello, friend") -> returns "Hello, friend"

Pseudo Translation

This is a nice way to do translation QA during development, as pseudo-translated strings stand out and are easy to identify.

TRANSIFEX_MISSING_POLICY = 'transifex.native.rendering.PseudoTranslationPolicy'
# _t("Hello, friend") -> returns "Ȟêĺĺø, ƒȓıêñđ"

It's advised that you do that only for your development environment, as you probably don't want to show pseudo translations to your actual users on production.

Source String Inside Brackets

Another way to show that a string is α placeholder text is to show it wrapped around some symbols.

TRANSIFEX_MISSING_POLICY = (
    'transifex.native.rendering.WrappedStringPolicy',
    {'start': '[', 'end': ']'},
)
# _t("Hello, friend") -> returns "[Hello, friend]"

Source String with Extra Characters

Translations in some locales are typically longer than in English. This policy allows you to do QA for your UI during development and make sure that longer strings can be accommodated by your current UI elements.

TRANSIFEX_MISSING_POLICY = (
    'transifex.native.rendering.WrappedStringPolicy',
    {'extra_percentage': 0.5, 'extra_str': '~#'},
)
# _t("Hello, friend") -> returns "Hello, friend~#~#~#"

A Complex Policy

You can also combine multiple policies to get a result that stands out even more visually and also supports features like extra length or something custom you might want.

Simply set the policy to a list, with each item being a tuple of a string, depending on whether or not it needs parameters:

TRANSIFEX_MISSING_POLICY = [
    'transifex.native.rendering.PseudoTranslationPolicy',
    (
        'transifex.native.rendering.ExtraLengthPolicy',
        {'extra_percentage': 0.5},
    ),
    (
        'transifex.native.rendering.WrappedStringPolicy',
        {'start': '{', 'end': '}'},
    )
]
# _t("Hello, friend") -> returns "{Ȟêĺĺø, ƒȓıêñđ~extra~}"

Custom Policy

You can easily create your own policy:

TRANSIFEX_MISSING_POLICY = (
    'myapp.module_name.MyMissingPolicy',
    {'param1': 'value1', 'param2': 'value2'},
)
# _t("Hello, friend") -> returns a custom string