Skip to content

Instantly share code, notes, and snippets.

@theosp
Last active August 29, 2015 14:10
Show Gist options
  • Save theosp/40175bb969604fc40276 to your computer and use it in GitHub Desktop.
Save theosp/40175bb969604fc40276 to your computer and use it in GitHub Desktop.
tap:i18n feature proposal 1: TAPi18n.loadTranslations

Please comment on this proposal here

TAPi18n.loadTranslations(translations, namespace="project") (Anywhere)

Use translations in addition or instead of the translations defined in the i18n.json files. Translations defined by loadTranslations will have priority over those defined in language files (i18n.json) of namespace (the project, or package name).

To enjoy the benefits of tap:i18n, you should use language files to internationalize your project whenever you can.

Legitimate cases for addTranslations are: allowing users to change the project translations, changing translations of 3rd party packages that you don't want to fork (see the Note below).

Example:

TAPi18n.loadTranslations({
    {
        es: {
            meteor_status_waiting: "Desconectado,"
        },
        fr: {
            meteor_status_failed: "La connexion au serveur a échoué"
        }
    },
    "francocatena:status"
})

Arguments:

  • translations: An object of the following format:
{
    'lang-tag': {
        'translation-key1': 'translation',
        'translation-key2': 'translation',
        ...
    },
    ...
}
  • namespace="project": The namespace you want to add the translations to. by default translations are added to the project namespace, if you want to change a package translation use the package name as the namespace like the above example.

Note: If you want to add a new language to a 3rd pary package (and you can't get it's owner to merge your pull request) consider introducing a "translation" package in which package-tap.i18n has the "namespace" options set to the package you are translating. That way you can translate with languages files instead of addTranslations and share your translation package with others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment