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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
[
{
"namespace": "manifest",
"types": [
{
"$extend": "WebExtensionManifest",
"properties": {
"default_locale": {
"type": "string",
"optional": "true"
}
}
}
]
},
{
"namespace": "i18n",
"allowedContexts": ["content"],
"defaultContexts": ["content"],
"description": "Use the <code>browser.i18n</code> infrastructure to implement internationalization across your whole app or extension.",
"types": [
{
"id": "LanguageCode",
"type": "string",
"description": "An ISO language code such as <code>en</code> or <code>fr</code>. For a complete list of languages supported by this method, see <a href='http://src.chromium.org/viewvc/chrome/trunk/src/third_party/cld/languages/internal/languages.cc'>kLanguageInfoTable</a>. For an unknown language, <code>und</code> will be returned, which means that [percentage] of the text is unknown to CLD"
}
],
"functions": [
{
"name": "getAcceptLanguages",
"type": "function",
"description": "Gets the accept-languages of the browser. This is different from the locale used by the browser; to get the locale, use $(ref:i18n.getUILanguage).",
"async": "callback",
"parameters": [
{
"type": "function",
"name": "callback",
"parameters": [
{"name": "languages", "type": "array", "items": {"$ref": "LanguageCode"}, "description": "Array of LanguageCode"}
]
}
]
},
{
"name": "getMessage",
"type": "function",
"description": "Gets the localized string for the specified message. If the message is missing, this method returns an empty string (''). If the format of the <code>getMessage()</code> call is wrong — for example, <em>messageName</em> is not a string or the <em>substitutions</em> array has more than 9 elements — this method returns <code>undefined</code>.",
"parameters": [
{
"type": "string",
"name": "messageName",
"description": "The name of the message, as specified in the <code>$(topic:i18n-messages)[messages.json]</code> file."
},
{
"type": "any",
"name": "substitutions",
"optional": true,
"description": "Substitution strings, if the message requires any."
}
],
"returns": {
"type": "string",
"description": "Message localized for current locale."
}
},
{
"name": "getUILanguage",
"type": "function",
"description": "Gets the browser UI language of the browser. This is different from $(ref:i18n.getAcceptLanguages) which returns the preferred user languages.",
"parameters": [],
"returns": {
"type": "string",
"description": "The browser UI language code such as en-US or fr-FR."
}
},
{
"name": "detectLanguage",
"type": "function",
"description": "Detects the language of the provided text using CLD.",
"async": "callback",
"parameters": [
{
"type": "string",
"name": "text",
"description": "User input string to be translated."
},
{
"type": "function",
"name": "callback",
"parameters": [
{
"type": "object",
"name": "result",
"description": "LanguageDetectionResult object that holds detected langugae reliability and array of DetectedLanguage",
"properties": {
"isReliable": { "type": "boolean", "description": "CLD detected language reliability" },
"languages":
{
"type": "array",
"description": "array of detectedLanguage",
"items":
{
"type": "object",
"description": "DetectedLanguage object that holds detected ISO language code and its percentage in the input string",
"properties":
{
"language":
{
"$ref": "LanguageCode"
},
"percentage":
{
"type": "integer",
"description": "The percentage of the detected language"
}
}
}
}
}
}
]
}
]
}
],
"events": []
}
]
|