xref: /haiku/src/kits/locale/Locale.cpp (revision 58481f0f6ef1a61ba07283f012cafbc2ed874ead)
1 /*
2 ** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 ** Distributed under the terms of the OpenBeOS License.
4 */
5 
6 
7 #include <Catalog.h>
8 #include <Locale.h>
9 #include <LocaleRoster.h>
10 
11 
12 static BLocale gLocale;
13 BLocale *be_locale = &gLocale;
14 
15 
16 BLocale::BLocale()
17 {
18 	BLocaleRoster roster;
19 	roster.GetDefaultCollator(&fCollator);
20 	roster.GetDefaultCountry(&fCountry);
21 	roster.GetDefaultLanguage(&fLanguage);
22 }
23 
24 
25 BLocale::~BLocale()
26 {
27 }
28 
29 
30 const char *
31 BLocale::GetString(uint32 id)
32 {
33 	// Note: this code assumes a certain order of the string bases
34 
35 	if (id >= B_OTHER_STRINGS_BASE) {
36 		if (id == B_CODESET)
37 			return "UTF-8";
38 
39 		return "";
40 	}
41 	if (id >= B_LANGUAGE_STRINGS_BASE)
42 		return fLanguage->GetString(id);
43 
44 	return fCountry->GetString(id);
45 }
46 
47 status_t
48 BLocale::GetAppCatalog(BCatalog *catalog) {
49 	if (!catalog)
50 		return B_BAD_VALUE;
51 	if (be_catalog)
52 		debugger( "GetAppCatalog() has been called while be_catalog != NULL");
53 	return BCatalog::GetAppCatalog(catalog);
54 }
55