// This may look like C code, but it's really -*- C++ -*-
/*
 * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */
#ifndef WLOCALIZED_STRINGS_
#define WLOCALIZED_STRINGS_

#include <string>
#include "Wt/WDllDefs.h"

namespace Wt {

class WString;

/*! \class WLocalizedStrings Wt/WLocalizedStrings Wt/WLocalizedStrings
 *  \brief An abstract class that provides support for localized strings.
 *
 * This abstract class provides the content to localized WStrings, by
 * resolving the key to a string using the current application locale.
 *
 * \sa WString::tr(), WApplication::setLocalizedStrings()
 */
class WT_API WLocalizedStrings
{
public:
  /*! \brief Destructor.
   */
  virtual ~WLocalizedStrings();

  /*! \brief Returns the value for a particular string in the current locale.
   *
   * This is equivalent to \link WString::value() s.value()\endlink.
   */
  std::wstring getValue(const WString& s);

  /*! \brief Returns the UTF8-encoded value for a particular string in the
   *         current locale.
   *
   * This is equivalent to \link WString::toUTF8() s.toUTF8()\endlink.
   */
  std::string getUTF8Value(const WString& s);

  /*! \brief Reread the message resources.
   *
   * Purge any cached key/values, if applicable.
   *
   * The default implementation does nothing.
   */
  virtual void refresh();

  /*! \brief Purge memory resources, if possible.
   * 
   * This is called afer event handling, and is an opportunity to
   * conserve memory inbetween events, by freeing memory used for
   * cached key/value bindings, if applicable.
   *
   * The default implementation does nothing.
   */
  virtual void hibernate();

  /*! \brief Resolve a key in the current locale.
   * 
   * This method is used by WString to obtain the UTF8 value corresponding
   * to a key in the current locale.
   *
   * Returns true if the key could be resolved. The value is written
   * in <i>result</i>, encoded using UTF8.
   *
   * \sa WApplication::locale()
   */
  virtual bool resolveKey(const std::string& key, std::string& result) = 0;
};

}

#endif // WSTRING_TRANSLATOR_
