i18n.cpp

Engine/source/i18n/i18n.cpp

More...

Public Functions

DefineEngineFunction(getCoreLangTable , S32 , () , "()" "@brief Gets the primary <a href="/coding/class/classlangtable/">LangTable</a> used by the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">game\n\n</a>" "@return ID of the core <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">LangTable\n</a>" "@ingroup Localization" )
DefineEngineFunction(setCoreLangTable , void , (const char *lgTable) , "(string <a href="/coding/class/classlangtable/">LangTable</a>)" "@brief Sets the primary <a href="/coding/class/classlangtable/">LangTable</a> used by the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">game\n\n</a>" "@param <a href="/coding/class/classlangtable/">LangTable</a> ID of the core <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">LangTable\n</a>" "@ingroup Localization" )

Detailed Description

Public Variables

LangTable * gCoreLangTable 
const UTF8 * gI18NDefaultStrings []

Public Functions

DefineEngineFunction(getCoreLangTable , S32 , () , "()" "@brief Gets the primary <a href="/coding/class/classlangtable/">LangTable</a> used by the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">game\n\n</a>" "@return ID of the core <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">LangTable\n</a>" "@ingroup Localization" )

DefineEngineFunction(setCoreLangTable , void , (const char *lgTable) , "(string <a href="/coding/class/classlangtable/">LangTable</a>)" "@brief Sets the primary <a href="/coding/class/classlangtable/">LangTable</a> used by the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">game\n\n</a>" "@param <a href="/coding/class/classlangtable/">LangTable</a> ID of the core <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">LangTable\n</a>" "@ingroup Localization" )

getCoreString(S32 id)

 1
 2//-----------------------------------------------------------------------------
 3// Copyright (c) 2012 GarageGames, LLC
 4//
 5// Permission is hereby granted, free of charge, to any person obtaining a copy
 6// of this software and associated documentation files (the "Software"), to
 7// deal in the Software without restriction, including without limitation the
 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 9// sell copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21// IN THE SOFTWARE.
22//-----------------------------------------------------------------------------
23
24#include "platform/platform.h"
25#include "core/stream/stream.h"
26#include "core/stream/fileStream.h"
27#include "console/console.h"
28#include "console/engineAPI.h"
29
30#include "i18n/i18n.h"
31#include "i18n/lang.h"
32
33//-----------------------------------------------------------------------------
34// Globals
35//-----------------------------------------------------------------------------
36
37// [tom, 3/17/2005] Note: This is created in script
38static LangTable *gCoreLangTable = NULL;
39
40// [tom, 3/17/2005] Defined in CoreStringsDefaults.cc, which is generated by langc
41//extern const UTF8 *gI18NDefaultStrings[];
42
43// [tom, 5/2/2005] Note: Temporary kludge to keep this compilable while
44// the core localization isn't finished.
45static const UTF8 *gI18NDefaultStrings[] =
46{
47   NULL
48};
49
50//-----------------------------------------------------------------------------
51
52const UTF8 *getCoreString(S32 id)
53{
54   if(gCoreLangTable)
55      return gCoreLangTable->getString(id);
56   else
57      return gI18NDefaultStrings[id];
58}
59
60//-----------------------------------------------------------------------------
61
62DefineEngineFunction( getCoreLangTable, S32, (), , "()"
63            "@brief Gets the primary LangTable used by the game\n\n"
64            "@return ID of the core LangTable\n"
65            "@ingroup Localization")
66{
67   if(gCoreLangTable)
68      return gCoreLangTable->getId();
69   else
70      return 0;
71}
72
73DefineEngineFunction( setCoreLangTable, void, (const char * lgTable), , "(string LangTable)"
74            "@brief Sets the primary LangTable used by the game\n\n"
75            "@param LangTable ID of the core LangTable\n"
76            "@ingroup Localization")
77{
78   LangTable * lt;
79   
80   if(Sim::findObject(lgTable, lt))
81   { gCoreLangTable = lt; }
82   else
83   {       
84      Con::errorf("setCoreLangTable - Unable to find LanTable '%s'", lgTable); 
85   }
86
87}
88
89//-----------------------------------------------------------------------------
90