Debian Codegraph @

debian/missing-sources/locale_config/README.md

raw symbols SCIP
1 [![TravisCI Build Status](https://travis-ci.org/rust-locale/locale_config.svg?branch=master)](https://travis-ci.org/rust-locale/locale_config)
2 [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/13100wtqs80tyink/branch/master?svg=true)](https://ci.appveyor.com/project/jan-hudec/locale-config/branch/master)
3 [![Crates.io Version](https://img.shields.io/crates/v/locale_config.svg)](https://crates.io/crates/locale_config)
4 [![Docs.rs](https://docs.rs/locale_config/badge.svg)](https://docs.rs/locale_config/)
5
6 # `locale_config`
7
8 Remembers locale configuration per-thread and per-process and initializes the
9 values by inspecting the system for user preferences.
10
11 ## Installation
12
13 You can depend on this library by adding `locale_config` to your Cargo dependencies:
14
15 ```toml
16 [dependencies]
17 locale_config = "*"
18 ```
19
20 Usually it is not recommended to depend on `*`, but in this case it is
21 important that incompatible version requirements don't cause multiple
22 versions to be pulled in the final binary, so I do recommend it here and
23 promise I will maintain good compatibility. Just please don't add traits to
24 the types defined here to avoid conflicts with potential future methods.
25
26 ## Using
27
28 Usually you want to use this indirectly via a localization crate like
29 `locale`. However if you need to work with the identifier itself, or you need
30 to override it, use
31
32 ```rust
33 Locale::current()
34 ```
35
36 to find what you should be using at any given point in the application,
37
38 ```rust
39 Locale::set_current()
40 ```
41
42 to override it for current thread and
43
44 ```rust
45 Locale::set_global_default()
46 ```
47
48 to override it for new threads.
49
50 In case you need to access the initial value, you'll find it under
51
52 ```rust
53 Locale::user_default()
54 ```
55
56 The value may contain language tags specific for various localization
57 aspects, called categories, and fallbacks. The `Locale::tags_for` method will
58 take care of selecting relevant tags for you. For preferred language of
59 translations, use
60
61 ```rust
62 Locale::current().tags_for("messages")
63 ```
64
65 For formatting, use categories `"numeric"` for numbers, `"time"` for date and
66 time and `"monetary"` for money amounts. And use `"collate"` for collation.
67
68 Note that this crate does not itself provide any translation, formatting nor
69 collation functionality. Formatting and collation will be provided by
70 `locale` crate, translation has multiple available implementations.
71
72 See full documentation on [![Docs.rs](https://docs.rs/locale_config/badge.svg)](https://docs.rs/locale_config/) or [github](https://rust-locale.github.io/locale_config/locale_config/).
73
74 ## Supported systems
75
76 * **Unix:** Using the POSIX standard environment variables `LANG`, `LC_*` and
77 `LANGUAGES`. The variables are recognized on all systems and take
78 precedence on most of them.
79
80 * **Windows:** Vista and newer
81
82 - Uses API available from Vista and Server 2008 only.
83 - The `GetUserPreferredUILanguages` is only available for desktop, but
84 not store applications. Store applications should have equivalent
85 functionality, but I didn't try accessing it from Rust yet.
86 - Customization to individual locale elements done in “Regional and
87 Language options” (digits, calendar, decimal and thousand separator
88 etc.) are not detected (yet).
89 - Not well tested.
90
91 * **OS X:** Reads setting from `NSLocale`, can be overridden by setting the
92 Unix environment variables.
93
94 * **CGI:** The `HTTP_ACCEPT_LANGUAGE` environment variable is used if
95 detected. Hopefully it is specific enough to the CGI environment that it
96 can be used whenever detected.
97
98 ## Changelog
99
100 ### 0.3.0
101
102 * Support OS X `NSLocale`.
103 Thanks Sophie Tauchert (@999eagle).
104
105 ### 0.2.3
106
107 * Try support getting locale in emscripten targets in browser. Unfortunately
108 the emscripten targets seem to have broken in cross meanwhile, so they are not
109 being tested.
110 * Update to winapi 0.3.
111 * Update ro regex 1.0.
112
113 ### 0.2.2
114
115 * Update dependencies: regex 0.2.
116
117 ### 0.2.1
118
119 * Interpret some overrides that can be set on Windows in Region and Language
120 dialog, namely: group, decimal and list separators, first day of week,
121 12/24-hour time, measurement system, (decimal) number system, to an extent
122 negative monetary value format (only whether to use parenthesized format
123 or not) and to an extent date format (if ISO-8601 variant is selected).
124
125 ### 0.2.0
126
127 * Changed error handling to proper error type.
128
129 ### 0.1.1
130
131 * Added basic Windows support.
132
133 ### 0.1.0
134
135 * Initial version, with Unix and CGI support.