blob: 433b3f2ef6f77ff160ea471af41e0ff82b41729e (
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
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
|
---
title: Intl.Locale.prototype.baseName
slug: Web/JavaScript/Reference/Global_Objects/Intl/Locale/baseName
tags:
- Internationalization
- JavaScript
- Property
- Prototype
- Reference
- プロパティ
- 国際化
translation_of: Web/JavaScript/Reference/Global_Objects/Intl/Locale/baseName
---
<div>{{JSRef}}</div>
<p><strong><code>Intl.Locale.prototype.baseName</code></strong> プロパティは、 <code>Locale</code> の文字列表現の部分文字列を返し、そこには <code>Locale</code> についての中核情報が含まれています。</p>
<h2 id="Description" name="Description">解説</h2>
<p>{{jsxref("Locale", "Intl.Locale")}} オブジェクトは、解析されたロケールとそのロケールのオプションを表します。 <code>baseName</code> プロパティは、ロケールに関する基本的な情報を、完全なデータ文字列の部分文字列の形で返します。具体的には、このプロパティは言語を含む部分文字列を返し、文字体系や地域があればそれも返します。</p>
<p><code>baseName</code> は <code>言語 ["-" 文字体系] ["-" 地域] *("-" variant)</code> の形で <a href="https://www.unicode.org/reports/tr35/#Identifiers">unicode_language_id grammar</a> の部分文字列を返します。</p>
<h2 id="Examples" name="Examples">例</h2>
<h3 id="Basic_Example" name="Basic_Example">基本的な例</h3>
<pre class="brush: js">let myLoc = new Intl.Locale("fr-Latn-CA"); // ロケールをカナダのフランス語に設定
console.log(myLoc.toString()); // "fr-Latn-CA-u-ca-gregory" と表示
console.log(myLoc.baseName); // "fr-Latn-CA" と表示</pre>
<h3 id="入力文字列のオプション付きの例">入力文字列のオプション付きの例</h3>
<pre class="brush: js">// 言語を日本語、地域を日本に設定する。
// カレンダーをグレゴリオ暦、時制を24時制にする
let japan = new Intl.Locale("ja-JP-u-ca-gregory-hc-24");
console.log(japan.toString()); // "ja-JP-u-ca-gregory-hc-h24" と表示
console.log(japan.baseName); // "ja-JP" と表示</pre>
<h3 id="入力文字列を上書きするオプション付きの例">入力文字列を上書きするオプション付きの例</h3>
<pre class="brush: js">// 入力文字列は言語がオランダ語、地域がベルギーであることを示していますが、
// ただし、オプションオブジェクトで地域を上書きしており、オランダに設定しています
let dutch = new Intl.Locale("nl-Latn-BE", {region: "NL"});
console.log(dutch.baseName); // "nl-Latn-NL" と表示</pre>
<h2 id="Specifications" name="Specifications">仕様書</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">仕様書</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('ES Int Draft', '#sec-Intl.Locale.prototype.baseName')}}</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>
<div>{{Compat("javascript.builtins.Intl.Locale.baseName")}}</div>
<h2 id="See_also" name="See_also">関連情報</h2>
<ul>
<li>{{jsxref("Locale", "Intl.Locale")}}</li>
</ul>
|