14
|
1 /**
|
|
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
|
|
3 * Authors: Jacob Carlborg
|
|
4 * Version: Initial created: Aug 3, 2009
|
|
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
|
|
6 */
|
|
7 module dstep.foundation.NSLocale;
|
|
8
|
|
9 import dstep.foundation.NSArray;
|
|
10 import dstep.foundation.NSDictionary;
|
|
11 import dstep.foundation.NSObject;
|
|
12 import dstep.foundation.NSString;
|
|
13 import dstep.objc.bridge.Bridge;
|
|
14 import dstep.objc.objc : id;
|
|
15
|
|
16 import bindings = dstep.foundation.NSLocale_bindings;
|
|
17
|
|
18 const NSString NSCurrentLocaleDidChangeNotification;
|
|
19 const NSString NSLocaleIdentifier;
|
|
20 const NSString NSLocaleLanguageCode;
|
|
21 const NSString NSLocaleCountryCode;
|
|
22 const NSString NSLocaleScriptCode;
|
|
23 const NSString NSLocaleVariantCode;
|
|
24 const NSString NSLocaleExemplarCharacterSet;
|
|
25 const NSString NSLocaleCalendar;
|
|
26 const NSString NSLocaleCollationIdentifier;
|
|
27 const NSString NSLocaleUsesMetricSystem;
|
|
28 const NSString NSLocaleMeasurementSystem;
|
|
29 const NSString NSLocaleDecimalSeparator;
|
|
30 const NSString NSLocaleGroupingSeparator;
|
|
31 const NSString NSLocaleCurrencySymbol;
|
|
32 const NSString NSLocaleCurrencyCode;
|
|
33 const NSString NSGregorianCalendar;
|
|
34 const NSString NSBuddhistCalendar;
|
|
35 const NSString NSChineseCalendar;
|
|
36 const NSString NSHebrewCalendar;
|
|
37 const NSString NSIslamicCalendar;
|
|
38 const NSString NSIslamicCivilCalendar;
|
|
39 const NSString NSJapaneseCalendar;
|
|
40
|
|
41 static this ()
|
|
42 {
|
|
43 NSCurrentLocaleDidChangeNotification = new NSString(bindings.NSCurrentLocaleDidChangeNotification);
|
|
44 NSLocaleIdentifier = new NSString(bindings.NSLocaleIdentifier);
|
|
45 NSLocaleLanguageCode = new NSString(bindings.NSLocaleLanguageCode);
|
|
46 NSLocaleCountryCode = new NSString(bindings.NSLocaleCountryCode);
|
|
47 NSLocaleScriptCode = new NSString(bindings.NSLocaleScriptCode);
|
|
48 NSLocaleVariantCode = new NSString(bindings.NSLocaleVariantCode);
|
|
49 NSLocaleExemplarCharacterSet = new NSString(bindings.NSLocaleExemplarCharacterSet);
|
|
50 NSLocaleCalendar = new NSString(bindings.NSLocaleCalendar);
|
|
51 NSLocaleCollationIdentifier = new NSString(bindings.NSLocaleCollationIdentifier);
|
|
52 NSLocaleUsesMetricSystem = new NSString(bindings.NSLocaleUsesMetricSystem);
|
|
53 NSLocaleMeasurementSystem = new NSString(bindings.NSLocaleMeasurementSystem);
|
|
54 NSLocaleDecimalSeparator = new NSString(bindings.NSLocaleDecimalSeparator);
|
|
55 NSLocaleGroupingSeparator = new NSString(bindings.NSLocaleGroupingSeparator);
|
|
56 NSLocaleCurrencySymbol = new NSString(bindings.NSLocaleCurrencySymbol);
|
|
57 NSLocaleCurrencyCode = new NSString(bindings.NSLocaleCurrencyCode);
|
|
58 NSGregorianCalendar = new NSString(bindings.NSGregorianCalendar);
|
|
59 NSBuddhistCalendar = new NSString(bindings.NSBuddhistCalendar);
|
|
60 NSChineseCalendar = new NSString(bindings.NSChineseCalendar);
|
|
61 NSHebrewCalendar = new NSString(bindings.NSHebrewCalendar);
|
|
62 NSIslamicCalendar = new NSString(bindings.NSIslamicCalendar);
|
|
63 NSIslamicCivilCalendar = new NSString(bindings.NSIslamicCivilCalendar);
|
|
64 NSJapaneseCalendar = new NSString(bindings.NSJapaneseCalendar);
|
|
65 }
|
|
66
|
|
67 class NSLocale : NSObject, INSCopying, INSCoding
|
|
68 {
|
|
69 mixin ObjcWrap;
|
|
70 mixin TNSLocaleCreation;
|
|
71 mixin TNSLocaleGeneralInfo;
|
|
72 mixin TNSExtendedLocale;
|
|
73
|
|
74 Object objectForKey (Object key)
|
|
75 {
|
|
76 return invokeObjcSelf!(Object, "objectForKey:", Object)(key);
|
|
77 }
|
|
78
|
|
79 NSString displayNameForKey (Object key, Object value)
|
|
80 {
|
|
81 return invokeObjcSelf!(NSString, "displayNameForKey:value:", Object, Object)(key, value);
|
|
82 }
|
|
83
|
|
84 Object copyWithZone (NSZone* zone)
|
|
85 {
|
|
86 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);
|
|
87 }
|
|
88
|
|
89 void encodeWithCoder (NSCoder aCoder)
|
|
90 {
|
|
91 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
|
|
92 }
|
|
93
|
|
94 Object initWithCoder (NSCoder aDecoder)
|
|
95 {
|
|
96 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder);
|
|
97 }
|
|
98
|
|
99 this (NSCoder aDecoder)
|
|
100 {
|
|
101 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
102 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder);
|
|
103
|
|
104 if (result)
|
|
105 objcObject = ret;
|
|
106
|
|
107 dObject = this;
|
|
108 }
|
|
109 }
|
|
110
|
|
111 template TNSLocaleCreation ()
|
|
112 {
|
|
113 static Object systemLocale ()
|
|
114 {
|
|
115 return invokeObjcSelfClass!(Object, "systemLocale");
|
|
116 }
|
|
117
|
|
118 static Object currentLocale ()
|
|
119 {
|
|
120 return invokeObjcSelfClass!(Object, "currentLocale");
|
|
121 }
|
|
122
|
|
123 static Object autoupdatingCurrentLocale ()
|
|
124 {
|
|
125 return invokeObjcSelfClass!(Object, "autoupdatingCurrentLocale");
|
|
126 }
|
|
127
|
|
128 Object initWithLocaleIdentifier (NSString string)
|
|
129 {
|
|
130 return invokeObjcSelf!(Object, "initWithLocaleIdentifier:", NSString)(string);
|
|
131 }
|
|
132
|
|
133 this (NSString string)
|
|
134 {
|
|
135 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
136 id result = Bridge.invokeObjcMethod!(id, "initWithLocaleIdentifier:", NSString)(objcObject, string);
|
|
137
|
|
138 if (result)
|
|
139 objcObject = ret;
|
|
140
|
|
141 dObject = this;
|
|
142 }
|
|
143 }
|
|
144
|
|
145 template TNSLocaleGeneralInfo ()
|
|
146 {
|
|
147 static NSArray availableLocaleIdentifiers ()
|
|
148 {
|
|
149 return invokeObjcSelfClass!(NSArray, "availableLocaleIdentifiers");
|
|
150 }
|
|
151
|
|
152 static NSArray ISOLanguageCodes ()
|
|
153 {
|
|
154 return invokeObjcSelfClass!(NSArray, "ISOLanguageCodes");
|
|
155 }
|
|
156
|
|
157 static NSArray ISOCountryCodes ()
|
|
158 {
|
|
159 return invokeObjcSelfClass!(NSArray, "ISOCountryCodes");
|
|
160 }
|
|
161
|
|
162 static NSArray ISOCurrencyCodes ()
|
|
163 {
|
|
164 return invokeObjcSelfClass!(NSArray, "ISOCurrencyCodes");
|
|
165 }
|
|
166
|
|
167 static NSArray commonISOCurrencyCodes ()
|
|
168 {
|
|
169 return invokeObjcSelfClass!(NSArray, "commonISOCurrencyCodes");
|
|
170 }
|
|
171
|
|
172 static NSArray preferredLanguages ()
|
|
173 {
|
|
174 return invokeObjcSelfClass!(NSArray, "preferredLanguages");
|
|
175 }
|
|
176
|
|
177 static NSDictionary componentsFromLocaleIdentifier (NSString string)
|
|
178 {
|
|
179 return invokeObjcSelfClass!(NSDictionary, "componentsFromLocaleIdentifier:", NSString)(string);
|
|
180 }
|
|
181
|
|
182 static NSString localeIdentifierFromComponents (NSDictionary dict)
|
|
183 {
|
|
184 return invokeObjcSelfClass!(NSString, "localeIdentifierFromComponents:", NSDictionary)(dict);
|
|
185 }
|
|
186
|
|
187 static NSString canonicalLocaleIdentifierFromString (NSString string)
|
|
188 {
|
|
189 return invokeObjcSelfClass!(NSString, "canonicalLocaleIdentifierFromString:", NSString)(string);
|
|
190 }
|
|
191 }
|
|
192
|
|
193 template TNSExtendedLocale ()
|
|
194 {
|
|
195 NSString localeIdentifier ()
|
|
196 {
|
|
197 return invokeObjcSelf!(NSString, "localeIdentifier");
|
|
198 }
|
|
199 }
|
|
200
|