Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breadcrumb label translations support #65

Open
jamhall opened this issue Dec 18, 2014 · 9 comments
Open

Breadcrumb label translations support #65

jamhall opened this issue Dec 18, 2014 · 9 comments
Labels

Comments

@jamhall
Copy link

jamhall commented Dec 18, 2014

Hi!

First of all, great module!

It would be nice if this module supported translations for the breadcrumbs labels.

It could be passed in as an extra option to enable it:

myAppModule.config(function($breadcrumbProvider) {
    $breadcrumbProvider.setOptions({
      translations: true
    });
  })

What are your thoughts?

I would happily implement it if you'd like... Of course I'd make sure that the dependency for the angular-translate module is optional.

@ncuillery
Copy link
Owner

I suppose you have in mind to translate the labels containing translate keys programmatically if the options is set to true, right ?

How about using a custom template like this ?

<ol class="breadcrumb">
  <li ng-repeat="step in steps" ng-class="{active: $last}" ng-switch="$last || !!step.abstract">
    <a ng-switch-when="false" href="{{step.ncyBreadcrumbLink}}">{{step.ncyBreadcrumbLabel | translate}}</a>
    <span ng-switch-when="true">{{step.ncyBreadcrumbLabel | translate}}</span>
  </li>
</ol>

@andresalves
Copy link

ncuillery. Very good

@egel
Copy link

egel commented Feb 10, 2015

I like this version of breadcrumbs template with support of translations (written in Jade):

ol.breadcrumb
  li(ng-repeat="step in steps | limitTo:(steps.length-1)")
    a(href="{{step.ncyBreadcrumbLink}}" ng-bind-html="step.ncyBreadcrumbLabel | translate")
  li.active(ng-repeat="step in steps | limitTo:-1")
    span(ng-bind-html="step.ncyBreadcrumbLabel | translate")

@ncuillery
Copy link
Owner

@jamhall I'm not very kind of this option. I prefer keep the API simple and let users making a custom template.

I think I'll make a FAQ wiki page. I keep the issue open to remember to add an entry for angular-translate integration.

@jamhall
Copy link
Author

jamhall commented Mar 22, 2015

I'm happy with the solution offered above :-).

Thanks

@jamhall jamhall closed this as completed Mar 22, 2015
@ncuillery
Copy link
Owner

I keep the issue open to remember to add an entry for angular-translate integration.

So don't close it please ;-)

@goliney
Copy link

goliney commented Jun 24, 2015

@ncuillery I tried custom template like you suggested, but it only works after I move to another state. On initial load my breadcrumbs are not translated. Any suggestions how to fix it?

@GitYouss
Copy link

Hi there,

I was in the very same case as you did @goliney, I found this on Stack Overflow and it worked like a charm:

http://stackoverflow.com/questions/30292000/gettext-module-in-angularjs-does-does-not-translate-gettextcatalog-getstring-i

Basically (quoted from Stack Overflow):

Anything that goes on the scope shouldn't use gettextCatalog.getString.

Use something like this:

$rootScope.stepText = gettext("My step 1 title");
And in the view:

{{stepText | translate}}

@arielcr
Copy link

arielcr commented Jun 27, 2016

Hi there,

Nice solution! I was wondering what about variable replacement in translate filter. I've already tried passing some random text, and it works pretty fine, but I need is to specify a variable, not some static text, for example:

<a ng-switch-when="false" href="{{step.ncyBreadcrumbLink}}">{{step.ncyBreadcrumbLabel | translate:"{entity:variable}"}}</a>

I tried accessing a scope variable, but then I realized that I cannot access the rootScope or scope data inside .config. Maybe some provider that I can access in .config?

Has anybody run through this also?

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

No branches or pull requests

7 participants