41853a8bbf
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>
76 lines
2.0 KiB
C++
76 lines
2.0 KiB
C++
/*
|
|
* Copyright 2009, Adrien Destugues, pulkomandy@gmail.com.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef _DEFAULT_CATALOG_H_
|
|
#define _DEFAULT_CATALOG_H_
|
|
|
|
|
|
#include <DataIO.h>
|
|
#include <HashMapCatalog.h>
|
|
#include <String.h>
|
|
|
|
|
|
class BFile;
|
|
|
|
namespace BPrivate {
|
|
|
|
|
|
/*
|
|
* The implementation of the Locale Kit's standard catalog-type.
|
|
* Currently it only maps CatKey to a BString (the translated string),
|
|
* but the value-type might change to add support for shortcuts and/or
|
|
* graphical data (button-images and the like).
|
|
*/
|
|
class DefaultCatalog : public HashMapCatalog {
|
|
public:
|
|
DefaultCatalog(const entry_ref &catalogOwner, const char *language,
|
|
uint32 fingerprint);
|
|
// constructor for normal use
|
|
DefaultCatalog(entry_ref *appOrAddOnRef);
|
|
// constructor for embedded catalog
|
|
DefaultCatalog(const char *path, const char *signature,
|
|
const char *language);
|
|
// constructor for editor-app
|
|
|
|
~DefaultCatalog();
|
|
|
|
// implementation for editor-interface:
|
|
status_t ReadFromFile(const char *path = NULL);
|
|
status_t ReadFromResource(const entry_ref &appOrAddOnRef);
|
|
status_t WriteToFile(const char *path = NULL);
|
|
status_t WriteToResource(const entry_ref &appOrAddOnRef);
|
|
|
|
status_t ReadFromStandardLocations();
|
|
|
|
status_t SetRawString(const CatKey& key, const char *translated);
|
|
void SetSignature(const entry_ref &catalogOwner);
|
|
|
|
static BCatalogData *Instantiate(const entry_ref& catalogOwner,
|
|
const char *language, uint32 fingerprint);
|
|
static BCatalogData *Create(const char *signature,
|
|
const char *language);
|
|
|
|
static const uint8 kDefaultCatalogAddOnPriority;
|
|
static const char *kCatMimeType;
|
|
|
|
private:
|
|
status_t Flatten(BDataIO *dataIO);
|
|
status_t Unflatten(BDataIO *dataIO);
|
|
void UpdateAttributes(BFile& catalogFile);
|
|
|
|
mutable BString fPath;
|
|
};
|
|
|
|
|
|
extern "C" status_t
|
|
default_catalog_get_available_languages(BMessage* availableLanguages,
|
|
const char* sigPattern, const char* langPattern = NULL,
|
|
int32 fingerprint = 0);
|
|
|
|
|
|
} // namespace BPrivate
|
|
|
|
|
|
#endif /* _DEFAULT_CATALOG_H_ */
|