Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2003-2024 German Aerospace Center (DLR) and others.
4 : // This program and the accompanying materials are made available under the
5 : // terms of the Eclipse Public License 2.0 which is available at
6 : // https://www.eclipse.org/legal/epl-2.0/
7 : // This Source Code may also be made available under the following Secondary
8 : // Licenses when the conditions for such availability set forth in the Eclipse
9 : // Public License 2.0 are satisfied: GNU General Public License, version 2
10 : // or later which is available at
11 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 : /****************************************************************************/
14 : /// @file Translation.h
15 : /// @author Michael Behrisch
16 : /// @date 2023-01-24
17 : ///
18 : // Translation macros
19 : /****************************************************************************/
20 : #pragma once
21 : #include <config.h>
22 : #ifdef HAVE_INTL
23 : #include <libintl.h>
24 : #endif
25 : #include "StringUtils.h"
26 :
27 :
28 : // ===========================================================================
29 : // global definitions
30 : // ===========================================================================
31 : #ifdef HAVE_INTL
32 : static inline const char*
33 : my_pgettext(const char* msg_ctxt_id, const char* msgid) {
34 14657 : const char* translation = dcgettext(NULL, msg_ctxt_id, LC_MESSAGES);
35 14657 : if (translation == msg_ctxt_id) {
36 14657 : return msgid;
37 : }
38 : return translation;
39 : }
40 :
41 :
42 : #define TL(string) gettext(string)
43 : #define TLC(context, string) my_pgettext(context "\004" string, string)
44 : #define TLF(string, ...) StringUtils::format(gettext(string), __VA_ARGS__)
45 : #else
46 : #define TL(string) (string)
47 : #define TLC(context, string) (string)
48 : #define TLF(string, ...) StringUtils::format(string, __VA_ARGS__)
49 : #endif
|