1 /*  Copyright 2008 Guillaume Duhamel
2 
3     This file is part of mini18n.
4 
5     mini18n is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9 
10     mini18n is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14 
15     You should have received a copy of the GNU General Public License
16     along with mini18n; if not, write to the Free Software
17     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
18 */
19 
20 #ifndef MINI18N_H
21 #define MINI18N_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /** @file */
28 
29 #if defined _WIN32 || defined __CYGWIN__
30   #ifdef BUILDING_DLL
31     #ifdef __GNUC__
32       #define DLL_PUBLIC __attribute__ ((dllexport))
33     #else
34       #define DLL_PUBLIC __declspec(dllexport) // Note: actually gcc seems to also supports this syntax.
35     #endif
36   #else
37     #ifdef USE_DLL
38       #ifdef __GNUC__
39         #define DLL_PUBLIC __attribute__ ((dllimport))
40       #else
41         #define DLL_PUBLIC __declspec(dllimport) // Note: actually gcc seems to also supports this syntax.
42       #endif
43     #else
44       #define DLL_PUBLIC
45     #endif
46   #endif
47   #define DLL_LOCAL
48 #else
49   #if __GNUC__ >= 4
50     #define DLL_PUBLIC __attribute__ ((visibility ("default")))
51     #define DLL_LOCAL  __attribute__ ((visibility ("hidden")))
52   #else
53     #define DLL_PUBLIC
54     #define DLL_LOCAL
55   #endif
56 #endif
57 
58 #define MINI18N_UTF16 1
59 #define MINI18N_FORMAT_COUNT 1
60 
61 #ifndef _
62 #define _(source) (mini18n(source))
63 #endif
64 
65 #ifndef _16
66 #define _16(source) (mini18n_with_conversion(source, MINI18N_UTF16))
67 #endif
68 
69 /**
70  * @brief Select a translation matching the operating system configuration.
71  *
72  * @param folder the folder to search for translations.
73  * @returns 0 on success, -1 otherwise
74  */
75 DLL_PUBLIC int mini18n_set_domain(const char * folder);
76 /**
77  * @brief Load a translation from a file.
78  *
79  * @param filename of the translation to load.
80  * @returns 0 on success, -1 otherwise
81  */
82 DLL_PUBLIC int mini18n_set_locale(const char * locale);
83 DLL_PUBLIC int mini18n_set_log(const char * filename);
84 /**
85  * @brief Translates a string.
86  *
87  * @param source string to translate
88  * @returns The translated string on success, the source string otherwise. The returned value should not be freed or modified in any way.
89  */
90 DLL_PUBLIC const char * mini18n(const char * source);
91 /**
92  * @brief Translates and convert a string.
93  *
94  * The list of available conversion formats depends of the system.
95  * The converted value is stored so further calls to the function with the same source will return the same pointer.
96  *
97  * @param source String to translate.
98  * @param format The format to convert the string to.
99  */
100 DLL_PUBLIC const void * mini18n_with_conversion(const char * source, unsigned int format);
101 DLL_PUBLIC void mini18n_close(void);
102 
103 /**
104  *
105  * @mainpage
106  *
107  * Mini18n is a translation library.
108  *
109  * \section using Using
110  *
111  * \subsection using-selecting Selecting translation
112  *
113  * Mini18n supports either automaticaly choosing a translation based on the current system settings or
114  * load a given translation file.
115  *
116  * To let Mini18n select the translation file, call mini18n_set_domain() with the base directory
117  * of translation files.
118  *
119  * \section extending Extending
120  *
121  */
122 
123 #ifdef __cplusplus
124 }
125 #endif
126 
127 #endif
128