question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing translation in js code for Angular Material mdToast

See original GitHub issue

Hey !

In my toast factory, I am looking for a string ‘CLOSE’ to put the translation in a toast. My problem is that it is always marked as [MISSING] when the key and value are in my translation json files !

Here is how I proceed :

function logger($log, $mdToast, gettext, gettextCatalog) {
    var close = "CLOSE";
    close = gettextCatalog.getString(close);
    close = gettext(close);

    var service = {
      showToasts: true,
      error: error
    };

    function error(message, data) {
      message = gettext(message);
      $mdToast.show(
        $mdToast
          .simple()
          .textContent(message)
          .theme('error-toast')
          .action(close) // <-- MISSING
          .highlightAction(true)
      );
      $log.error('Error: ' + message, data);
    };
    return service
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
clematorcommented, Oct 6, 2016

OK thanks, I understand now. Good day !

0reactions
rubenvcommented, Oct 6, 2016

Yes.

Mostly you’d do something like:

$scope.something = gettext("Hello");
<span>{{something | translate}}</span>

That’s the best way to do things, since it’ll update the span if the language changes.

Only use gettextCatalog.getString() if you need a translated version to pass it into e.g. a library (such as $mdToast).

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: $translate.use is not a function - Stack Overflow
So i first added the languages en, fr & nl to my app.js file. This is horrible bad practice so i now got...
Read more >
Services > $mdToast - AngularJS Material
$mdToast is a service to build a toast notification on any position on the screen with an optional duration, and provides a simple...
Read more >
Angular(i18n): Missing Translations | by Sujana Pathuri
Everything looks fine, then what are these missing translations? When we are working with angular downloaded examples, git-hub source codes ...
Read more >
Material Design implementation with AngularJS
of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, ... Step 1: Code “Hello World—Angular Material” .
Read more >
angular-material | Yarn - Package Manager
This repository was used to publish the AngularJS Material v1.x library and localized installs using npm . You can find the component source-code...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found