| 1 |
@comment{ $Source: e:\\cvsroot/ARM/Source/pre_locales.mss,v $ } |
| 2 |
@comment{ $Revision: 1.9 $ $Date: 2015/04/03 04:12:42 $ $Author: randy $ } |
| 3 |
@Part(predefenviron, Root="ada.mss") |
| 4 |
|
| 5 |
@Comment{$Date: 2015/04/03 04:12:42 $} |
| 6 |
|
| 7 |
@LabeledAddedClause{Version=[3],Name=[The Package Locales]} |
| 8 |
|
| 9 |
@begin{Intro} |
| 10 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0127-2],ARef=[AI05-0248-1]} |
| 11 |
@ChgAdded{Version=[3],Text=[A @i{locale}@Defn{locale} identifies a geopolitical |
| 12 |
place or region and its associated language, which can be used to determine |
| 13 |
other internationalization-related characteristics.]} |
| 14 |
@end{Intro} |
| 15 |
|
| 16 |
@begin{StaticSem} |
| 17 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0127-2]} |
| 18 |
@ChgAdded{Version=[3],KeepNext=[T],Type=[Leading],Text=[The library package |
| 19 |
Locales has the following declaration:]} |
| 20 |
@begin{Example} |
| 21 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 22 |
@ChgAdded{Version=[3],Text=[@key{package} Ada.Locales @key{is}@ChildUnit{Parent=[Ada],Child=[Locales]} |
| 23 |
@key{pragma} Preelaborate(Locales); |
| 24 |
@key{pragma} Remote_Types(Locales);]} |
| 25 |
|
| 26 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 27 |
@ChgRef{Version=[4],Kind=[Revised],ARef=[AI12-0037-1]} |
| 28 |
@ChgAdded{Version=[3],Text=[ @key[type] @AdaTypeDefn{Language_Code} @key[is @Chg{Version=[4],New=[new],Old=[array]}] @Chg{Version=[4],New=[String ],Old=[]}(1 .. 3)@Chg{Version=[4],New=[ |
| 29 |
@key[with] Dynamic_Predicate => |
| 30 |
(@key[for all] E @key[of] Language_Code => E @key[in]],Old=[ @key[of] Character @key[range]]} 'a' .. 'z'@Chg{Version=[4],New=[)],Old=[]}; |
| 31 |
@key[type] @AdaTypeDefn{Country_Code} @key[is @Chg{Version=[4],New=[new],Old=[array]}] @Chg{Version=[4],New=[String ],Old=[]}(1 .. 2)@Chg{Version=[4],New=[ |
| 32 |
@key[with] Dynamic_Predicate => |
| 33 |
(@key[for all] E @key[of] Country_Code => E @key[in]],Old=[ @key[of] Character @key[range]]} 'A' .. 'Z'@Chg{Version=[4],New=[)],Old=[]};]} |
| 34 |
|
| 35 |
@begin{Discussion} |
| 36 |
@ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0037-1]} |
| 37 |
@ChgAdded{Version=[4],Text=[These types are derived from type |
| 38 |
String so that they can easily be converted to or from type String. That's |
| 39 |
important if one of these values needs to be input or displayed (via Text_IO, |
| 40 |
perhaps). We use the predicate to ensure that only possible component values |
| 41 |
are used. Ada does not allow converting between unrelated types with |
| 42 |
components that don't statically match, so we cannot declare new types with |
| 43 |
constrained components if we want conversions to or from type String.]} |
| 44 |
@end{Discussion} |
| 45 |
|
| 46 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 47 |
@ChgAdded{Version=[3],Text=[ @AdaObjDefn{Language_Unknown} : @key[constant] Language_Code := "und"; |
| 48 |
@AdaObjDefn{Country_Unknown} : @key[constant] Country_Code := "ZZ";]} |
| 49 |
|
| 50 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 51 |
@ChgAdded{Version=[3],Text=[ @key[function] @AdaSubDefn{Language} @key[return] Language_Code; |
| 52 |
@key[function] @AdaSubDefn{Country} @key[return] Country_Code;]} |
| 53 |
|
| 54 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 55 |
@ChgAdded{Version=[3],Text=[@key[end] Ada.Locales;]} |
| 56 |
@end{Example} |
| 57 |
|
| 58 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0127-2],ARef=[AI05-0233-1]} |
| 59 |
@ChgAdded{Version=[3],Text=[The @i{active locale}@Defn{active |
| 60 |
locale}@Defn2{Term=[locale],Sec=[active]} is the locale associated with the |
| 61 |
partition of the current task.]} |
| 62 |
|
| 63 |
@begin{ImplNote} |
| 64 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0233-1]} |
| 65 |
@ChgAdded{Version=[3],Text=[Some environments define both a system locale and |
| 66 |
the locale of the current user. For such environments, the active locale is |
| 67 |
that of current user if any; otherwise (as in a partition running on a server |
| 68 |
without a user), the system locale should be used.]} |
| 69 |
@end{ImplNote} |
| 70 |
|
| 71 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0127-2]} |
| 72 |
@ChgAdded{Version=[3],Text=[Language_Code is a lower-case string representation |
| 73 |
of an ISO 639-3 alpha-3 code that identifies a language.]} |
| 74 |
|
| 75 |
@begin{Discussion} |
| 76 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 77 |
@ChgAdded{Version=[3],Text=[Some common language codes are: "eng" @en English; |
| 78 |
"fra" @en French; "deu" @en German; "zho" @en Chinese. These are the same |
| 79 |
codes as used by POSIX systems. We considered including |
| 80 |
constants for the most common languages, but that was rejected as the |
| 81 |
likely source of continual arguments about the constant names and which |
| 82 |
languages are important enough to include.]} |
| 83 |
@end{Discussion} |
| 84 |
|
| 85 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0127-2]} |
| 86 |
@ChgAdded{Version=[3],Text=[Country_Code is an upper-case string representation |
| 87 |
of an ISO 3166-1 alpha-2 code that identifies a country.]} |
| 88 |
|
| 89 |
@begin{Discussion} |
| 90 |
@ChgRef{Version=[3],Kind=[AddedNormal]} |
| 91 |
@ChgAdded{Version=[3],Text=[Some common country codes are: "CA" @en Canada; |
| 92 |
"FR" @en France; "DE" @en Germany; "IT" @en Italy; "ES" @en Spain; |
| 93 |
"GB" @en United Kingdom; "US" @en United States. These are the same codes |
| 94 |
as used by POSIX systems. We didn't include any |
| 95 |
country constants for the same reasons that we didn't include any language |
| 96 |
constants.]} |
| 97 |
@end{Discussion} |
| 98 |
|
| 99 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0127-2],ARef=[AI05-0248-1]} |
| 100 |
@ChgAdded{Version=[3],Text=[Function Language returns the code of the language |
| 101 |
associated with the active locale. If the Language_Code associated with the |
| 102 |
active locale cannot be determined from the environment, then Language returns |
| 103 |
Language_Unknown.]} |
| 104 |
|
| 105 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0127-2],ARef=[AI05-0248-1]} |
| 106 |
@ChgAdded{Version=[3],Text=[Function Country returns the code of the country |
| 107 |
associated with the active locale. If the Country_Code associated with the |
| 108 |
active locale cannot be determined from the environment, then Country returns |
| 109 |
Country_Unknown.]} |
| 110 |
|
| 111 |
@end{StaticSem} |
| 112 |
|
| 113 |
@begin{Extend2005} |
| 114 |
@ChgRef{Version=[3],Kind=[AddedNormal],ARef=[AI05-0127-2],ARef=[AI05-0233-1]} |
| 115 |
@ChgAdded{Version=[3],Text=[@Defn{extensions to Ada 2005} |
| 116 |
Package Locales is new.]} |
| 117 |
@end{Extend2005} |
| 118 |
|
| 119 |
@begin{Inconsistent2012} |
| 120 |
@ChgRef{Version=[4],Kind=[AddedNormal],ARef=[AI12-0037-1]} |
| 121 |
@ChgAdded{Version=[4],Text=[@Defn{inconsistencies with Ada 2012}@b<Corrigendum:> |
| 122 |
Types Language_Code and Country_Code are defined with predicates rather than |
| 123 |
constrained components so that they can be converted to/from type String. |
| 124 |
This changes the exception raised from Constraint_Error to Assertion_Error |
| 125 |
if an assignment is attempted with an incorrect value. This could only |
| 126 |
matter if there is a handler specifically for Constraint_Error surrounding |
| 127 |
this assignment; as this exception raise is certainly caused by a bug |
| 128 |
(why would anyone want to use invalid language or country codes?), such a |
| 129 |
handler seems very unlikely. (In addition, this is a new Ada 2012 package, |
| 130 |
so there is not likely to be a lot of code using it.)]} |
| 131 |
@end{Inconsistent2012} |
| 132 |
|