@@ -144,13 +144,127 @@ The :mod:`locale` module defines the following exception and functions:
144144
145145.. function :: nl_langinfo(option)
146146
147- Return some locale-specific information as a string. This function is not
148- available on all systems, and the set of possible options might also vary across
149- platforms. The possible argument values are numbers, for which symbolic
150- constants are available in the locale module.
147+ Return some locale-specific information as a string. This function is not
148+ available on all systems, and the set of possible options might also vary
149+ across platforms. The possible argument values are numbers, for which
150+ symbolic constants are available in the locale module.
151151
152+ The :func: `nl_langinfo ` function accepts one of the following keys. Most
153+ descriptions are taken from the corresponding description in the GNU C
154+ library.
152155
153- .. function :: getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE'))
156+ .. data :: CODESET
157+
158+ Get a string with the name of the character encoding used in the
159+ selected locale.
160+
161+ .. data :: D_T_FMT
162+
163+ Get a string that can be used as a format string for :func: `strftime ` to
164+ represent time and date in a locale-specific way.
165+
166+ .. data :: D_FMT
167+
168+ Get a string that can be used as a format string for :func: `strftime ` to
169+ represent a date in a locale-specific way.
170+
171+ .. data :: T_FMT
172+
173+ Get a string that can be used as a format string for :func: `strftime ` to
174+ represent a time in a locale-specific way.
175+
176+ .. data :: T_FMT_AMPM
177+
178+ Get a format string for :func: `strftime ` to represent time in the am/pm
179+ format.
180+
181+ .. data :: DAY_1 ... DAY_7
182+
183+ Get the name of the n-th day of the week.
184+
185+ .. note ::
186+
187+ This follows the US convention of :const: `DAY_1 ` being Sunday, not the
188+ international convention (ISO 8601) that Monday is the first day of the
189+ week.
190+
191+ .. data :: ABDAY_1 ... ABDAY_7
192+
193+ Get the abbreviated name of the n-th day of the week.
194+
195+ .. data :: MON_1 ... MON_12
196+
197+ Get the name of the n-th month.
198+
199+ .. data :: ABMON_1 ... ABMON_12
200+
201+ Get the abbreviated name of the n-th month.
202+
203+ .. data :: RADIXCHAR
204+
205+ Get the radix character (decimal dot, decimal comma, etc.)
206+
207+ .. data :: THOUSEP
208+
209+ Get the separator character for thousands (groups of three digits).
210+
211+ .. data :: YESEXPR
212+
213+ Get a regular expression that can be used with the regex function to
214+ recognize a positive response to a yes/no question.
215+
216+ .. note ::
217+
218+ The expression is in the syntax suitable for the :cfunc: `regex ` function
219+ from the C library, which might differ from the syntax used in :mod: `re `.
220+
221+ .. data :: NOEXPR
222+
223+ Get a regular expression that can be used with the regex(3) function to
224+ recognize a negative response to a yes/no question.
225+
226+ .. data :: CRNCYSTR
227+
228+ Get the currency symbol, preceded by "-" if the symbol should appear before
229+ the value, "+" if the symbol should appear after the value, or "." if the
230+ symbol should replace the radix character.
231+
232+ .. data :: ERA
233+
234+ Get a string that represents the era used in the current locale.
235+
236+ Most locales do not define this value. An example of a locale which does
237+ define this value is the Japanese one. In Japan, the traditional
238+ representation of dates includes the name of the era corresponding to the
239+ then-emperor's reign.
240+
241+ Normally it should not be necessary to use this value directly. Specifying
242+ the ``E `` modifier in their format strings causes the :func: `strftime `
243+ function to use this information. The format of the returned string is not
244+ specified, and therefore you should not assume knowledge of it on different
245+ systems.
246+
247+ .. data :: ERA_YEAR
248+
249+ Get the year in the relevant era of the locale.
250+
251+ .. data :: ERA_D_T_FMT
252+
253+ Get a format string for :func: `strftime ` to represent dates and times in a
254+ locale-specific era-based way.
255+
256+ .. data :: ERA_D_FMT
257+
258+ Get a format string for :func: `strftime ` to represent time in a
259+ locale-specific era-based way.
260+
261+ .. data :: ALT_DIGITS
262+
263+ Get a representation of up to 100 values used to represent the values
264+ 0 to 99.
265+
266+
267+ .. function :: getdefaultlocale([envvars])
154268
155269 Tries to determine the default locale settings and returns them as a tuple of
156270 the form ``(language code, encoding) ``.
@@ -338,140 +452,13 @@ The :mod:`locale` module defines the following exception and functions:
338452 This is a symbolic constant used for different values returned by
339453 :func: `localeconv `.
340454
341- The :func: `nl_langinfo ` function accepts one of the following keys. Most
342- descriptions are taken from the corresponding description in the GNU C library.
343-
344-
345- .. data :: CODESET
346-
347- Return a string with the name of the character encoding used in the selected
348- locale.
349-
350-
351- .. data :: D_T_FMT
352-
353- Return a string that can be used as a format string for strftime(3) to represent
354- time and date in a locale-specific way.
355-
356-
357- .. data :: D_FMT
358-
359- Return a string that can be used as a format string for strftime(3) to represent
360- a date in a locale-specific way.
361-
362-
363- .. data :: T_FMT
364-
365- Return a string that can be used as a format string for strftime(3) to represent
366- a time in a locale-specific way.
367-
368-
369- .. data :: T_FMT_AMPM
370-
371- The return value can be used as a format string for 'strftime' to represent time
372- in the am/pm format.
373-
374-
375- .. data :: DAY_1 ... DAY_7
376-
377- Return name of the n-th day of the week.
378-
379- .. note ::
380-
381- This follows the US convention of :const: `DAY_1 ` being Sunday, not the
382- international convention (ISO 8601) that Monday is the first day of the week.
383-
384-
385- .. data :: ABDAY_1 ... ABDAY_7
386-
387- Return abbreviated name of the n-th day of the week.
388-
389-
390- .. data :: MON_1 ... MON_12
391-
392- Return name of the n-th month.
393-
394-
395- .. data :: ABMON_1 ... ABMON_12
396-
397- Return abbreviated name of the n-th month.
398-
399-
400- .. data :: RADIXCHAR
401-
402- Return radix character (decimal dot, decimal comma, etc.)
403-
404-
405- .. data :: THOUSEP
406-
407- Return separator character for thousands (groups of three digits).
408-
409-
410- .. data :: YESEXPR
411-
412- Return a regular expression that can be used with the regex function to
413- recognize a positive response to a yes/no question.
414-
415- .. note ::
416-
417- The expression is in the syntax suitable for the :cfunc: `regex ` function from
418- the C library, which might differ from the syntax used in :mod: `re `.
419-
420-
421- .. data :: NOEXPR
422-
423- Return a regular expression that can be used with the regex(3) function to
424- recognize a negative response to a yes/no question.
425-
426-
427- .. data :: CRNCYSTR
428-
429- Return the currency symbol, preceded by "-" if the symbol should appear before
430- the value, "+" if the symbol should appear after the value, or "." if the symbol
431- should replace the radix character.
432-
433-
434- .. data :: ERA
435-
436- The return value represents the era used in the current locale.
437-
438- Most locales do not define this value. An example of a locale which does define
439- this value is the Japanese one. In Japan, the traditional representation of
440- dates includes the name of the era corresponding to the then-emperor's reign.
441-
442- Normally it should not be necessary to use this value directly. Specifying the
443- ``E `` modifier in their format strings causes the :func: `strftime ` function to
444- use this information. The format of the returned string is not specified, and
445- therefore you should not assume knowledge of it on different systems.
446-
447-
448- .. data :: ERA_YEAR
449-
450- The return value gives the year in the relevant era of the locale.
451-
452-
453- .. data :: ERA_D_T_FMT
454-
455- This return value can be used as a format string for :func: `strftime ` to
456- represent dates and times in a locale-specific era-based way.
457-
458-
459- .. data :: ERA_D_FMT
460-
461- This return value can be used as a format string for :func: `strftime ` to
462- represent time in a locale-specific era-based way.
463-
464-
465- .. data :: ALT_DIGITS
466-
467- The return value is a representation of up to 100 values used to represent the
468- values 0 to 99.
469455
470456Example::
471457
472458 >>> import locale
473459 >>> loc = locale.getlocale() # get current locale
474- >>> locale.setlocale(locale.LC_ALL, 'de_DE') # use German locale; name might vary with platform
460+ # use German locale; name might vary with platform
461+ >>> locale.setlocale(locale.LC_ALL, 'de_DE')
475462 >>> locale.strcoll('f\xe4n', 'foo') # compare a string containing an umlaut
476463 >>> locale.setlocale(locale.LC_ALL, '') # use user's preferred locale
477464 >>> locale.setlocale(locale.LC_ALL, 'C') # use default (C) locale
0 commit comments