Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: chrome/common/extensions/docs/templates/intros/i18n.html

Issue 1306873003: Added example of chrome.i18n.detectLanguage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added License header in comments in js file Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/common/extensions/docs/examples/api/i18n/detectLanguage/popup.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!-- 1 <!--
2 [NOTEs for editors: 2 [NOTEs for editors:
3 * Try to be consistent about string vs. message (it's probably not yet). 3 * Try to be consistent about string vs. message (it's probably not yet).
4 --> 4 -->
5 5
6 <p> 6 <p>
7 You need to put all of its user-visible strings into a file 7 You need to put all of its user-visible strings into a file
8 named <a href="i18n-messages"><code>messages.json</code></a>. 8 named <a href="i18n-messages"><code>messages.json</code></a>.
9 Each time you add a new locale, 9 Each time you add a new locale,
10 you add a messages file 10 you add a messages file
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 var languages = languageList.join(","); 552 var languages = languageList.join(",");
553 document.getElementById("languageSpan").innerHTML = languages; 553 document.getElementById("languageSpan").innerHTML = languages;
554 }) 554 })
555 } 555 }
556 </pre> 556 </pre>
557 557
558 <p> 558 <p>
559 For details on calling <code>getAcceptLanguages()</code>, see the 559 For details on calling <code>getAcceptLanguages()</code>, see the
560 $(ref:i18n.getAcceptLanguages API reference). 560 $(ref:i18n.getAcceptLanguages API reference).
561 </p> 561 </p>
562
563 <h3 id="example-detect-language">Example: detectLanguage</h3>
564 <p>
565 The following code detects up to 3 languages from the given string and display s the result as strings separated by new lines.
566 </p>
567
568 <pre>
569 function detectLanguage(inputText) {
570 chrome.i18n.detectLanguage(inputText, function(result) {
571 var outputLang = "Detected Language: ";
572 var outputPercent = "Language Percentage: ";
573 for(i = 0; i &lt; result.languages.length; i++) {
574 outputLang += result.languages[i].language + " ";
575 outputPercent +=result.languages[i].percentage + " ";
576 }
577 document.getElementById("languageSpan").innerHTML = outputLang + "\n" + outp utPercent + "\nReliable: " + result.isReliable;
578 });
579 }
580 </pre>
581
582 <p>
583 For more details on calling <code>detectLanguage(inputText)</code>, see the $( ref:i18n.detectLanguage API reference).
584 </p>
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/examples/api/i18n/detectLanguage/popup.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698