manekinekko / angular2-drupal

4 stars 1 forks source link

Localization #3

Open manekinekko opened 8 years ago

manekinekko commented 8 years ago

One of Drupal's big features is localization, and so we want the labels, buttons, etc. to appear in a visitor's proper language. Drupal provides a PHP function (t()), a JS function (Drupal.t()), and a Twig filter (|t) to localize UI text. If this project wants to render any UI text through some other means, it needs to integrate it with one of these.

Dedicated Drupal thread https://github.com/acquia/js-exploration/issues/4

Elecash commented 8 years ago

Reading some documentation on JS files I've found this:

/**
 * Variable generated by Drupal that holds all translated strings from PHP.
 *
 * Content of this variable is automatically created by Drupal when using the
 * Interface Translation module. It holds the translation of strings used on
 * the page.
 *
 * This variable is used to pass data from the backend to the frontend. Data
 * contained in `drupalSettings` is used during behavior initialization.
 *
 * @global
 *
 * @var {object} drupalTranslations
 */

But it seems that drupalTranslations is always undefined. I think that something must be wrong with my setup.

You can find this docs in this file: https://github.com/manekinekko/angular2-drupal/blob/master/core/misc/drupal.js#L17

wimleers commented 8 years ago

You need to install the locale module and add additional languages.

If you'd instead base this off of https://github.com/acquia/js-exploration/tree/js-exploration-base, you'd get all of that set up automatically for you.