xref: /haiku/src/system/libroot/add-ons/icu/ICUMessagesData.cpp (revision 002f37b0cca92e4cf72857c72ac95db5a8b09615)
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 namespace BPrivate {
14 namespace Libroot {
15 
16 
17 ICUMessagesData::ICUMessagesData(pthread_key_t tlsKey)
18 	: inherited(tlsKey)
19 {
20 }
21 
22 
23 void
24 ICUMessagesData::Initialize(LocaleMessagesDataBridge* dataBridge)
25 {
26 	fPosixLanginfo = dataBridge->posixLanginfo;
27 }
28 
29 
30 status_t
31 ICUMessagesData::SetTo(const Locale& locale, const char* posixLocaleName)
32 {
33 	status_t result = inherited::SetTo(locale, posixLocaleName);
34 
35 	// TODO: open the "POSIX" catalog and fetch the translations from there!
36 
37 	return result;
38 }
39 
40 
41 status_t
42 ICUMessagesData::SetToPosix()
43 {
44 	status_t result = inherited::SetToPosix();
45 
46 	strcpy(fYesExpression, fPosixLanginfo[YESEXPR]);
47 	strcpy(fNoExpression, fPosixLanginfo[NOEXPR]);
48 
49 	return result;
50 }
51 
52 
53 const char*
54 ICUMessagesData::GetLanginfo(int index)
55 {
56 	switch(index) {
57 		case YESEXPR:
58 			return fYesExpression;
59 		case NOEXPR:
60 			return fNoExpression;
61 		default:
62 			return "";
63 	}
64 }
65 
66 
67 }	// namespace Libroot
68 }	// namespace BPrivate
69