1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5[ 6 { 7 "namespace": "manifest", 8 "types": [ 9 { 10 "$extend": "WebExtensionManifest", 11 "properties": { 12 "default_locale": { 13 "type": "string", 14 "optional": "true" 15 }, 16 "l10n_resources": { 17 "type": "array", 18 "items": { 19 "type": "string" 20 }, 21 "optional": true 22 } 23 } 24 } 25 ] 26 }, 27 { 28 "namespace": "i18n", 29 "allowedContexts": ["content", "devtools"], 30 "defaultContexts": ["content", "devtools"], 31 "description": "Use the <code>browser.i18n</code> infrastructure to implement internationalization across your whole app or extension.", 32 "types": [ 33 { 34 "id": "LanguageCode", 35 "type": "string", 36 "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" 37 } 38 ], 39 "functions": [ 40 { 41 "name": "getAcceptLanguages", 42 "type": "function", 43 "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).", 44 "async": "callback", 45 "parameters": [ 46 { 47 "type": "function", 48 "name": "callback", 49 "parameters": [ 50 {"name": "languages", "type": "array", "items": {"$ref": "LanguageCode"}, "description": "Array of LanguageCode"} 51 ] 52 } 53 ] 54 }, 55 { 56 "name": "getMessage", 57 "type": "function", 58 "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>.", 59 "parameters": [ 60 { 61 "type": "string", 62 "name": "messageName", 63 "description": "The name of the message, as specified in the <code>$(topic:i18n-messages)[messages.json]</code> file." 64 }, 65 { 66 "type": "any", 67 "name": "substitutions", 68 "optional": true, 69 "description": "Substitution strings, if the message requires any." 70 } 71 ], 72 "returns": { 73 "type": "string", 74 "description": "Message localized for current locale." 75 } 76 }, 77 { 78 "name": "getUILanguage", 79 "type": "function", 80 "description": "Gets the browser UI language of the browser. This is different from $(ref:i18n.getAcceptLanguages) which returns the preferred user languages.", 81 "parameters": [], 82 "returns": { 83 "type": "string", 84 "description": "The browser UI language code such as en-US or fr-FR." 85 } 86 }, 87 { 88 "name": "detectLanguage", 89 "type": "function", 90 "description": "Detects the language of the provided text using CLD.", 91 "async": "callback", 92 "parameters": [ 93 { 94 "type": "string", 95 "name": "text", 96 "description": "User input string to be translated." 97 }, 98 { 99 "type": "function", 100 "name": "callback", 101 "parameters": [ 102 { 103 "type": "object", 104 "name": "result", 105 "description": "LanguageDetectionResult object that holds detected langugae reliability and array of DetectedLanguage", 106 "properties": { 107 "isReliable": { "type": "boolean", "description": "CLD detected language reliability" }, 108 "languages": 109 { 110 "type": "array", 111 "description": "array of detectedLanguage", 112 "items": 113 { 114 "type": "object", 115 "description": "DetectedLanguage object that holds detected ISO language code and its percentage in the input string", 116 "properties": 117 { 118 "language": 119 { 120 "$ref": "LanguageCode" 121 }, 122 "percentage": 123 { 124 "type": "integer", 125 "description": "The percentage of the detected language" 126 } 127 } 128 } 129 } 130 } 131 } 132 ] 133 } 134 ] 135 } 136 ], 137 "events": [] 138 } 139] 140