diff options
Diffstat (limited to 'files/ja/mozilla/add-ons/webextensions/api/i18n')
7 files changed, 699 insertions, 0 deletions
diff --git a/files/ja/mozilla/add-ons/webextensions/api/i18n/detectlanguage/index.html b/files/ja/mozilla/add-ons/webextensions/api/i18n/detectlanguage/index.html new file mode 100644 index 0000000000..f34d266ad8 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/i18n/detectlanguage/index.html @@ -0,0 +1,115 @@ +--- +title: i18n.detectLanguage() +slug: Mozilla/Add-ons/WebExtensions/API/i18n/detectLanguage +tags: + - API + - Add-ons + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - detectLanguage + - i18n +translation_of: Mozilla/Add-ons/WebExtensions/API/i18n/detectLanguage +--- +<div>{{AddonSidebar()}}</div> + +<p>提供されたテキストの言語を <a href="https://github.com/CLD2Owners/cld2">Compact Language Detector</a> (CLD) を利用して検出します。</p> + +<p>これは、<code><a href="/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> を返す非同期関数です。</p> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox brush:js">var detectingLanguages = browser.i18n.detectLanguage( + text // string +) +</pre> + +<h3 id="Parameters" name="Parameters">引数</h3> + +<dl> + <dt><code>text</code></dt> + <dd><code>文字列</code>。翻訳されるユーザー入力の文字列です。</dd> +</dl> + +<h3 id="Return_value" name="Return_value">戻り値</h3> + +<p>結果オブジェクトで解決される <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>。結果オブジェクトは 2 個のプロパティを持ちます:</p> + +<dl class="reference-values"> + <dt><code>isReliable</code></dt> + <dd><code>真偽値</code>。検出された言語が確かかどうかを示します。</dd> + <dt><code>languages</code></dt> + <dd>オブジェクトの <code>配列</code>。配列の各項目はさらに 2 個のプロパティを持ちます:</dd> + <dd> + <dl class="reference-values"> + <dt><code>language</code></dt> + <dd>{{WebExtAPIRef('i18n.LanguageCode')}}。検出された言語です。</dd> + <dt><code>percentage</code></dt> + <dd><code>整数値</code>。検出された言語で入力された文字列の割り合い。</dd> + </dl> + </dd> +</dl> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの実装状況</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.i18n.detectLanguage")}}</p> + +<h2 id="Examples" name="Examples">例</h2> + +<pre class="brush: js">function onLanguageDetected(langInfo) { + for (lang of langInfo.languages) { + console.log("Language is: " + lang.language); + console.log("Percentage is: " + lang.percentage); + } +} + +var text = "L'homme est né libre, et partout il est dans les fers." + +var detecting = browser.i18n.detectLanguage(text); +detecting.then(onLanguageDetected); + +</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は、Chromium の <a href="https://developer.chrome.com/extensions/i18n#method-detectLanguage"><code>chrome.i18n</code></a> API を基にしています。このドキュメンテーションは、Chromium コード内の <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/i18n.json"><code>i18n.json</code></a> に由来しています。</p> + +<p>Microsoft Edge 互換性データは、Microsoft Corporation より供給され、Creative Commons Attribution 3.0 United States License の下で含まれています。</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/ja/mozilla/add-ons/webextensions/api/i18n/getacceptlanguages/index.html b/files/ja/mozilla/add-ons/webextensions/api/i18n/getacceptlanguages/index.html new file mode 100644 index 0000000000..636e86d94d --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/i18n/getacceptlanguages/index.html @@ -0,0 +1,92 @@ +--- +title: i18n.getAcceptLanguages() +slug: Mozilla/Add-ons/WebExtensions/API/i18n/getAcceptLanguages +tags: + - API + - Add-ons + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - getAcceptLanguages + - i18n +translation_of: Mozilla/Add-ons/WebExtensions/API/i18n/getAcceptLanguages +--- +<div>{{AddonSidebar()}}</div> + +<p>ブラウザーの <a href="/ja/docs/Web/HTTP/Content_negotiation#The_Accept-Language_header">accept-languages</a> を取得します。これは、ブラウザーに使用されているロケールとは異なります。ロケールを取得するには、{{WebExtAPIRef('i18n.getUILanguage')}} を使用してください。</p> + +<p>これは、<code><a href="/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> を返す非同期関数です。</p> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox brush:js">var gettingAcceptLanguages = browser.i18n.getAcceptLanguages() +</pre> + +<h3 id="Parameters" name="Parameters">引数</h3> + +<p>なし。</p> + +<h3 id="Return_value" name="Return_value">戻り値</h3> + +<p><code>{{WebExtAPIRef('i18n.LanguageCode')}}</code> オブジェクトの <code>配列</code> で処理が完了した <code><a href="/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>。</p> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの実装状況</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.i18n.getAcceptLanguages")}}</p> + +<h2 id="Examples" name="Examples">例</h2> + +<pre class="brush: js">function onGot(languages) { + console.log(languages); + //e.g. Array [ "en-US", "en" ] +} + +var gettingAcceptLanguages = browser.i18n.getAcceptLanguages(); +gettingAcceptLanguages.then(onGot); +</pre> + +<p> </p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は、Chromium の <a href="https://developer.chrome.com/extensions/i18n#method-getAcceptLanguages"><code>chrome.i18n</code></a> API を基にしています。このドキュメンテーションは、Chromium コード内の <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/i18n.json"><code>i18n.json</code></a> に由来しています。</p> + +<p>Microsoft Edge 互換性データは、Microsoft Corporation より供給され、Creative Commons Attribution 3.0 United States License の下で含まれています。</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/ja/mozilla/add-ons/webextensions/api/i18n/getmessage/index.html b/files/ja/mozilla/add-ons/webextensions/api/i18n/getmessage/index.html new file mode 100644 index 0000000000..c28d4a83ad --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/i18n/getmessage/index.html @@ -0,0 +1,119 @@ +--- +title: i18n.getMessage() +slug: Mozilla/Add-ons/WebExtensions/API/i18n/getMessage +tags: + - API + - Add-ons + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - getMessage + - i18n +translation_of: Mozilla/Add-ons/WebExtensions/API/i18n/getMessage +--- +<div>{{AddonSidebar()}}</div> + +<p>指定したメッセージのローカライズされた文字列を取得します。</p> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox brush:js">browser.i18n.getMessage( + messageName, // 文字列 + substitutions // 任意 +) +</pre> + +<h3 id="Parameters" name="Parameters">引数</h3> + +<dl> + <dt><code>messageName</code></dt> + <dd><code>文字列</code>。messages.json で指定されたメッセージ名です。messages.json 内にメッセージを見つけられない場合は:</dd> + <dd> + <ul> + <li>Firefox は "" を返し、エラーログを出力します。</li> + <li>Chrome は "" を返し、エラーログを出力しません。</li> + </ul> + </dd> + <dt><code>substitutions</code>{{optional_inline}}</dt> + <dd><code>文字列</code> または <code>文字列</code> の <code>配列</code>。単一の置換文字列、または置換文字列の配列です。</dd> + <dd>Chrome では、9 個より多くの置換文字列を与えると、<code>getMessage()</code> は <code>undefined</code> を返します。</dd> +</dl> + +<h3 id="Return_value" name="Return_value">戻り値</h3> + +<p><code>文字列</code>。現在のロケール向けにローカライズされたメッセージ。</p> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの実装状況</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.i18n.getMessage")}}</p> + +<h2 id="Examples" name="Examples">例</h2> + +<p><code>target.url</code> を置換文字列として渡し、<code>"messageContent"</code> のローカライズされた文字列を取得します:</p> + +<pre class="brush: js">var message = browser.i18n.getMessage("messageContent", target.url); +console.log(message); +</pre> + +<p>これは、_locales/en/messages.json ファイルに含まれた次の内容で動作します:</p> + +<pre class="brush: json">{ + "messageContent": { + "message": "You clicked $URL$.", + "description": "Tells the user which link they clicked.", + "placeholders": { + "url" : { + "content" : "$1", + "example" : "https://developer.mozilla.org" + } + } + } +}</pre> + +<p><code>target.url</code> が "https://developer.mozilla.org" である場合、"en" ロケールでのメッセージの値は次のようになります:</p> + +<pre>"You clicked https://developer.mozilla.org."</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は、Chromium の <a href="https://developer.chrome.com/extensions/i18n#method-getMessage"><code>chrome.i18n</code></a> API を基にしています。このドキュメンテーションは、Chromium コード内の <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/i18n.json"><code>i18n.json</code></a> に由来しています。</p> + +<p>Microsoft Edge 互換性データは、Microsoft Corporation より供給され、Creative Commons Attribution 3.0 United States License の下で含まれています。</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/ja/mozilla/add-ons/webextensions/api/i18n/getuilanguage/index.html b/files/ja/mozilla/add-ons/webextensions/api/i18n/getuilanguage/index.html new file mode 100644 index 0000000000..51161c8496 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/i18n/getuilanguage/index.html @@ -0,0 +1,84 @@ +--- +title: i18n.getUILanguage() +slug: Mozilla/Add-ons/WebExtensions/API/i18n/getUILanguage +tags: + - API + - Add-ons + - Extensions + - Method + - Non-standard + - Reference + - WebExtensions + - getUILanguage + - i18n +translation_of: Mozilla/Add-ons/WebExtensions/API/i18n/getUILanguage +--- +<div>{{AddonSidebar()}}</div> + +<p>ブラウザーの UI 言語を取得します。これは、優先されるユーザー言語を返す {{WebExtAPIRef('i18n.getAcceptLanguages')}} とは異なります。</p> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox brush:js">browser.i18n.getUILanguage() +</pre> + +<h3 id="Parameters" name="Parameters">引数</h3> + +<p>なし。</p> + +<h3 id="Return_value" name="Return_value">戻り値</h3> + +<p><code>文字列</code>。{{WebExtAPIRef("i18n.LanguageCode")}} によるブラウザーの UI 言語コード。</p> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの実装状況</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.i18n.getUILanguage")}}</p> + +<h2 id="Examples" name="Examples">例</h2> + +<pre class="brush: js">var uiLanguage = browser.i18n.getUILanguage(); +console.log(uiLanguage); + +//e.g. "ja"</pre> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は、Chromium の <a href="https://developer.chrome.com/extensions/i18n#method-getUILanguage"><code>chrome.i18n</code></a> API を基にしています。このドキュメンテーションは、Chromium コード内の <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/i18n.json"><code>i18n.json</code></a> に由来しています。</p> + +<p>Microsoft Edge 互換性データは、Microsoft Corporation より供給され、Creative Commons Attribution 3.0 United States License の下で含まれています。</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/ja/mozilla/add-ons/webextensions/api/i18n/index.html b/files/ja/mozilla/add-ons/webextensions/api/i18n/index.html new file mode 100644 index 0000000000..deba5c0bf5 --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/i18n/index.html @@ -0,0 +1,94 @@ +--- +title: i18n +slug: Mozilla/Add-ons/WebExtensions/API/i18n +tags: + - API + - Add-ons + - Extensions + - Interface + - Non-standard + - Reference + - WebExtensions + - i18n +translation_of: Mozilla/Add-ons/WebExtensions/API/i18n +--- +<div>{{AddonSidebar}}</div> + +<p>拡張機能を国際化する関数です。これらの API は、拡張機能に同梱したロケールファイルからローカライズ文字列を取得したり、ブラウザーの現在の言語や、その <a href="/ja/docs/Web/HTTP/Content_negotiation#The_Accept-Language_header">Accept-Language ヘッダー</a> を調べるために使用します。</p> + +<p id="See_also">拡張機能で i18n を使用するための詳細は、以下の記事を参照してください:</p> + +<ul> + <li><a href="/ja/docs/Mozilla/Add-ons/WebExtensions/Internationalization">Internationalization</a>: WebExtension の i18n システムを使うためのガイド。</li> + <li><a href="/ja/docs/Mozilla/Add-ons/WebExtensions/API/i18n/Locale-Specific_Message_reference">ロケール固有のメッセージ参照</a>: 拡張機能が <code>messages.json</code> と呼ばれるファイルで供給するロケール固有の文字列。このページは、<code>messages.json</code> の書式について書かれています。</li> +</ul> + +<h2 id="Types" name="Types">型</h2> + +<dl> + <dt>{{WebExtAPIRef("i18n.LanguageCode")}}</dt> + <dd><code>"en-US"</code> や "<code>fr</code>" などの <a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.10">言語タグ</a>。</dd> +</dl> + +<h2 id="Functions" name="Functions">関数</h2> + +<dl> + <dt>{{WebExtAPIRef("i18n.getAcceptLanguages()")}}</dt> + <dd>ブラウザーの <a href="/ja/docs/Web/HTTP/Content_negotiation#The_Accept-Language_header">accept-languages</a> を取得します。これは、ブラウザーに使用されているロケールとは異なります。ロケールを取得するには、{{WebExtAPIRef('i18n.getUILanguage')}} を使用してください。</dd> + <dt>{{WebExtAPIRef("i18n.getMessage()")}}</dt> + <dd>指定したメッセージのローカライズ文字列を取得します。</dd> + <dt>{{WebExtAPIRef("i18n.getUILanguage()")}}</dt> + <dd>ブラウザーの UI 言語を取得します。これは、優先されるユーザー言語を返す {{WebExtAPIRef('i18n.getAcceptLanguages')}} とは異なります。</dd> + <dt>{{WebExtAPIRef("i18n.detectLanguage()")}}</dt> + <dd>提供されたテキストの言語を <a href="https://github.com/CLD2Owners/cld2">Compact Language Detector</a> を利用して検出します。</dd> +</dl> + +<dl> +</dl> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの実装状況</h2> + +<p>{{Compat("webextensions.api.i18n")}}</p> + +<p>{{WebExtExamples("h2")}}</p> + +<dl> +</dl> + +<div class="note"><strong>謝辞</strong> + +<p>この API は、Chromium の <a href="https://developer.chrome.com/extensions/i18n"><code>chrome.i18n</code></a> API を基にしています。このドキュメンテーションは、Chromium コード内の <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/i18n.json"><code>i18n.json</code></a> に由来しています。</p> + +<p>Microsoft Edge 互換性データは、Microsoft Corporation より供給され、Creative Commons Attribution 3.0 United States License の下で含まれています。</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/ja/mozilla/add-ons/webextensions/api/i18n/languagecode/index.html b/files/ja/mozilla/add-ons/webextensions/api/i18n/languagecode/index.html new file mode 100644 index 0000000000..2ed7796e1f --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/i18n/languagecode/index.html @@ -0,0 +1,68 @@ +--- +title: i18n.LanguageCode +slug: Mozilla/Add-ons/WebExtensions/API/i18n/LanguageCode +tags: + - API + - Add-ons + - Extensions + - LanguageCode + - Non-standard + - Reference + - Type + - WebExtensions + - i18n +translation_of: Mozilla/Add-ons/WebExtensions/API/i18n/LanguageCode +--- +<div>{{AddonSidebar()}}</div> + +<p><code>"en-US"</code> や "<code>fr</code>" などの <a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.10">言語タグ</a>。</p> + +<h2 id="Types" name="Types">型</h2> + +<p>この型の値は文字列です。</p> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの実装状況</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.api.i18n.LanguageCode")}}</p> + +<p>{{WebExtExamples}}</p> + +<div class="note"><strong>謝辞</strong> + +<p>この API は、Chromium の <a href="https://developer.chrome.com/extensions/i18n#type-LanguageCode"><code>chrome.i18n</code></a> API を基にしています。このドキュメンテーションは、Chromium コード内の <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/api/i18n.json"><code>i18n.json</code></a> に由来しています。</p> + +<p>Microsoft Edge 互換性データは、Microsoft Corporation より供給され、Creative Commons Attribution 3.0 United States License の下で含まれています。</p> +</div> + +<div class="hidden"> +<pre>// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> diff --git a/files/ja/mozilla/add-ons/webextensions/api/i18n/locale-specific_message_reference/index.html b/files/ja/mozilla/add-ons/webextensions/api/i18n/locale-specific_message_reference/index.html new file mode 100644 index 0000000000..adcde0288c --- /dev/null +++ b/files/ja/mozilla/add-ons/webextensions/api/i18n/locale-specific_message_reference/index.html @@ -0,0 +1,127 @@ +--- +title: ロケール固有のメッセージ参照 +slug: Mozilla/Add-ons/WebExtensions/API/i18n/Locale-Specific_Message_reference +tags: + - Internationalization + - Localization + - Reference + - String + - WebExtensions + - i18n + - message + - message.json + - placeholders +translation_of: Mozilla/Add-ons/WebExtensions/API/i18n/Locale-Specific_Message_reference +--- +<p>国際化対応 (i18n) した拡張機能は、ロケール固有のメッセージを提供する少なくとも 1 個の <code>messages.json</code> というファイルを持っています。このページでは、<code>messages.json</code> の書式を説明します。</p> + +<div class="note"> +<p><strong>補足</strong>: 拡張機能を国際化する方法についての情報は、<a href="/ja/Add-ons/WebExtensions/WebExtension_i18n">i18n</a> ガイドを参照してください。</p> +</div> + +<h2 id="messages.json_example">messages.json example</h2> + +<p>次のコードは、<a href="https://github.com/mdn/webextensions-examples/tree/master/notify-link-clicks-i18n">notify-link-clicks-i18n example</a> 拡張機能から取られた <code>messages.json ファイル</code> の例示です。"<em>name</em>" と "message" のフィールドのみが必須です。</p> + +<pre class="brush: json">{ + "extensionName": { + "message": "Notify link clicks i18n", + "description": "Name of the extension." + }, + + "extensionDescription": { + "message": "ユーザーがリンクをクリックしたときに通知を表示します。", + "description": "Description of the extension." + }, + + "notificationTitle": { + "message": "クリック通知", + "description": "Title of the click notification." + }, + + "notificationContent": { + "message": "$URL$ をクリックしました。", + "description": "Tells the user which link they clicked.", + "placeholders": { + "url" : { + "content" : "$1", + "example" : "https://developer.mozilla.org" + } + } + } +}</pre> + +<h2 id="Placement" name="Placement">ファイルの配置</h2> + +<p><code>messages.json</code> ファイルは、サポートされたロケール名 (<code>en</code>, <code>de</code>, <code>ja</code> など) のディレクトリー内に置く必要があります。さらにこれらは、拡張機能のルートディレクトリ内の <code>_locales</code> と呼ばれるディレクトリー内に置く必要があります。</p> + +<h2 id="Member_details" name="Member_details">メンバーの詳細</h2> + +<p>このセクションは、<code>messages.json</code> 内に記述される各メンバーについて説明します。</p> + +<h3 id="name" name="name">name</h3> + +<p>各トップレベルのメンバーは、ローカライズするメッセージ文字列の name の後に名付けられます。例えば、上記の例の <code>"extensionName"</code> や <code>"notificationContent"</code> です。name は大文字と小文字が区別され、ローカライズされたメッセージテキストを受け取るためのキーとして振る舞います。</p> + +<p>name には、次の文字が使用できます:</p> + +<ul> + <li>A-Z</li> + <li>a-z</li> + <li>0-9</li> + <li>_ (アンダースコア)</li> + <li>@</li> +</ul> + +<p class="note"><strong>注記:</strong> @@ で始まる name を定義してはいけません。この名前は <a href="/ja/Add-ons/WebExtensions/Internationalization#Predefined_messages">事前定義されたメッセージ</a> で予約されています。</p> + +<h3 id="message" name="message">message</h3> + +<p><code>"message"</code> メンバーは、{{anch("placeholders")}} を含むことのできるローカライズされた文字列を含みます。次のように使用します:</p> + +<ul> + <li><em>$placeholder_name$</em> (大文字と小文字を区別) は、文字列に特定のプレースホルダー (例えば、上記の例の $URL$) を挿入します。</li> + <li><code>$1</code>, <code>$2</code>,<code> $3</code> 等は、{{WebExtAPIRef("i18n.getMessage()")}} 呼び出し時に取得した値を文字列に直接挿入します。</li> +</ul> + +<p>他の注意すべき点:</p> + +<ul> + <li>文字列の前後に現れるいくつかのドル記号は、その個数から 1 を引いた数分のドル記号に置き換えられます。つまり、$$ は $ に、$$$ は $$ になります。</li> + <li>ロケールファイルの読み込み時に、<code>/\$([a-z0-9_@]+)\$/i</code> と一致するトークンは、文字列の "置き換え" オブジェクトからの一致する値に置き換えられます。これらの置換は、メッセージ内の任意の <code>/\$\d/</code> トークンの処理よりも優先して行われます。</li> + <li>ロケール文字列が使用される時に、<code>/\$\d+/</code> と一致するトークンは、{{WebExtAPIRef("i18n.getMessage()")}} に渡される replacement に置き換えられます。</li> + <li><code>getMessage()</code> は、placeholder/substitution の呼び出しを 9 個までしか処理しません。</li> +</ul> + +<h3 id="description" name="description">description</h3> + +<p>{{optional_inline}}</p> + +<p><code>"description"</code> メンバーは、文字列に最適な訳語を作成する助けとなる情報を翻訳者に提供するために、メッセージ文字列の内容についての説明を含みます。</p> + +<h3 id="placeholders" name="placeholders">placeholders</h3> + +<p>{{optional_inline}}</p> + +<p><code>"placeholders"</code> メンバーは、メッセージ内で使用されるいくつかのプレースホルダー補助文字列を定義します。これらは、翻訳してほしくないハードコードされたアイテムや変数を参照するアイテムに利用できます。</p> + +<p>各プレースホルダー補助文字列の定義は、それ自身がいくつかの値を持っています:</p> + +<pre class="brush: json">"url" : { + "content" : "$1", + "example" : "https://developer.mozilla.org" +}</pre> + +<h4 id="placeholder_name" name="placeholder_name">プレースホルダー名</h4> + +<p>プレースホルダー名は、補助文字列内の placeholder を表すために使用します (<code>"url"</code> は <code>$url$</code> になります)。これは、大文字と小文字が区別され、メッセージ文字列と同じ文字が使用できます {{anch("name")}}。</p> + +<h4 id="content" name="content">content</h4> + +<p>"content" アイテムは、placeholder の内容を定義します。これは、"My placeholder" などハードコードされた文字列にすることができますが、{{WebExtAPIRef("i18n.getMessage()")}} 呼び出しから取得した値も含められます。詳しい情報は、<a href="/ja/Add-ons/WebExtensions/Internationalization#Retrieving_message_strings_from_JavaScript">JavaScript からメッセージ文字列を取得する</a> を参照してください。</p> + +<h4 id="example" name="example">example</h4> + +<p>{{optional_inline}}</p> + +<p>任意の "example" アイテムは、プレースホルダーがエンドユーザーにどのように表示されるかの例を示すことによって翻訳者を助けるためのものです。これにより、翻訳者がファイルをローカライズするときに最適な選択ができるようになるでしょう。</p> |
