Open jmyera opened 5 years ago
This type of code is instance based, meaning that it will translate based on identical strings (a.k.a. bits of letters as text) found in a page when the code is called. So, for example, you can't translate only 1 instance of the same word in a page if it appears multiple times, but you can avoid translating a word by just not entering any translation for it into the dictionary's codes.
for example, var dict = { "-EN-": { pt: "ENGLISH", en: "ENGLISH", es:"ENGLISH" }, "-PT-": { pt: "PORTUGUÊS", en: "PORTUGESE", es:"PORTUGÉS" }, "-ES-": { pt: "ESPANHOL", en: "SPANISH, es:"ESPAÑOL"} } Then, in the buttons' texts, you type -EN-, -PT- and -ES-. The translation will replace those with texts you entered in the dictionary. In such example, ENGLISH would be present in every language while PORTUGESE and SPANISH would be translated in the selected language. The only thing you got to highly remember is that you must avoid translating short words or letters in a way that would allow multiple other words or expression to includes such short words or letters. This is why, in the example above, each typed text starts with "-" as there's almost no chance, normally, that "-" would appear in the text content while, on the other end, EN, PT or ES (without "-") might appears many times if you type text in capitals like on titles or buttons.
If you mean that you want to just not enter the original text in the dictionary, it's kinda complicated since it's not just a script that change what is displayed, but an actual text replacement, meaning that the "English" language that was there before the translation doesn't exist anymore once translated in the client, unless you look up into the browser cache .
It's possible to leave the html text as the main text and translate only the languages that are different from the main one?
Button: EN (original text non-translatable) Button: PT (text to translate) Button: ES (text to translate)