summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/docs/static/i18n.html
blob: 360a8d5ca21d7795437600b43e56bd7e051ff63b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<div id="pageData-title" class="pageData">i18n</div>

<!-- BEGIN AUTHORED CONTENT -->
<p id="classSummary">
Use the <code>chrome.i18n</code> module to manipulate the i18n related browser
settings, such as the accept languages.
<span class="comment">
[PENDING: add when getMessage works:
"or to get localized messages for the current locale."]
</span>
</p>

<h3 id="overview-examples">Examples</h3>

<p>
The following code gets accept-languages from the browser and display them as a
string by separating each accept-language with ','.
</p>

<pre>
function getAcceptLanguages() {
  chrome.i18n.getAcceptLanguages(function(languageList) {
    var languages = languageList.join(",");
    document.getElementById("languageSpan").innerHTML = languages;
  })
}
</pre>

<div class="comment">
[PENDING: add the following when getMessage is working]

<p>
The following code gets a localized message from the browser and displays it as a
string. It replaces two placeholders within the message with values arg1 and
arg2.
</p>

<pre>
function getMessage() {
  var message = chrome.i18n.getMessage("click_here", ["arg1", "arg2"]);
  document.getElementById("languageSpan").innerHTML = message;
}
</pre>
</div>
<!-- END AUTHORED CONTENT -->