blob: e25a84aadce26492bab9cc9e36c0cab085a93e77 (
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
|
---
title: Intl.Locale.prototype.toString()
slug: Web/JavaScript/Reference/Global_Objects/Intl/Locale/toString
tags:
- Intl
- JavaScript
- Locale
- Méthode
- Reference
translation_of: Web/JavaScript/Reference/Global_Objects/Intl/Locale/toString
original_slug: Web/JavaScript/Reference/Objets_globaux/Intl/Locale/toString
---
{{JSRef}}
La méthode **`Intl.Locale.prototype.toString()`** renvoie [l'identifiant de locale complet](https://www.unicode.org/reports/tr35/#Unicode_locale_identifier) pour la locale courante.
{{EmbedInteractiveExample("pages/js/intl-locale-prototype-tostring.html")}}
## Syntaxe
locale.toString()
### Valeur de retour
La chaîne de caractères représentant l'identifiant complet de la locale.
## Description
Une instance de `Locale` est une représentation JavaScript d'une locale au sens Unicode. Les informations décrivant une locale donnée (la langue, le système d'écriture, le type de calendrier, etc.) peuvent être encodées en une chaîne de caractères qui est l'identifiant de la locale. Lorsqu'on appelle la méthode `toString()` sur une instance de `Locale`, on obtiendra l'identifiant complet de la locale.
## Exemples
```js
let maLocale = new Intl.Locale("fr-Latn-FR", {hourCycle: "h24", calendar: "gregory"});
console.log(maLocale.baseName); // Affiche "fr-Latn-FR"
console.log(maLocale.toString()); // Affiche "fr-Latn-FR-u-ca-gregory-hc-h24"
```
## Spécifications
| Spécification | État | Commentaires |
| -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | ------------ |
| [Proposition pour `Intl.Locale.prototype.toString()`](https://tc39.github.io/proposal-intl-locale/#sec-Intl.Locale.prototype.toString) | Proposition de niveau 3 | |
## Compatibilité des navigateurs
{{Compat("javascript.builtins.Intl.Locale.toString")}}
## Voir aussi
- {{jsxref("Locale", "Intl.Locale")}}
- {{jsxref("Locale/baseName", "Intl.Locale.baseName")}}
|