Google Translate messes up Font Awesome Icons

早过忘川 提交于 2019-12-13 16:53:23

问题


I use font awesome icons on my website. (http://fortawesome.github.io/Font-Awesome/)

I am also thinking of adding the google translate widget to my website as a little tab at the bottom that prompts the user to translate the page if they need to. (https://translate.google.com/manager/website/)

However, if I run my site through google translate, all of the font awesome icons gets messed up. I'm thinking that google tries to translate the icons (since it's essentially just a font type). Does anyone have an idea to prevent this from happening?

You can see an example by just running the font awesome site through google translate. (https://translate.google.com/translate?hl=en&sl=en&tl=es&u=http%3A%2F%2Ffortawesome.github.io%2FFont-Awesome%2F)

Google Translate + Font Awesome = Not Awesome


回答1:


Just add an attribute to your HTML like this:

<div translate="no">Let's keep this in plain English!</div>

or add a CSS class:

<div class="notranslate">Let's keep this in plain English, too!</div>

Both is possible, but the first one is W3C recommended and can by viewed in detail here: http://www.w3.org/International/questions/qa-translate-flag.en

UPDATE:

The above examples only work for text inside of HTML attributes. It does not include CSS content in the pseudo ::before attribute.

So, just include the fontawesome library through CDN:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">



回答2:


Apparently (untested) you can add class="notranslate" to your stylesheet:

<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" class="notranslate" />


来源:https://stackoverflow.com/questions/29053605/google-translate-messes-up-font-awesome-icons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!