Skip to content

Commit

Permalink
More catalog-related cleanup.
Browse files Browse the repository at this point in the history
* rename B_TRANSLATE_CONTEXT to B_TRANSLATION_CONTEXT and
  B_TRANSLATE_WITH_CONTEXT to B_TRANSLATE_CONTEXT, squashing a TODO
* adjust all uses of both macros in Haiku's source tree
* use correct header guard for collecting/Catalog.h

The renamed macros require adjustments to all external applications
using catalogs.
  • Loading branch information
olta committed Apr 16, 2012
1 parent 3244c2b commit 546208a
Show file tree
Hide file tree
Showing 521 changed files with 1,171 additions and 1,165 deletions.
4 changes: 2 additions & 2 deletions docs/develop/makefile-engine.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ <h2>Contents</h2>
<pre><code>#include &lt;stdio.h&gt;
#include &lt;Catalog.h&gt;

#undef B_TRANSLATE_CONTEXT
#ifdef B_TRANSLATE_CONTEXT "hello"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "hello"

int main(void)
{
Expand Down
2 changes: 1 addition & 1 deletion docs/user/locale/Catalog.dox
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

\section macros Using the macros
You don't have to do much in your program to handle catalogs. You must
first set the B_TRANSLATE_CONTEXT define to a string that identifies which
first set the B_TRANSLATION_CONTEXT define to a string that identifies which
part of the application the strings you will translate are in. This allows
the translators to keep track of the strings in the catalog more easily,
and find where they are visible in the application. then, all you have to
Expand Down
24 changes: 11 additions & 13 deletions headers/os/locale/Catalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,16 @@ class BCatalog {
};


#undef B_TRANSLATE_SYSTEM_NAME_CONTEXT
#define B_TRANSLATE_SYSTEM_NAME_CONTEXT "System name"
#undef B_TRANSLATION_SYSTEM_NAME_CONTEXT
#define B_TRANSLATION_SYSTEM_NAME_CONTEXT "System name"


#ifndef B_AVOID_TRANSLATION_MACROS
// macros for easy catalog-access, define B_AVOID_TRANSLATION_MACROS if
// you don't want these (in which case you need to collect the catalog keys
// manually, as collectcatkeys won't do it for you):

// TODO: maybe rename this to B_TRANSLATE_DEFAULT_CONTEXT, so that
// B_TRANSLATE_WITH_CONTEXT() can just be called B_TRANSLATE_CONTEXT()
#undef B_TRANSLATE_CONTEXT
#undef B_TRANSLATION_CONTEXT
// In a single application, several strings (e.g. 'Ok') will be used
// more than once, in different contexts.
// As the application programmer can not know if all translations of
Expand All @@ -81,27 +79,27 @@ class BCatalog {
// same string and tell which strings appears in what context of the
// application.
// In order to give the translator a useful hint, the application
// programmer needs to define B_TRANSLATE_CONTEXT with the context he'd
// programmer needs to define B_TRANSLATION_CONTEXT with the context he'd
// like to be associated with the strings used in this specifc source file.
// example:
// #define B_TRANSLATE_CONTEXT "Folder-Window"
// #define B_TRANSLATION_CONTEXT "Folder-Window"
// Tip: Use a descriptive name of the class implemented in that
// source-file.

// Translation macros which may be used to shorten translation requests:
#undef B_TRANSLATE
#define B_TRANSLATE(string) \
BLocaleRoster::Default()->GetCatalog()->GetString((string), \
B_TRANSLATE_CONTEXT)
B_TRANSLATION_CONTEXT)

#undef B_TRANSLATE_WITH_CONTEXT
#define B_TRANSLATE_WITH_CONTEXT(string, context) \
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT(string, context) \
BLocaleRoster::Default()->GetCatalog()->GetString((string), (context))

#undef B_TRANSLATE_COMMENT
#define B_TRANSLATE_COMMENT(string, comment) \
BLocaleRoster::Default()->GetCatalog()->GetString((string), \
B_TRANSLATE_CONTEXT, (comment))
B_TRANSLATION_CONTEXT, (comment))

#undef B_TRANSLATE_ALL
#define B_TRANSLATE_ALL(string, context, comment) \
Expand All @@ -116,13 +114,13 @@ class BCatalog {
#define B_TRANSLATE_SYSTEM_NAME(string) \
BLocaleRoster::Default()->IsFilesystemTranslationPreferred() \
? BLocaleRoster::Default()->GetCatalog()->GetString((string), \
B_TRANSLATE_SYSTEM_NAME_CONTEXT) \
B_TRANSLATION_SYSTEM_NAME_CONTEXT) \
: (string)

// Translation markers which can be used to mark static strings/IDs which
// are used as key for translation requests (at other places in the code).
/* Example:
#define B_TRANSLATE_CONTEXT "MyDecentApp-Menu"
#define B_TRANSLATION_CONTEXT "MyDecentApp-Menu"
static const char* choices[] = {
B_TRANSLATE_MARK("left"),
Expand Down
30 changes: 15 additions & 15 deletions headers/private/locale/collecting/Catalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
* Copyright 2012, Haiku, Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _CATALOG_COLLECTOR_H_
#define _CATALOG_COLLECTOR_H_
#ifndef _COLLECTING_CATALOG_H_
#define _COLLECTING_CATALOG_H_


#include_next <Catalog.h>


// Translation macros used when executing collectcatkeys
#undef B_TRANSLATE_CONTEXT
#undef B_TRANSLATION_CONTEXT

#undef B_TRANSLATE
#define B_TRANSLATE(string) \
B_CATKEY((string), B_TRANSLATE_CONTEXT)
B_CATKEY((string), B_TRANSLATION_CONTEXT)

#undef B_TRANSLATE_WITH_CONTEXT
#define B_TRANSLATE_WITH_CONTEXT(string, context) \
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT(string, context) \
B_CATKEY((string), (context))

#undef B_TRANSLATE_COMMENT
#define B_TRANSLATE_COMMENT(string, comment) \
B_CATKEY((string), B_TRANSLATE_CONTEXT, (comment))
B_CATKEY((string), B_TRANSLATION_CONTEXT, (comment))

#undef B_TRANSLATE_ALL
#define B_TRANSLATE_ALL(string, context, comment) \
Expand All @@ -34,15 +34,15 @@

#undef B_TRANSLATE_SYSTEM_NAME
#define B_TRANSLATE_SYSTEM_NAME(string) \
B_CATKEY((string), B_TRANSLATE_SYSTEM_NAME_CONTEXT)
B_CATKEY((string), B_TRANSLATION_SYSTEM_NAME_CONTEXT)

#undef B_TRANSLATE_MARK
#define B_TRANSLATE_MARK(string) \
B_CATKEY((string), B_TRANSLATE_CONTEXT)
B_CATKEY((string), B_TRANSLATION_CONTEXT)

#undef B_TRANSLATE_MARK_COMMENT
#define B_TRANSLATE_MARK_COMMENT(string, comment) \
B_CATKEY((string), B_TRANSLATE_CONTEXT, (comment))
B_CATKEY((string), B_TRANSLATION_CONTEXT, (comment))

#undef B_TRANSLATE_MARK_ALL
#define B_TRANSLATE_MARK_ALL(string, context, comment) \
Expand All @@ -54,15 +54,15 @@

#undef B_TRANSLATE_MARK_SYSTEM_NAME
#define B_TRANSLATE_MARK_SYSTEM_NAME(string) \
B_CATKEY((string), B_TRANSLATE_SYSTEM_NAME_CONTEXT, "")
B_CATKEY((string), B_TRANSLATION_SYSTEM_NAME_CONTEXT, "")

#undef B_TRANSLATE_MARK_VOID
#define B_TRANSLATE_MARK_VOID(string) \
B_CATKEY((string), B_TRANSLATE_CONTEXT)
B_CATKEY((string), B_TRANSLATION_CONTEXT)

#undef B_TRANSLATE_MARK_COMMENT_VOID
#define B_TRANSLATE_MARK_COMMENT_VOID(string, comment) \
B_CATKEY((string), B_TRANSLATE_CONTEXT, (comment))
B_CATKEY((string), B_TRANSLATION_CONTEXT, (comment))

#undef B_TRANSLATE_MARK_ALL_VOID
#define B_TRANSLATE_MARK_ALL_VOID(string, context, comment) \
Expand All @@ -74,7 +74,7 @@

#undef B_TRANSLATE_MARK_SYSTEM_NAME_VOID
#define B_TRANSLATE_MARK_SYSTEM_NAME_VOID(string) \
B_CATKEY((string), B_TRANSLATE_SYSTEM_NAME_CONTEXT, "")
B_CATKEY((string), B_TRANSLATION_SYSTEM_NAME_CONTEXT, "")

#undef B_TRANSLATE_NOCOLLECT
#define B_TRANSLATE_NOCOLLECT(string)
Expand All @@ -92,4 +92,4 @@
#define B_TRANSLATE_NOCOLLECT_SYSTEM_NAME(string)


#endif /* _CATALOG_COLLECTOR_H_ */
#endif /* _COLLECTING_CATALOG_H_ */
4 changes: 2 additions & 2 deletions src/add-ons/disk_systems/bfs/InitializeParameterEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include <Window.h>


#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "BFS_Initialize_Parameter"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "BFS_Initialize_Parameter"


static uint32 MSG_BLOCK_SIZE = 'blsz';
Expand Down
4 changes: 2 additions & 2 deletions src/add-ons/disk_systems/intel/CreationParameterEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include <PartitionParameterEditor.h>
#include <View.h>

#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "BFS_Creation_Parameter"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "BFS_Creation_Parameter"


PrimaryPartitionEditor::PrimaryPartitionEditor()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#include "TeamListItem.h"


#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "Team monitor"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Team monitor"


TeamMonitorWindow* gTeamMonitorWindow = NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include <MailSettings.h>


#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "ConfigView"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "ConfigView"


const uint32 kMsgActionMoveTo = 'argm';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include <MailProtocol.h>


#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "RuleFilter"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "RuleFilter"


RuleFilter::RuleFilter(MailProtocol& protocol, AddonSettings* addonSettings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include <MailSettings.h>


#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "ConfigView"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "ConfigView"


const uint32 kMsgNotifyMethod = 'nomt';
Expand Down
4 changes: 2 additions & 2 deletions src/add-ons/mail_daemon/inbound_filters/notifier/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include "ConfigView.h"


#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "filter"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "filter"


class NotifyFilter : public MailFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@
#include "SpamFilter.h"


#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "SpamFilter"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "SpamFilter"


// The names match the ones set up by spamdbm for sound effects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
#include <FileConfigView.h>


#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "SpamFilterConfig"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "SpamFilterConfig"


static const char *kServerSignature = "application/x-vnd.agmsmith.spamdbm";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include <crypt.h>


#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "IMAPFolderConfig"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "IMAPFolderConfig"


class EditableListItem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#include "IMAPFolderConfig.h"


#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "imap_config"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "imap_config"


const uint32 kMsgOpenIMAPFolder = '&OIF';
Expand Down
4 changes: 2 additions & 2 deletions src/add-ons/mail_daemon/inbound_protocols/pop3/ConfigView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include <ProtocolConfigView.h>


#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "ConfigView"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "ConfigView"


class POP3ConfigView : public BMailProtocolConfigView {
Expand Down
4 changes: 2 additions & 2 deletions src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
#include "MessageIO.h"


#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "pop3"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "pop3"


static void NotHere(BStringList &that, BStringList &otherList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include <FileConfigView.h>


#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "ConfigView"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "ConfigView"


ConfigView::ConfigView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include <ProtocolConfigView.h>


#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "ConfigView"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "ConfigView"


class SMTPConfigView : public BMailProtocolConfigView {
Expand Down
4 changes: 2 additions & 2 deletions src/add-ons/mail_daemon/outbound_protocols/smtp/smtp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
#endif


#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "smtp"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "smtp"


#define CRLF "\r\n"
Expand Down
4 changes: 2 additions & 2 deletions src/add-ons/media/media-add-ons/mixer/AudioMixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
#include "MixerUtils.h"


#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "AudioMixer"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "AudioMixer"


// the range of the gain sliders (in dB)
Expand Down
4 changes: 2 additions & 2 deletions src/add-ons/screen_savers/butterfly/Butterfly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

#include <BuildScreenSaverDefaultSettingsView.h>

#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "Screensaver Butterfly"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Screensaver Butterfly"


extern "C" BScreenSaver*
Expand Down
4 changes: 2 additions & 2 deletions src/add-ons/screen_savers/debugnow/DebugNow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

#include <BuildScreenSaverDefaultSettingsView.h>

#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "Screensaver DebugNow"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Screensaver DebugNow"


const rgb_color kMediumBlue = {0, 0, 100};
Expand Down
4 changes: 2 additions & 2 deletions src/add-ons/screen_savers/haiku/ScreenSaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

#include <BuildScreenSaverDefaultSettingsView.h>

#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "Screensaver Haiku"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Screensaver Haiku"


class ScreenSaver : public BScreenSaver
Expand Down
Loading

0 comments on commit 546208a

Please sign in to comment.