Introduction
Web2py is a free, open-source internet framework for the rapid development of database-driven web applications. Python is used to write and program it. It is a full-stack framework that provides all of the necessary components for a developer to create fully functional web apps.
Internationalization and Pluralization with T in web2py is one of the most important topics/concepts in web2py. This blog will be your key to a thorough understanding of Internationalisation and Pluralization with T in web2py. Before starting Internationalisation and Pluralization with T in web2py, we request your full concentration, So let's start.

Internationalization with T in web2py
The language translator is the object T. It is a single global instance of the gluon. Language.translator web2py class. T should be used to denote all string constants (and only string constants),
For example:
a = T("Coding Ninjas")
The T object also allows interpolated variables and numerous similar syntaxes:
a = T("hello %s", ('Ninjas', ))
a = T("hello %(name)s", dict(name='Ninjas'))
a = T("hello %s") % ('Ninjas', )
a = T("hello %(name)s") % dict(name='Ninjas')
The latter syntax is preferred since it facilitates translation. The first string is translated according to the language file specified, and the name variable is replaced regardless of Language.
Concatenating translated and normal strings are possible:
T("blah ") + name + T(" blah")
The following code is also acceptable and generally preferred:
T("blah %(name)s blah", dict(name='Ninjas')) OR T("blah %(name)s blah") % dict(name='Ninjas')
In all situations, the translation takes place before the variable name is entered into the " percent (names)" column.
The following option should not be Applicable:
T("blah %(name)s blah" % dict(name='Ninjas'))

Determining the Language
The "Accept-Language" field in the HTTP header determines the requested Language, although this option can be changed programmatically by requesting a specific file, for example, T.force('it-it'), which reads the language file "languages/it-it.py" The administrative interface allows you to create and change language files.
You may also specify a language per string:
T("Hello World", language="it-it")
You may totally disable translations by using Force Method:
T.force(None)
The translator force method should not be invoked inside a view since string translation is normally evaluated lazily when the view is displayed.
It is possible to deactivate lazy evaluation by using the
T.lazy = False
Strings are, therefore, immediately translated by the T operation based on the presently acceptable or forced Language.
Individual strings can also be disabled from the lazy evaluation:
T("Hello World", lazy=False)
The following is a prevalent problem. The initial application was written in English. Assume there is a translation file (say, "it-it.py"), and the HTTP client indicates that it supports both English (en) and Italian (it-it) in that order. The following unfavorable scenario occurs: web2py is unaware that the default is written in English (en). As a result, because it only located the Italian translation file, it prefers translating everything into Italian (it-it). It would have utilized the default language strings if the "it-it.py" file had not been discovered (English).
There are two solutions to this problem: build a redundant and superfluous translation language for English, or specify web2py which languages should use the default language strings (the strings coded into the application).
This is possible with:
T.set_language('en', 'en-en')
It saves a list of languages that do not require translation in T.languages and requires a reload of the language files.
Notice that "it" and "it-it" are different languages from the point of view of web2py. To support both of them, one would need two translation files, always lowercase. The same is true for all other languages.
The currently used Language is saved in
T.accepted_languageTranslating Variables
T may translate not only texts but also values stored in variables:
a = "Coding Ninjas."
print T(a)
The word "test" is translated in this instance, but if it is not discovered and the filesystem is writable, it will be added to the list of words to be translated in the language file.
Take note that this might result in a large amount of file IO, and you may wish to disable it:
T.is_writable = False
T is not allowed to dynamically update language files.







