haiku/headers/private/locale/MutableLocaleRoster.h
Adrien Destugues 41853a8bbf locale kit: allow creating a catalog without entry_ref
The catalogs are loaded from separate files, so there is no need to have
an app entry_ref to load them, just a MIME type is enough.

The implementation is a bit simplified: only the default catalog format
is allowed (unlike when loading from entry_ref, where extra catalog
formats can be added in add-ons).

Unrelated cleanup: remove unused code to load catalogs from attributes
of an application. We considered this when designing the locale kit, but
using resources or separate files works better.

Use this in Cortex, where some strings are in a static library, so they
don't have an associated executable or library or add-on to identify
them. The code in Cortex is not complete localization, several parts
should use StringForRate, BStringFormat, etc.

Change-Id: I09be22b1f50891250c4497c51e1db8dcee279140
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3172
Reviewed-by: Kacper Kasper <kacperkasper@gmail.com>
2020-09-01 18:14:57 +00:00

69 lines
1.6 KiB
C++

/*
* Copyright 2010-2012, Haiku. All rights reserved.
* Distributed under the terms of the MIT license.
*/
#ifndef _MUTABLE_LOCALE_ROSTER_H_
#define _MUTABLE_LOCALE_ROSTER_H_
#include <Collator.h>
#include <FormattingConventions.h>
#include <image.h>
#include <Language.h>
#include <List.h>
#include <Locale.h>
#include <Locker.h>
#include <LocaleRoster.h>
#include <Message.h>
#include <Resources.h>
#include <TimeZone.h>
class BLocale;
class BCatalog;
class BCatalogData;
struct entry_ref;
namespace BPrivate {
class MutableLocaleRoster : public BLocaleRoster {
public:
MutableLocaleRoster();
~MutableLocaleRoster();
static MutableLocaleRoster* Default();
status_t SetDefaultFormattingConventions(
const BFormattingConventions& conventions);
status_t SetDefaultTimeZone(const BTimeZone& zone);
status_t SetPreferredLanguages(const BMessage* message);
// the message contains one or more
// 'language'-string-fields which
// contain the language-name(s)
status_t SetFilesystemTranslationPreferred(
bool preferred);
status_t LoadSystemCatalog(BCatalog* catalog) const;
BCatalogData* LoadCatalog(const entry_ref& catalogOwner,
const char* language = NULL,
int32 fingerprint = 0) const;
BCatalogData* LoadCatalog(const char* signature,
const char* language = NULL) const;
status_t UnloadCatalog(BCatalogData* catalogData);
BCatalogData* CreateCatalog(const char* type,
const char* signature,
const char* language);
};
} // namespace BPrivate
#endif // _MUTABLE_LOCALE_ROSTER_H_