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

Providing missingTranslationHandler() same flexibility as useStorage() #45

Closed
0x-r4bbit opened this issue May 13, 2013 · 10 comments
Closed
Assignees
Milestone

Comments

@0x-r4bbit
Copy link
Member

Missing translation handler should be injectable as well!

Default behavior should be changed. Currently I have to do something like this, to avoid logging:

$translateProvider.missingTranslationHandler(function (translationId) {
    return;
});
@ghost ghost assigned 0x-r4bbit May 13, 2013
@knalli
Copy link
Member

knalli commented May 13, 2013

  1. What about a chain/list of handlers?
  2. What about a similar list of handlers for success? Currently, this is a $rootScope broadcast.

@0x-r4bbit
Copy link
Member Author

For example?

@knalli
Copy link
Member

knalli commented May 13, 2013

Example for what? :)

@0x-r4bbit
Copy link
Member Author

It'd be great to get more details on what you've posted.

@knalli
Copy link
Member

knalli commented May 13, 2013

Just brainstorming.

1. Instead of one single failure handler, it could be list of handlers.
Reason 1: Currently we cannot use our own failure handler (apart from simple $log) because of same reasons like success (see down). Reason 2: Currently different independent handlers must be implemented in one single.

We can add another api or just extend this one to be optional adding (default replace just like before)

  this.missingTranslationHandler = function (functionHandler, noReplace) {
    if (angular.isUndefined(noReplace) || !noReplace) {
      if (angular.isUndefined(functionHandler)) {
        return $missingTranslationHandlers[0];
      }
      $missingTranslationHandlers = [functionHandler];
    } else {
      if (!angular.isUndefined(functionHandler) && functionHandler === true) {
        return $missingTranslationHandlers;
      } else {
        $missingTranslationHandlers.push(functionHandler);
      }
    }

// supporting
function fn() {}
equals([], missingTranslationHandler(true));
equals(undefined, missingTranslationHandler());
missingTranslationHandler(fn);
equals(fn, missingTranslationHandler());
equals([fn], missingTranslationHandler(true));
missingTranslationHandler(fn, true);
equals(fn, missingTranslationHandler());
equals([fn, fn], missingTranslationHandler(true));

* 2. Just like missingTranslationHandler, but for success.*

Before:

    $rootScope.$broadcast('translationChangeSuccess');

After:

    $successTranslationChangeHandler();

(Ore even a list because we will actually relay on that broadcast).

@knalli
Copy link
Member

knalli commented May 13, 2013

@PascalPrecht Gotcha. Renaming a project while commenting isn't supported by Github. No redirect, only an error ;)

@knalli
Copy link
Member

knalli commented May 13, 2013

Oh no wait.. the mail link is broken.

@0x-r4bbit
Copy link
Member Author

This is of course a pretty cool approach of handling several handlers for errors and success, but I'm not sure if this is currently really required.

If you want to, you can go ahead and implement this in canary. Otherwise, I'd just implement something like useMissingTranslationHandle('serviceString') or so, since this is currently totally enough.

@0x-r4bbit 0x-r4bbit mentioned this issue May 14, 2013
29 tasks
@0x-r4bbit
Copy link
Member Author

Implemented this in f6ed3e3

Will merge it into master later today. Last chance to review!

@0x-r4bbit
Copy link
Member Author

Landed in master.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants