Skip to content
This repository was archived by the owner on Jan 29, 2024. It is now read-only.
This repository was archived by the owner on Jan 29, 2024. It is now read-only.

"custom error Handler" invoked three times for each translate directive  #1616

Open
@fmunafo

Description

@fmunafo

Why custom handler function is invoked three times using translateas attribute and six times using translateas element (three for the element and three for the attribute)?

(I've also noticed that with translate 2.10.0 it happens 4 and 8 times)

Thanks,
Filippo

<!doctype html>
<html ng-app="myApp">
  <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-translate/2.12.1/angular-translate.js"></script>
  </head>
  <body>

    <div>
      <p translate="test_id_1"></p>
      <translate translate="test_id_2"></translate>
    </div>

    <script>
      var translations = {};

      var app = angular.module('myApp', ['pascalprecht.translate']);

      app.config(['$translateProvider', function ($translateProvider) {
        // add translation table
        $translateProvider
          .translations('en', translations)
          .useMissingTranslationHandler('myCustomHandlerFactory')
      }]);

      app.factory('myCustomHandlerFactory', function () {
        return function (translationID, uses) {
          if (translationID == "test_id_1") {
            console.log("handler per " + translationID);
            return 'NO VALUE FOR test_id_1';
          } else {
            console.log("handler per " + translationID);
            return 'NO VALUE FOR test_id_2';
          }
        };
      });  
    </script>
  </body>
</html>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions