haiku/headers/os/locale/Language.h

64 lines
1.3 KiB
C
Raw Normal View History

/*
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
* Copyright 2003-2010, Haiku, Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _LANGUAGE_H_
#define _LANGUAGE_H_
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
#include <LocaleStrings.h>
#include <String.h>
#include <SupportDefs.h>
// We must not include the icu headers in there as it could mess up binary
// compatibility.
namespace icu_44 {
class Locale;
}
enum script_direction {
B_LEFT_TO_RIGHT = 0,
B_RIGHT_TO_LEFT,
B_TOP_TO_BOTTOM, // seems not to be supported anywhere else?
};
class BLanguage {
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
public:
BLanguage();
BLanguage(const char* language);
BLanguage(const BLanguage& other);
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
~BLanguage();
BLanguage& operator=(const BLanguage& source);
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
status_t GetName(BString& name) const;
status_t GetTranslatedName(BString& name) const;
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
// ISO-639 language code, e.g. "en", "de"
const char* Code() const;
const char* Country() const;
const char* Variant() const;
const char* ID() const;
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
bool IsCountrySpecific() const;
bool IsVariant() const;
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
uint8 Direction() const;
status_t SetTo(const char* language);
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
// see definitions below
const char* GetString(uint32 id) const;
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
private:
// BString fStrings[B_NUM_LANGUAGE_STRINGS];
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
uint8 fDirection;
icu_44::Locale* fICULocale;
};
* Changed BLocaleRoster::GetLanguage() to a signature that makes more sense, and looks more like the rest of the API. * Also, it will now return an appropriate error code if the language couldn't be allocated (anything else than B_OK is an improvement :-)). * Several changes in BLanguage: - GetName() now gets a BString reference, also - it now returns the name in its own language, ie. for German this would always be "deutsch", no matter the current language settings, and finally, - it now empties the string it gets before adding the name. - added GetTranslatedName() that behaves like the previous version. - added const where it made sense (ie. almost everywhere). - Code() now returns the code of the language only. - ID() now returns the full ID of this language, ie. including country, variant, and keywords if any. - added Country(), and Variant(). - renamed IsCountry() to IsCountrySpecific(). - added IsVariant(). * Cleaned up Language.h, minor cleanup in LocaleRoster.cpp. * Removed the whole move item logic from LanguageListView; while this was not only spaghetti code, it doesn't make much sense in the first place. * Instead of removing stuff from the left, and even worse, moving all countries for a language even if only one had been dragged, we now only mark the items that are already in the preferred list, and only those. * Fixed various mixups of FullList*() vs. *() methods that could lead to things like bug #5896. * Pressing the delete key in the preferred list view will now remove the language. * Moved LocaleWindow specific message constants to LocaleWindow.cpp; Locale.h is supposed to contain application wide constants. * The drop logic is now in LocaleWindow. * We now make sure that each base language can only be in the list once. * Lots of cleanup, even though I mostly replaced spaghettie code with different looking spaghettie code - still, I think things have slightly improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36727 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-07 21:38:40 +04:00
#endif // _LANGUAGE_H_