Chromium Code Reviews| 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..67bc5c2fd3e558dd6522720a608c8991aab30bc2 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. |
|
mkearney1
2015/09/04 19:56:59
Trailing whitespace error coming up on this line w
|
| +</p> |
| + |
| +<pre> |
| +function detectLanguage(inputText) { |
| + chrome.i18n.detectLanguage(inputText, function(result) { |
| + var outputLang = "Detected Language: "; |
| + var outputPercent = "Language Percentage: "; |
|
mkearney1
2015/09/04 19:56:59
Trailing whitespace error coming up on this line w
|
| + for(i = 0; i < 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> |