Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
   Copyright (c) 2017 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software
   and associated documentation files (the "Software"), to deal in the Software
   without restriction,
   including without limitation the rights to use, copy, modify, merge, publish,
   distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
   PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
   DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
   IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */

#ifndef _LOCALE_H_
#define _LOCALE_H_

static const char* DEFAULT_LANG = "enGB";

#include "Platform/Headers/PlatformDefines.h"

namespace Divide {

enum class ErrorCode : I32;

namespace Locale {
    namespace detail {
        /// Is everything loaded and ready for use?
        static bool s_initialized = false;
        /// Default language can be set at compile time
        static stringImpl s_localeFile = DEFAULT_LANG;

        /// Each string key in the map matches a key in the language ini file
        /// each string value in the map matches the value in the ini file for the given key
        /// Basicly, the hashMapImpl is a direct copy of the [language] section of the
        /// give ini file
        static hashMapImpl<U64, stringImpl> s_languageTable;
        static vectorImpl<DELEGATE_CBK<void, const char* /*new language*/>> s_languageChangeCallbacks;

        /// Callback for external file changes. 
        void onLanguageFileModify(const char* languageFile);
    }; //detail

/// Reset everything and load the specified language file.
ErrorCode init(const stringImpl& newLanguage = DEFAULT_LANG);
/// clear the language table
void clear();
/// perform maintnance tasks
void idle();
/// Altough the language can be set at compile time, in-game options may support
/// language changes
void changeLanguage(const stringImpl& newLanguage);
/// Add a function to be called on each language change
void addChangeLanguageCallback(const DELEGATE_CBK<void, const char* /*new language*/>& cbk);
/// Query the current language code to detect changes
inline const stringImpl& currentLanguage() { return detail::s_localeFile; }
/// usage: Locale::get(_ID("A_B_C")) or Locale::get(_ID("A_B_C"),"X") where "A_B_C" is the
/// language key we want
/// and "X" is a default string in case the key does not exist in the INI file
const char* get(U64 key, const char* defaultValue);
const char* get(U64 key);

};  // namespace Locale
};  // namespace Divide

#endif

Commits for Divide-Framework/trunk/Source Code/Utility/Headers/Localization.h

Diff revisions: vs.
Revision Author Commited Message
842 Diff Diff IonutCava picture IonutCava Wed 01 Feb, 2017 17:25:15 +0000

[IonutCava]
- Start to implement scripting support via ChaiScript: http://chaiscript.com/
- Cleanup DELEGATE_CBK alias

841 Diff Diff IonutCava picture IonutCava Wed 01 Feb, 2017 14:47:57 +0000

[IonutCava]
- Add callbacks to Localization so that listeners can be informed of language changes
— First callback added to GUIInterface

840 Diff Diff IonutCava picture IonutCava Wed 01 Feb, 2017 14:06:06 +0000

[IonutCava]
- Fix a bug with hot shader reloading and atom file caching
- Add hot language file reloading.
— Changes made to the current language file will be immediately applied

836 Diff Diff IonutCava picture IonutCava Fri 27 Jan, 2017 14:59:56 +0000

[IonutCava]
- Update copyright notice

835 Diff Diff IonutCava picture IonutCava Fri 27 Jan, 2017 14:58:07 +0000

[IonutCava]
- Split Engine lib into Core and Engine lib.
- Fix Server build issues

807 Diff Diff IonutCava picture IonutCava Mon 09 Jan, 2017 17:06:26 +0000

[IonutCava]
- Split PlatformDefines.h into 2. Move data type defines to PlatformDataTypes.h
- Continue to improve velocity map calculation
- Remove “destroy()” calls from most classes. Attempt to move as many classes to the RAII system.

795 Diff Diff IonutCava picture IonutCava Wed 23 Nov, 2016 17:14:33 +0000

[IonutCava]
- Remove ULL. Use U64 instead
- Various small bug fixes and typos.

648 Diff Diff IonutCava picture IonutCava Sun 21 Feb, 2016 16:32:52 +0000

[IonutCava]
- Update copyright notice
- Move BoundingBox and BoundingSphere to a new BoundsComponent
— Add a temp hack in SceneGraphNode to update these

619 Diff Diff IonutCava picture IonutCava Fri 08 Jan, 2016 16:23:28 +0000

[IonutCava]
- Memory allocation optimizations
- Large VBO allocation system
- More terrain fixes
- Temporarily disable water and vegetation systems

577 IonutCava picture IonutCava Fri 20 Nov, 2015 15:59:10 +0000

[IonutCava]
- Replace all string indexed maps with unsigned long long indexed maps and add both compile time and runtime hashing functions to convert strings to the proper indices
— Balancing the calls between _ID and _ID_RT can reduce map lookup overhead, especially with ParamHandler and Locale::get