0

I have an app that uses AngularJS along with angular-translate to provide localization. The app currently uses only English and German.

On the login page is a required field, an email. If there is an error, the app displays "A valid email is required" in English.

In German (and forgive me if this is mangled, this is Google Translate, I don't know any German) the phrase is "Eine gültige E-Mail erforderlich".

In the second word, you'll notice an international character, it looks like a "u" with two little dots over it. When the app is set to display in German, that character gets escaped and much weirdness happens on the screen.

Looking that the docs, it seems like using $translateProvider.useSanitizeValueStrategy() is supposed to handle this, but it's not. If I use $translateProvider.useSanitizeValueStrategy('escaped') then it look like this onscreen:

enter image description here

If use $translateProvider.useSanitizeValueStrategy('sanitize')(which I'd really prefer of course) then it looks like this:

enter image description here

I also happened to come across this article which states that my *.js translation file needs to be UTF-8 encoded. I opened up that file in NotePad++, changed the encoding to UTF-8 Without BOM and saved it, but I'm still seeing the error. And VS really hates the file now.

enter image description here

Community
  • 1
  • 1
Todd Davis
  • 5,855
  • 10
  • 53
  • 89

1 Answers1

0

I know, it's a little late, but maybe others have similar Problems:

Adressing the UI:
Are you using the attribute style e.g.

<span translate="key"><span> 

or inline style

<span>{{key | translate}}</span>

in your view?

I am working with the second style without issues.

Addressing your Problem with UTF-8:
I am not using Visual Studio nor Notepad++, so I don't know how Notepad++ handles the conversion. Possibly it does not convert the characters at all, but only changes the file to be seen as UTF-8.

Sublime Text 2 (1), on the other hand, offers you to 'Save with Encoding', which converts all characters accordingly. I stressed this conversion pretty much, so that I can recommend this approach with a clean conscience.


(1) I have no relations to Sublime Text, this is not meant be any form of commercial advertisement

Phe0nix
  • 157
  • 4
  • 15