Small library for defining string translations. Basically it stores key-values-pairs, and allows their retrieval. Needs the csv_parser library.
Localization.h@0:56714c5edd05, 2011-02-22 (annotated)
- Committer:
- hlipka
- Date:
- Tue Feb 22 23:07:49 2011 +0000
- Revision:
- 0:56714c5edd05
initial public version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hlipka | 0:56714c5edd05 | 1 | /* |
hlipka | 0:56714c5edd05 | 2 | * Localization library |
hlipka | 0:56714c5edd05 | 3 | * Copyright (c) 2010 Hendrik Lipka |
hlipka | 0:56714c5edd05 | 4 | * |
hlipka | 0:56714c5edd05 | 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
hlipka | 0:56714c5edd05 | 6 | * of this software and associated documentation files (the "Software"), to deal |
hlipka | 0:56714c5edd05 | 7 | * in the Software without restriction, including without limitation the rights |
hlipka | 0:56714c5edd05 | 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
hlipka | 0:56714c5edd05 | 9 | * copies of the Software, and to permit persons to whom the Software is |
hlipka | 0:56714c5edd05 | 10 | * furnished to do so, subject to the following conditions: |
hlipka | 0:56714c5edd05 | 11 | * |
hlipka | 0:56714c5edd05 | 12 | * The above copyright notice and this permission notice shall be included in |
hlipka | 0:56714c5edd05 | 13 | * all copies or substantial portions of the Software. |
hlipka | 0:56714c5edd05 | 14 | * |
hlipka | 0:56714c5edd05 | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
hlipka | 0:56714c5edd05 | 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
hlipka | 0:56714c5edd05 | 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
hlipka | 0:56714c5edd05 | 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
hlipka | 0:56714c5edd05 | 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
hlipka | 0:56714c5edd05 | 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
hlipka | 0:56714c5edd05 | 21 | * THE SOFTWARE. |
hlipka | 0:56714c5edd05 | 22 | */ |
hlipka | 0:56714c5edd05 | 23 | |
hlipka | 0:56714c5edd05 | 24 | #ifndef __LOCALIZATION_H_ |
hlipka | 0:56714c5edd05 | 25 | #define __LOCALIZATION_H_ |
hlipka | 0:56714c5edd05 | 26 | |
hlipka | 0:56714c5edd05 | 27 | #include <list> |
hlipka | 0:56714c5edd05 | 28 | |
hlipka | 0:56714c5edd05 | 29 | typedef struct |
hlipka | 0:56714c5edd05 | 30 | { |
hlipka | 0:56714c5edd05 | 31 | char* key; |
hlipka | 0:56714c5edd05 | 32 | char* text; |
hlipka | 0:56714c5edd05 | 33 | } MsgEntry; |
hlipka | 0:56714c5edd05 | 34 | |
hlipka | 0:56714c5edd05 | 35 | class Localization |
hlipka | 0:56714c5edd05 | 36 | { |
hlipka | 0:56714c5edd05 | 37 | public: |
hlipka | 0:56714c5edd05 | 38 | Localization(); |
hlipka | 0:56714c5edd05 | 39 | const char* getLocalizedValue(const char* id); |
hlipka | 0:56714c5edd05 | 40 | const char* l(const char* id){return getLocalizedValue(id);}; |
hlipka | 0:56714c5edd05 | 41 | private: |
hlipka | 0:56714c5edd05 | 42 | int dummy; |
hlipka | 0:56714c5edd05 | 43 | std::list<MsgEntry*> *_entries; |
hlipka | 0:56714c5edd05 | 44 | static void init(); |
hlipka | 0:56714c5edd05 | 45 | |
hlipka | 0:56714c5edd05 | 46 | }; |
hlipka | 0:56714c5edd05 | 47 | |
hlipka | 0:56714c5edd05 | 48 | #endif |