import warnings
from wtforms import form
from wtforms.ext.i18n.utils import get_translations

translations_cache = {}


class Form(form.Form):
    """
    Base form for a simple localized WTForms form.

    This will use the stdlib gettext library to retrieve an appropriate
    translations object for the language, by default using the locale
    information from the environment.

    If the LANGUAGES class variable is overridden and set to a sequence of
    strings, this will be a list of languages by priority to use instead, e.g::

        LANGUAGES = ['en_GB', 'en']

    One can also provide the languages by passing `LANGUAGES=` to the
    constructor of the form.

    Translations objects are cached to prevent having to get a new one for the
    same languages every instantiation.
    """
    LANGUAGES = None

    def __init__(self, *args, **kwargs):
        warnings.warn('wtforms.ext.i18n will be removed in WTForms 1.2', DeprecationWarning)
        super(Form, self).__init__(*args, **kwargs)

    def _get_translations(self):
        languages = tuple(self.LANGUAGES) if self.LANGUAGES else None
        if languages not in translations_cache:
            translations_cache[languages] = get_translations(languages)
        return translations_cache[languages]

import warnings
from wtforms import form
from wtforms.ext.i18n.utils import get_translations

translations_cache = {}


class Form(form.Form):
    """
    Base form for a simple localized WTForms form.

    **NOTE** this class is now un-necessary as the i18n features have
    been moved into the core of WTForms, but it will be kept for
    compatibility reasons until WTForms 1.2.

    This will use the stdlib gettext library to retrieve an appropriate
    translations object for the language, by default using the locale
    information from the environment.

    If the LANGUAGES class variable is overridden and set to a sequence of
    strings, this will be a list of languages by priority to use instead, e.g::

        LANGUAGES = ['en_GB', 'en']

    One can also provide the languages by passing `LANGUAGES=` to the
    constructor of the form.

    Translations objects are cached to prevent having to get a new one for the
    same languages every instantiation.
    """
    LANGUAGES = None

    def __init__(self, *args, **kwargs):
        warnings.warn('i18n is now in core, wtforms.ext.i18n will be removed in WTForms 1.2', DeprecationWarning)
        super(Form, self).__init__(*args, **kwargs)

    def _get_translations(self):
        languages = tuple(self.LANGUAGES) if self.LANGUAGES else None
        if languages not in translations_cache:
            translations_cache[languages] = get_translations(languages)
        return translations_cache[languages]

Make documentation more explicit for WTForms deprecation.
Make documentation more explicit for WTForms deprecation.

  import warnings
  from wtforms import form
  from wtforms.ext.i18n.utils import get_translations
  
  translations_cache = {}
  
  
  class Form(form.Form):
      """
      Base form for a simple localized WTForms form.
+ 
+     **NOTE** this class is now un-necessary as the i18n features have
+     been moved into the core of WTForms, but it will be kept for
+     compatibility reasons until WTForms 1.2.
  
      This will use the stdlib gettext library to retrieve an appropriate
      translations object for the language, by default using the locale
      information from the environment.
  
      If the LANGUAGES class variable is overridden and set to a sequence of
      strings, this will be a list of languages by priority to use instead, e.g::
  
          LANGUAGES = ['en_GB', 'en']
  
      One can also provide the languages by passing `LANGUAGES=` to the
      constructor of the form.
  
      Translations objects are cached to prevent having to get a new one for the
      same languages every instantiation.
      """
      LANGUAGES = None
  
      def __init__(self, *args, **kwargs):
-         warnings.warn('wtforms.ext.i18n will be removed in WTForms 1.2', DeprecationWarning)
+         warnings.warn('i18n is now in core, wtforms.ext.i18n will be removed in WTForms 1.2', DeprecationWarning)
          super(Form, self).__init__(*args, **kwargs)
  
      def _get_translations(self):
          languages = tuple(self.LANGUAGES) if self.LANGUAGES else None
          if languages not in translations_cache:
              translations_cache[languages] = get_translations(languages)
          return translations_cache[languages]
  
Make documentation more explicit for WTForms deprecation.
## Code Before:
import warnings
from wtforms import form
from wtforms.ext.i18n.utils import get_translations

translations_cache = {}


class Form(form.Form):
    """
    Base form for a simple localized WTForms form.

    This will use the stdlib gettext library to retrieve an appropriate
    translations object for the language, by default using the locale
    information from the environment.

    If the LANGUAGES class variable is overridden and set to a sequence of
    strings, this will be a list of languages by priority to use instead, e.g::

        LANGUAGES = ['en_GB', 'en']

    One can also provide the languages by passing `LANGUAGES=` to the
    constructor of the form.

    Translations objects are cached to prevent having to get a new one for the
    same languages every instantiation.
    """
    LANGUAGES = None

    def __init__(self, *args, **kwargs):
        warnings.warn('wtforms.ext.i18n will be removed in WTForms 1.2', DeprecationWarning)
        super(Form, self).__init__(*args, **kwargs)

    def _get_translations(self):
        languages = tuple(self.LANGUAGES) if self.LANGUAGES else None
        if languages not in translations_cache:
            translations_cache[languages] = get_translations(languages)
        return translations_cache[languages]

## Instruction:
Make documentation more explicit for WTForms deprecation.
## Code After:
import warnings
from wtforms import form
from wtforms.ext.i18n.utils import get_translations

translations_cache = {}


class Form(form.Form):
    """
    Base form for a simple localized WTForms form.

    **NOTE** this class is now un-necessary as the i18n features have
    been moved into the core of WTForms, but it will be kept for
    compatibility reasons until WTForms 1.2.

    This will use the stdlib gettext library to retrieve an appropriate
    translations object for the language, by default using the locale
    information from the environment.

    If the LANGUAGES class variable is overridden and set to a sequence of
    strings, this will be a list of languages by priority to use instead, e.g::

        LANGUAGES = ['en_GB', 'en']

    One can also provide the languages by passing `LANGUAGES=` to the
    constructor of the form.

    Translations objects are cached to prevent having to get a new one for the
    same languages every instantiation.
    """
    LANGUAGES = None

    def __init__(self, *args, **kwargs):
        warnings.warn('i18n is now in core, wtforms.ext.i18n will be removed in WTForms 1.2', DeprecationWarning)
        super(Form, self).__init__(*args, **kwargs)

    def _get_translations(self):
        languages = tuple(self.LANGUAGES) if self.LANGUAGES else None
        if languages not in translations_cache:
            translations_cache[languages] = get_translations(languages)
        return translations_cache[languages]
