Advertisement
spacechase0

Localization

Feb 18th, 2012
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. template< struct T >
  2. class StringMap
  3. {
  4.     public:
  5.         static bool LoadFromFile( const std::string& filename )
  6.         {
  7.             // Probably load from the format:
  8.             // key=value
  9.             // With some way to put multiple lines in one string.
  10.         }
  11.        
  12.         static std::string GetString( const std::string& str )
  13.         {
  14.             return strings[ str ];
  15.         }
  16.    
  17.     private:
  18.         StringMap() = delete;
  19.         ~StringMap() = delete;
  20.        
  21.         static std::map< std::string, std::string > strings;
  22. };
  23.  
  24. struct Localization_Def {};
  25. typedef StringMap< Localization_Def > Localization;
  26.  
  27. AlertUser( Localization::GetString( "message.beat_game" ) );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement