Guide: Languages¶
This module provides an in depth knowledge of the Translations languages.
Important
The examples are assumed to be executed using these settings.
LANGUAGE_CODE = 'en-us'
LANGUAGES = (
('en', 'English'),
('en-gb', 'English (Great Britain)'),
('de', 'German'),
('tr', 'Turkish'),
)
Please keep these settings in mind in order to understand the examples better.
What are languages?¶
Translations provides some standard easy-to-access language codes out of the box. Language codes like the default language code in the settings, or the active language code in the request, etc.
Translate Languages¶
Translate languages are used in places like the Contexts and the translate method.
To access standard translate language codes use
the translate
object.
To get the default language code.
from translations.languages import translate
# get the default language
default = translate.DEFAULT
print(default)
en
To get the active language code.
(assume en
)
from translations.languages import translate
# get the active language
active = translate.ACTIVE
print(active)
en
Probe Languages¶
Probe languages are used in places like the TQs and the probe method.
To access standard probe language codes use
the probe
object.
To get the default language code.
from translations.languages import probe
# get the default language
default = probe.DEFAULT
print(default)
en
To get the active language code.
(assume en
)
from translations.languages import probe
# get the active language
active = probe.ACTIVE
print(active)
en
To get the default language and active language codes.
(assume en
)
from translations.languages import probe
# get the default and active language
defact = probe.DEFAULT_ACTIVE
print(defact)
en
To get the default language and active language codes.
(assume de
)
from translations.languages import probe
# get the default and active language
defact = probe.DEFAULT_ACTIVE
print(defact)
[
'en',
'de',
]
To get the translation language codes.
from translations.languages import probe
# get the translation language
translation = probe.TRANSLATION
print(translation)
[
'en-gb',
'de',
'tr',
]
To get all the supported language codes.
from translations.languages import probe
# get all the language
all = probe.ALL
print(all)
[
'en',
'en-gb',
'de',
'tr',
]