OLD | NEW |
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 Loading... |
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 < 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> |
OLD | NEW |