|
JX Application Framework
|
#include <JStringManager.h>
Public Types | |
| enum | { kASCIIFormat = 0 , kUTF8Format = 1 } |
Static Public Member Functions | |
| static bool | CanOverride (const JString &id) |
| static void | EnablePseudotranslation () |
Additional Inherited Members | |
Protected Member Functions inherited from JStringPtrMap< JString > | |
| void | PrepareForSet (const JPtrArrayT::SetAction action) override |
Protected Member Functions inherited from JStringMap< V > | |
| bool | SetItem (const JString &key, const V &value, const JPtrArrayT::SetAction action, const JStringMapT::SetType type, bool *existed) |
| bool | RemoveItem (const JString &key, const JPtrArrayT::SetAction action) |
| void | RemoveAll (const JPtrArrayT::SetAction action) |
Protected Member Functions inherited from JHashTable< JStrValue< V > > | |
| bool | IsEmpty (const JSize index) const |
| void | AllowCursors () |
| void | DisallowCursors () |
| JHashCursor< JStrValue< V > > * | GetCursor () |
| JConstHashCursor< JStrValue< V > > * | GetCursor () const |
| const JHashRecord< JStrValue< V > > & | GetRecord (const JSize index) const |
| JHashRecordT::State | GetState (const JSize index) const |
| bool | IsDeleted (const JSize index) const |
| bool | IsFull (const JSize index) const |
| JHashValue | GetHashValue (const JSize index) const |
| const JStrValue< V > & | GetValue (const JSize index) const |
| void | Set (const JSize index, const JHashRecord< JStrValue< V > > &record) |
| void | Set (const JSize index, const JHashValue hash, const JStrValue< V > &value) |
| void | Set (const JSize index, const JStrValue< V > &value) |
| void | SetHash (const JSize index, const JStrValue< V > &value) |
| void | Remove (const JSize index) |
| void | MarkEmpty (const JSize index) |
| void | MarkAllEmpty () |
| bool | TryResizeTable (const JSize lgSize) |
| void | ResizeTable (const JSize lgTrialSize) |
| virtual bool | FitToLimits (const JSize required=0, const bool force=false) |
| JSize | HashToIndex (JHashValue hash) const |
Stores a hash table of strings for use by the program. Each string is
associated with a unique id, which is also a string. ID's typically
have the form "name::class".
Every application must register a unique signature. This is used to search
for translation files:
1a. /usr/lib/<signature>/string_data/<locale>
1b. /usr/lib/<signature>/string_data/<language>
1c. /usr/lib/<signature>/string_data/default
2a. ~/.<signature>/string_data/<locale>
2b. ~/.<signature>/string_data/<language>
2c. ~/.<signature>/string_data/default
The ones that are found are loaded into the hash table in the order shown
to support overrides.
Each data file has the format:
file format (ASCII digits followed by ASCII newline)
# comment
id "string"
...
The comment ends at the end of the line. Inside the string, quotes and
backslashes must be preceded by a backslash.
Certain strings cannot be overridden because tampering with them
would be considered illegal. These include VERSION, COPYRIGHT, and
LICENSE.
Menus present a special case. If one puts the entire menu definition
into the database as a single item, then an outdated database file may
have the wrong number of menu items. The safe solution is to store
each item's text as a separate string, keyed to the ID of the menu item.
Pseudotranslation is useful for testing layout expansion and for
catching string concatenation (which should instead be done via
parameter insertion).
| JStringManager::JStringManager | ( | ) |
|
override |
|
inlinestatic |
This must be called before initialization.
| JString JStringManager::Get | ( | const JUtf8Byte * | id, |
| const JUtf8Byte * | map[], | ||
| const JSize | size | ||
| ) | const |
Uses the given associative array to replace $ variables in the specified string and then returns the result. 'size' must be the result of sizeof(map).
|
inline |
| JSubstitute * JStringManager::GetReplaceEngine | ( | ) | const |
Resets the replace engine and returns a pointer to it so clients can use it.
If debug, prints every string ID that it finds to stdout.
We have to merge the defaults first in case the file is outdated or does not include all necessary strings.
defaultDataSize should be the result of sizeof().
Uses the given associative array to replace $ variables in the given string. 'size' must be the result of sizeof(map).
Replaces $err in the specified string with the error message and calls JUserNotification::ReportError().
This is more helpful to the user than calling JError::ReportError()
| void JStringManager::WriteFile | ( | std::ostream & | output | ) | const |