* LocaleRoster.h was not self-containing.

* Moved the locale stuff to the data directory as well (some parts were in /etc).
* The DefaultCatalog will now also scan the user directory for catalogs.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33983 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-11-10 13:44:22 +00:00
parent c6106a595d
commit f9a80fec95
10 changed files with 75 additions and 82 deletions

View File

@ -276,7 +276,7 @@ actions ResAttr1
# linkcatkeys.
rule ExtractCatalogEntries target : source : signature
{
# get compiler and defines for the platform
# get compiler and defines for the platform
local headers ;
local sysHeaders ;
local cc ;
@ -381,6 +381,6 @@ rule DoCatalogs appName # Application name
: $(signature) : $(catalog:B) ;
}
AddFilesToHaikuImage system etc locale catalogs $(signature) :
AddFilesToHaikuImage system data locale catalogs $(signature) :
$(genCat) $(trans:S=.catalog) ;
}

View File

@ -384,7 +384,7 @@ SEARCH on $(spellFiles)
AddFilesToHaikuImage system etc word_dictionary : $(spellFiles) ;
# Locale kit language files
local languageDir = [ FDirName $(HAIKU_TOP) src data etc locale languages ] ;
local languageDir = [ FDirName $(HAIKU_TOP) src data locale languages ] ;
local languages = [ Glob $(languageDir) : *.language ] ;
AddFilesToHaikuImage system data locale languages : $(languages) ;
@ -491,17 +491,21 @@ AddFilesToHaikuImage system add-ons opengl
: Mesa\ Software\ Renderer ;
AddFilesToHaikuHybridImage system add-ons Translators
: $(SYSTEM_ADD_ONS_TRANSLATORS) : : true ;
AddFilesToHaikuImage system add-ons locale catalogs : $(SYSTEM_ADD_ONS_LOCALE_CATALOGS) ;
AddFilesToHaikuImage system add-ons locale catalogs
: $(SYSTEM_ADD_ONS_LOCALE_CATALOGS) ;
AddFilesToHaikuImage system add-ons mail_daemon inbound_protocols : POP3 IMAP ;
AddFilesToHaikuImage system add-ons mail_daemon outbound_protocols : SMTP ;
AddFilesToHaikuImage system add-ons mail_daemon inbound_filters : Match\ Header Spam\ Filter R5\ Daemon\ Filter ;
AddFilesToHaikuImage system add-ons mail_daemon inbound_filters
: Match\ Header Spam\ Filter R5\ Daemon\ Filter ;
AddFilesToHaikuImage system add-ons mail_daemon outbound_filters : Fortune ;
AddFilesToHaikuImage system add-ons mail_daemon system_filters : Inbox New\ Mail\ Notification Outbox Message\ Parser ;
AddFilesToHaikuImage system add-ons mail_daemon system_filters
: Inbox New\ Mail\ Notification Outbox Message\ Parser ;
AddFilesToHaikuImage system add-ons media : $(SYSTEM_ADD_ONS_MEDIA) ;
AddFilesToHaikuImage system add-ons media plugins
: $(SYSTEM_ADD_ONS_MEDIA_PLUGINS) ;
AddFilesToHaikuImage system add-ons Tracker
: FileType-F Mark\ as… Mark\ as\ Read-R Open\ Target\ Folder-O OpenTerminal-T ZipOMatic-Z ;
: FileType-F Mark\ as… Mark\ as\ Read-R Open\ Target\ Folder-O OpenTerminal-T
ZipOMatic-Z ;
AddSymlinkToHaikuImage system add-ons Tracker
: /boot/system/preferences/Backgrounds : Background-B ;
AddSymlinkToHaikuImage system add-ons Tracker

View File

@ -11,6 +11,7 @@ class BCollator;
class BCountry;
class BCatalog;
class BCatalogAddOn;
class BMessage;
struct entry_ref;

View File

@ -36,11 +36,10 @@ using std::max;
using std::pair;
/*
* This file implements the default catalog-type for the opentracker locale
* kit. Alternatively, this could be used as a full add-on, but currently this
* is provided as part of liblocale.so.
*/
/*! This file implements the default catalog-type for the opentracker locale
kit. Alternatively, this could be used as a full add-on, but currently this
is provided as part of liblocale.so.
*/
static const char *kCatFolder = "catalogs";
@ -52,13 +51,15 @@ const char *DefaultCatalog::kCatMimeType
static int16 kCatArchiveVersion = 1;
// version of the catalog archive structure, bump this if you change it!
const uint8 DefaultCatalog::kDefaultCatalogAddOnPriority = 1;
// give highest priority to our embedded catalog-add-on
/*
* constructs a DefaultCatalog with given signature and language and reads
* the catalog from disk.
* InitCheck() will be B_OK if catalog could be loaded successfully, it will
* give an appropriate error-code otherwise.
*/
/*! Constructs a DefaultCatalog with given signature and language and reads
the catalog from disk.
InitCheck() will be B_OK if catalog could be loaded successfully, it will
give an appropriate error-code otherwise.
*/
DefaultCatalog::DefaultCatalog(const char *signature, const char *language,
uint32 fingerprint)
:
@ -80,30 +81,26 @@ DefaultCatalog::DefaultCatalog(const char *signature, const char *language,
status_t status = ReadFromFile(catalogPath.Path());
if (status != B_OK) {
// look in common-etc folder (/boot/home/config/etc):
BPath commonEtcPath;
find_directory(B_COMMON_ETC_DIRECTORY, &commonEtcPath);
if (commonEtcPath.InitCheck() == B_OK) {
catalogName = BString(commonEtcPath.Path())
<< "/locale/" << kCatFolder
<< "/" << fSignature
<< "/" << fLanguageName
<< kCatExtension;
status = ReadFromFile(catalogName.String());
}
}
// search in data folders
if (status != B_OK) {
// look in system-etc folder (/boot/beos/etc):
BPath systemEtcPath;
find_directory(B_BEOS_ETC_DIRECTORY, &systemEtcPath);
if (systemEtcPath.InitCheck() == B_OK) {
catalogName = BString(systemEtcPath.Path())
<< "/locale/" << kCatFolder
<< "/" << fSignature
<< "/" << fLanguageName
<< kCatExtension;
status = ReadFromFile(catalogName.String());
directory_which which[] = {
B_USER_DATA_DIRECTORY,
B_COMMON_DATA_DIRECTORY,
B_SYSTEM_DATA_DIRECTORY
};
for (size_t i = 0; i < sizeof(which) / sizeof(which[0]); i++) {
BPath path;
if (find_directory(which[i], &path) == B_OK) {
catalogName = BString(path.Path())
<< "/locale/" << kCatFolder
<< "/" << fSignature
<< "/" << fLanguageName
<< kCatExtension;
status = ReadFromFile(catalogName.String());
if (status == B_OK)
break;
}
}
}
@ -114,12 +111,11 @@ DefaultCatalog::DefaultCatalog(const char *signature, const char *language,
}
/*
* constructs a DefaultCatalog and reads it from the resources of the
* given entry-ref (which usually is an app- or add-on-file).
* InitCheck() will be B_OK if catalog could be loaded successfully, it will
* give an appropriate error-code otherwise.
*/
/*! Constructs a DefaultCatalog and reads it from the resources of the
given entry-ref (which usually is an app- or add-on-file).
InitCheck() will be B_OK if catalog could be loaded successfully, it will
give an appropriate error-code otherwise.
*/
DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef)
:
BHashMapCatalog("", "", 0)
@ -131,11 +127,10 @@ DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef)
}
/*
* constructs an empty DefaultCatalog with given sig and language.
* This is used for editing/testing purposes.
* InitCheck() will always be B_OK.
*/
/*! Constructs an empty DefaultCatalog with given sig and language.
This is used for editing/testing purposes.
InitCheck() will always be B_OK.
*/
DefaultCatalog::DefaultCatalog(const char *path, const char *signature,
const char *language)
:
@ -387,10 +382,9 @@ DefaultCatalog::WriteToResource(entry_ref *appOrAddOnRef)
}
/*
* writes mimetype, language-name and signature of catalog into the
* catalog-file.
*/
/*! Writes mimetype, language-name and signature of catalog into the
catalog-file.
*/
void
DefaultCatalog::UpdateAttributes(BFile& catalogFile)
{
@ -581,7 +575,3 @@ DefaultCatalog::Create(const char *signature, const char *language)
}
return catalog;
}
const uint8 DefaultCatalog::kDefaultCatalogAddOnPriority = 1;
// give highest priority to our embedded catalog-add-on

View File

@ -1,7 +1,7 @@
/*
** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the MIT License.
*/
* Copyright 2003-2009, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
#include <Language.h>

View File

@ -1,10 +1,14 @@
/*
** Distributed under the terms of the OpenBeOS License.
** Copyright 2003-2004. All rights reserved.
**
** Authors: Axel Dörfler, axeld@pinc-software.de
** Oliver Tappe, zooey@hirschkaefer.de
*/
* Copyright 2003-2004, Haiku. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Axel Dörfler, axeld@pinc-software.de
* Oliver Tappe, zooey@hirschkaefer.de
*/
#include <LocaleRoster.h>
#include <set>
@ -23,7 +27,6 @@
#include <FindDirectory.h>
#include <Language.h>
#include <Locale.h>
#include <LocaleRoster.h>
#include <Node.h>
#include <Path.h>
#include <String.h>
@ -177,7 +180,7 @@ RosterData::RosterData()
InitializeCatalogAddOns();
// Load preferences to get the preffered languages
// Load preferences to get the preferred languages
BPath path;
BFile file;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {

View File

@ -1,7 +1,7 @@
/*
** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
* Copyright 2003-2009, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
#include "PropertyFile.h"
@ -10,18 +10,13 @@
#include <Path.h>
#include <FindDirectory.h>
#if B_BEOS_VERSION <= B_BEOS_VERSION_5 && !defined(__HAIKU__)
// B_BAD_DATA was introduced with DANO, so we define it for R5:
# define B_BAD_DATA -2147483632L
#endif
status_t
PropertyFile::SetTo(const char *directory, const char *name)
{
BPath path;
status_t status = find_directory(B_BEOS_ETC_DIRECTORY, &path);
if (status < B_OK)
status_t status = find_directory(B_BEOS_DATA_DIRECTORY, &path);
if (status != B_OK)
return status;
path.Append(directory);