Skip to content

Commit 4c58ac6

Browse files
authored
Update language tag guidelines in PEP 545
Cover usage of script subtags in IETF language tags.
1 parent 37914ba commit 4c58ac6

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

peps/pep-0545.rst

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,25 @@ Language Tag
187187
''''''''''''
188188

189189
A common notation for language tags is the :rfc:`IETF Language Tag <5646>`
190-
[4]_ based on ISO 639, although gettext uses ISO 639 tags with
191-
underscores (ex: ``pt_BR``) instead of dashes to join tags [5]_
192-
(ex: ``pt-BR``). Examples of IETF Language Tags: ``fr`` (French),
193-
``ja`` (Japanese), ``pt-BR`` (Orthographic formulation of 1943 -
194-
Official in Brazil).
190+
[4]_ (BCP 47, RFC 5646), which is based on ISO 639 for language codes,
191+
ISO 15924 for script codes, and ISO 3166 for region codes. Gettext uses
192+
ISO 639 tags with underscores (e.g. ``pt_BR``), but IETF tags use hyphens
193+
as separators instead of dashes to join tags [5]_ (e.g. ``pt-BR``).
195194

196-
It is more common to see dashes instead of underscores in URLs [6]_,
197-
so we should use IETF language tags, even if sphinx uses gettext
198-
internally: URLs are not meant to leak the underlying implementation.
195+
Examples of IETF Language Tags:
196+
197+
* ``fr`` (French),
198+
* ``ja`` (Japanese),
199+
* ``pt-br`` (Portugese as spoken in Brazil),
200+
* ``pa-guru`` (Punjabi written in Gurmukhi script)
201+
202+
The `script` subtag is used when a language can be written in multiple
203+
writing systems. For example, Punjabi can be written in Gurmukhi (``pa-guru``)
204+
or Shahmukhi (``pa-arab``).
205+
206+
It is more common to see hyphens instead of underscores in URLs [6]_,
207+
so we should use IETF language tags in URL paths, even if Sphinx or Gettext use
208+
different internal conventions. URLs should not leak implementation details.
199209

200210
It's uncommon to see capitalized letters in URLs, and docs.python.org
201211
doesn't use any, so it may hurt readability by attracting the eye on it,
@@ -206,10 +216,10 @@ states that tags are not case sensitive. As the RFC allows lower case,
206216
and it enhances readability, we should use lowercased tags like
207217
``pt-br``.
208218

209-
We may drop the region subtag when it does not add distinguishing
219+
We may drop the subtag when it does not add distinguishing
210220
information, for example: "de-DE" or "fr-FR". (Although it might
211221
make sense, respectively meaning "German as spoken in Germany"
212-
and "French as spoken in France"). But when the region subtag
222+
and "French as spoken in France"). But when the subtag
213223
actually adds information, for example "pt-BR" or "Portuguese as
214224
spoken in Brazil", it should be kept.
215225

0 commit comments

Comments
 (0)