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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/docs/templates/intros/i18n.html
diff --git a/chrome/common/extensions/docs/templates/intros/i18n.html b/chrome/common/extensions/docs/templates/intros/i18n.html
index c720fa246d0a11d9629884aaa3481cd0af047b8c..7fe537227cbe649b0ec37b8a17a602c9345923ae 100644
--- a/chrome/common/extensions/docs/templates/intros/i18n.html
+++ b/chrome/common/extensions/docs/templates/intros/i18n.html
@@ -559,3 +559,26 @@ function getAcceptLanguages() {
For details on calling <code>getAcceptLanguages()</code>, see the
$(ref:i18n.getAcceptLanguages API reference).
</p>
+
+<h3 id="example-detect-language">Example: detectLanguage</h3>
+<p>
+ The following code detects up to 3 languages from the given string and displays the result as strings separated by new lines.
+</p>
+
+<pre>
+function detectLanguage(inputText) {
+ chrome.i18n.detectLanguage(inputText, function(result) {
+ var outputLang = "Detected Language: ";
+ var outputPercent = "Language Percentage: ";
+ for(i = 0; i &lt; result.languages.length; i++) {
+ outputLang += result.languages[i].language + " ";
+ outputPercent +=result.languages[i].percentage + " ";
+ }
+ document.getElementById("languageSpan").innerHTML = outputLang + "\n" + outputPercent + "\nReliable: " + result.isReliable;
+ });
+}
+</pre>
+
+<p>
+ For more details on calling <code>detectLanguage(inputText)</code>, see the $(ref:i18n.detectLanguage API reference).
+</p>
« 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