xref: /haiku/src/system/libroot/add-ons/icu/ICUMessagesData.cpp (revision 17889a8c70dbb3d59c1412f6431968753c767bab)
1 /*
2  * Copyright 2010-2011, Oliver Tappe, zooey@hirschkaefer.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include "ICUMessagesData.h"
8 
9 #include <langinfo.h>
10 #include <string.h>
11 
12 
13 U_NAMESPACE_USE
14 
15 
16 namespace BPrivate {
17 namespace Libroot {
18 
19 
20 ICUMessagesData::ICUMessagesData(pthread_key_t tlsKey)
21 	: inherited(tlsKey)
22 {
23 }
24 
25 
26 void
27 ICUMessagesData::Initialize(LocaleMessagesDataBridge* dataBridge)
28 {
29 	fPosixLanginfo = dataBridge->posixLanginfo;
30 }
31 
32 
33 status_t
34 ICUMessagesData::SetTo(const Locale& locale, const char* posixLocaleName)
35 {
36 	status_t result = inherited::SetTo(locale, posixLocaleName);
37 
38 	// TODO: open the "POSIX" catalog and fetch the translations from there!
39 
40 	return result;
41 }
42 
43 
44 status_t
45 ICUMessagesData::SetToPosix()
46 {
47 	status_t result = inherited::SetToPosix();
48 
49 	strcpy(fYesExpression, fPosixLanginfo[YESEXPR]);
50 	strcpy(fNoExpression, fPosixLanginfo[NOEXPR]);
51 
52 	return result;
53 }
54 
55 
56 const char*
57 ICUMessagesData::GetLanginfo(int index)
58 {
59 	switch(index) {
60 		case YESEXPR:
61 			return fYesExpression;
62 		case NOEXPR:
63 			return fNoExpression;
64 		default:
65 			return "";
66 	}
67 }
68 
69 
70 }	// namespace Libroot
71 }	// namespace BPrivate
72