Que fait exactement “locale” sur Mac OS X et / ou un autre système d’exploitation Unix / Linux

En train de lire

man locale 

Je pense que ces parameters régionaux affichent des informations sur les “parameters régionaux actuels” ou une liste de tous les parameters régionaux disponibles.

En outre, en cours d’exécution

 $ locale 

donne …

 LANG= LC_COLLATE="C" LC_CTYPE="C" LC_MESSAGES="C" LC_MONETARY="C" LC_NUMERIC="C" LC_TIME="C" LC_ALL= 

Cependant, ni l’homme ni l’animateur ne mettent en lumière ce que font ces variables d’environnement. Je voudrais demander spécifiquement à quoi ces variables d’environnement sont nécessaires ou utilisées? (par exemple dans le contexte d’un logiciel exécuté sur ce système d’exploitation unix / linux possédant ces variables d’environnement)

La question: Qu’est-ce que cela signifie dans le contexte d’un logiciel qui s’exécute sur le système d’exploitation avec ces environnements locaux?

Oh, la page de manuel ( man 1 locale ) fait:

 LC_CTYPE Character classification and case conversion. LC_COLLATE Collation order. LC_TIME Date and time formats. LC_NUMERIC Non-monetary numeric formats. LC_MONETARY Monetary formats. LC_MESSAGES Formats of informative and diagnostic messages and interactive responses. 

Peut-être avez-vous cherché la page de manuel “locale” dans la mauvaise section? Ce sont les sections standard (voir man man )

 0 Header files (usually found in /usr/include) 1 Executable programs or shell commands 2 System calls (functions provided by the kernel) 3 Library calls (functions within program libraries) 4 Special files (usually found in /dev) 5 File formats and conventions eg /etc/passwd 6 Games 7 Miscellaneous (including macro packages and conven- tions), eg man(7), groff(7) 8 System administration commands (usually only for root) 9 Kernel routines [Non standard] 

donc, pour le binary de locale , vous devez regarder dans la section 1 : man 1 locale . Pour répondre pleinement à votre question, je cite la partie description de la page de manuel de locale:

 DESCRIPTION The locale utility shall write information about the current locale environment, or all public locales, to the standard output. For the purposes of this section, a public locale is one provided by the imple- mentation that is accessible to the application. When locale is invoked without any arguments, it shall summarize the current locale environment for each locale category as determined by the settings of the environment variables defined in the Base Defini- tions volume of IEEE Std 1003.1-2001, Chapter 7, Locale. When invoked with operands, it shall write values that have been assigned to the keywords in the locale categories, as follows: * Specifying a keyword name shall select the named keyword and the category containing that keyword. * Specifying a category name shall select the named category and all keywords in that category. 

Exemples ( LC_TIME et LC_MESSAGES ):

 $ export LC_TIME='fr_FR.UTF-8' #french time $ date mar. août 30 18:41:07 CEST 2011 $ export LC_TIME='de_DE.UTF-8' #german time $ date Di 30. Aug 18:41:12 CEST 2011 #english time $ export LC_TIME='en_US.UTF-8' $ date Tue Aug 30 18:41:17 CEST 2011 $ rm NON-EXIST rm: cannot remove `NON-EXIST': No such file or directory $ export LC_TIME='de_DE.UTF-8' #german time, but english MESSAGES $ rm NON-EXIST rm: cannot remove `NON-EXIST': No such file or directory $ export LC_MESSAGES='de_DE.UTF-8' #german messages $ rm NON-EXIST rm: cannot remove `NON-EXIST': Datei oder Verzeichnis nicht gefunden 

LC_COLLATE de sortinger les informations en fonction d’une langue. LC_MONETARY est le format de devise (US: $1.24 , europe: 1.24 € )

Locale régit beaucoup de choses, telles que:

  1. Codage en cours d’utilisation (c’est en_US.UTF-8 dire en_US.UTF-8 ou autre encodage classique)
  2. Fichiers de traduction à utiliser pour la bibliothèque standard ou d’autres applications.
  3. Internationalisation (formatage du numéro, devise, dates)

Les parameters régionaux C parameters régionaux par défaut. Il est généralement conseillé d’être plus précis et de faire fonctionner UTF-8 sous Linux.