turquoiseowl / i18n

Smart internationalization for ASP.NET
Other
556 stars 156 forks source link

Translation in AngularJS #264

Closed andreasmeer closed 8 years ago

andreasmeer commented 8 years ago

I have a AngularJS App, the translations in the controllers function properly. The translations in the Template Views (html files) are not displayed. Is there a solution ? Here the white and black list in the web.config.

Sorry for my terrible English.

turquoiseowl commented 8 years ago

Hmm, I can't think that there should be a particular problem with Angular, although haven't tested it myself.

Have you tried looking in the Network tab of the web browser debugger to see what is in the responses? What precisely are you getting e.g. are you getting raw nuggets with nugget markup?

andreasmeer commented 8 years ago

The views are displayed without [[[]]], html: <a href="#/addartist" class="btn btn-circle btn-default"> <i class="fa fa-plus"></i> [[[Neuer Künstler]]] </a>

Chrome Network: <a href="#/addartist" class="btn btn-circle btn-default"> <i class="fa fa-plus"></i> Neuer Künstler </a>

turquoiseowl commented 8 years ago

The fact that the nugget-markup is being stripped suggests i18n is working okay.

Would you show what the URLs are: for the initial html resource request and any subsequent requests made by angular for the template html resource.

andreasmeer commented 8 years ago

I have a small Angular app created and is releasing on GitHub . Here the texts are in the Navigation Translated , but as with my Great Application the html views not .

https://github.com/StromKreis/angular-i18n-test

chrismeistre commented 8 years ago

I am experiencing the same issue.

In a AngularJS controller I have the following code: $scope.title = "[[[Upload Boundaries]]]";

This gets used in a View with the following code: <span>{{$title}}</span>

The resulting HTML is: <span>Upload Boundaries</span>

postBuild.exe does not seem to pick up the [[[Upload Boundaries]]] in AngularJS controller file. I can see this from the section within messages.po where it picks it up in other files.

All other translations within the View's HTML are working.

So it appears to be picking up the [[[ and ]]] because it is removing them. But it's not doing the actual translation.

turquoiseowl commented 8 years ago

Would you confirm the encoding of the JS file containing the Angular controller. If it isn't UTF-8 can you try that?

chrismeistre commented 8 years ago

It was encoded as UTF-8-BOM as per Notepad++.

I have now saved it as UTF-8, rebuilt, and the same still happens.

turquoiseowl commented 8 years ago

To confirm then:

  1. You have a UTF-8 JS file included your project tree and you run PostBuild and it fails to detect nuggets in that file i.e. corresponding entries for those nuggets in that JS file are NOT added to the locale/messages.pot file?
  2. You have another UTF-8 JS file included in your tree and PostBuild DOES pick up the nuggets in that file i.e. entries for them are added to messages.pot?
  3. The only obvious difference between the JS files 1. and 2. is that 1. has angular code and 2. doesn't?
chrismeistre commented 8 years ago

Your mention of the directory tree made me recheck the web.config file.

Turns out if I whitelist *.js as well, the postBuild now picks up the placeholder in the controller file and puts it in the messages.pot file. I just assumed if I didn't blacklist it, it would be checked.

So all works as intended. Thank you for taking the time to respond. My apologies for wasting your time.

turquoiseowl commented 8 years ago

No problem, I'm glad it works.

andreasmeer commented 8 years ago

If the language is given with the calling of a Angular Views, the languages ​​are loaded correctly . :)

Now it's working. :D