mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 23:46:05 -03:30
add django.pot
This commit is contained in:
3496
awx/locale/django.pot
Normal file
3496
awx/locale/django.pot
Normal file
File diff suppressed because it is too large
Load Diff
@@ -116,7 +116,7 @@ register(
|
|||||||
register(
|
register(
|
||||||
'AWX_PROOT_ENABLED',
|
'AWX_PROOT_ENABLED',
|
||||||
field_class=fields.BooleanField,
|
field_class=fields.BooleanField,
|
||||||
label=_('Enable job isloation'),
|
label=_('Enable job isolation'),
|
||||||
help_text=_('Isolates an Ansible job from protected parts of the Tower system to prevent exposing sensitive information.'),
|
help_text=_('Isolates an Ansible job from protected parts of the Tower system to prevent exposing sensitive information.'),
|
||||||
category=_('Jobs'),
|
category=_('Jobs'),
|
||||||
category_slug='jobs',
|
category_slug='jobs',
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ which users can administer the organization.
|
|||||||
If True, all users using social auth will automatically be added as admins
|
If True, all users using social auth will automatically be added as admins
|
||||||
of the organization.
|
of the organization.
|
||||||
If False, no social auth users will be automatically added as admins of
|
If False, no social auth users will be automatically added as admins of
|
||||||
the organiation.
|
the organization.
|
||||||
If a string or list of strings, specifies the usernames and emails for
|
If a string or list of strings, specifies the usernames and emails for
|
||||||
users who will be added to the organization. Strings in the format
|
users who will be added to the organization. Strings in the format
|
||||||
"/<pattern>/<flags>" will be interpreted as JavaScript regular expressions and
|
"/<pattern>/<flags>" will be interpreted as JavaScript regular expressions and
|
||||||
@@ -286,7 +286,7 @@ register(
|
|||||||
field_class=fields.LDAPUserAttrMapField,
|
field_class=fields.LDAPUserAttrMapField,
|
||||||
default={},
|
default={},
|
||||||
label=_('LDAP User Attribute Map'),
|
label=_('LDAP User Attribute Map'),
|
||||||
help_text=_('Mapping of LDAP user schema to Tower API user atrributes (key is '
|
help_text=_('Mapping of LDAP user schema to Tower API user attributes (key is '
|
||||||
'user attribute name, value is LDAP attribute name). The default '
|
'user attribute name, value is LDAP attribute name). The default '
|
||||||
'setting is valid for ActiveDirectory but users with other LDAP '
|
'setting is valid for ActiveDirectory but users with other LDAP '
|
||||||
'configurations may need to change the values (not the keys) of '
|
'configurations may need to change the values (not the keys) of '
|
||||||
@@ -401,7 +401,7 @@ register(
|
|||||||
' If True, all users in LDAP will automatically be added as '
|
' If True, all users in LDAP will automatically be added as '
|
||||||
'admins of the organization.\n'
|
'admins of the organization.\n'
|
||||||
' If False, no LDAP users will be automatically added as admins '
|
' If False, no LDAP users will be automatically added as admins '
|
||||||
'of the organiation.\n'
|
'of the organization.\n'
|
||||||
' If a string or list of strings, specifies the group DN(s) '
|
' If a string or list of strings, specifies the group DN(s) '
|
||||||
'that will be added of the organization if they match any of the '
|
'that will be added of the organization if they match any of the '
|
||||||
'specified groups.\n'
|
'specified groups.\n'
|
||||||
|
|||||||
@@ -11,38 +11,56 @@
|
|||||||
# * update: check for new strings in ansible-tower catalogs, and
|
# * update: check for new strings in ansible-tower catalogs, and
|
||||||
# output how much strings are new/changed.
|
# output how much strings are new/changed.
|
||||||
#
|
#
|
||||||
# * stats: output statistics for each language
|
# * stats: output translation statistics at Zanata
|
||||||
#
|
|
||||||
# * pull: pull/fetch translations from Zanata
|
|
||||||
#
|
#
|
||||||
# * push: update resources in Zanata with the local files
|
# * push: update resources in Zanata with the local files
|
||||||
#
|
#
|
||||||
# Each command support the --lang option to limit their operation to
|
# * pull: pull/fetch translations from Zanata
|
||||||
# the specified language(s). For example,
|
|
||||||
# to pull translations for Japanese and French, run:
|
|
||||||
#
|
#
|
||||||
# $ python tools/scripts/manage_translations.py pull --lang ja,fr
|
# Each command support the --lang option to limit their operation to
|
||||||
|
# the specified language(s). Use --both option to include UI also.
|
||||||
|
# For examples,
|
||||||
|
#
|
||||||
|
# to update django.pot file, run:
|
||||||
|
# $ python tools/scripts/manage_translations.py update
|
||||||
|
#
|
||||||
|
# to update both pot files, run:
|
||||||
|
# $ python tools/scripts/manage_translations.py update --both
|
||||||
|
#
|
||||||
|
# to push both pot files (update also), run:
|
||||||
|
# $ python tools/scripts/manage_translations.py push --both
|
||||||
|
#
|
||||||
|
# to pull both translations for Japanese and French, run:
|
||||||
|
# $ python tools/scripts/manage_translations.py pull --both --lang ja,fr
|
||||||
|
#
|
||||||
|
# to see translations stats at Zanata for Japanese, run:
|
||||||
|
# $ python tools/scripts/manage_translations.py pull --both --lang ja
|
||||||
|
|
||||||
|
# python
|
||||||
import os
|
import os
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from subprocess import PIPE, Popen
|
from subprocess import PIPE, Popen
|
||||||
from xml.etree import ElementTree as ET
|
from xml.etree import ElementTree as ET
|
||||||
from xml.etree.ElementTree import ParseError
|
from xml.etree.ElementTree import ParseError
|
||||||
|
|
||||||
|
# django
|
||||||
import django
|
import django
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.management import call_command
|
from django.core.management import call_command
|
||||||
|
|
||||||
|
ZNTA_CONFIG_FRONTEND_TRANS = "tools/scripts/zanata_config/frontend-translations.xml"
|
||||||
PROJECT_CONFIG = "tools/scripts/zanata_config/backend-translations.xml"
|
ZNTA_CONFIG_BACKEND_TRANS = "tools/scripts/zanata_config/backend-translations.xml"
|
||||||
MIN_TRANS_PERCENT_SETTING = False
|
MIN_TRANS_PERCENT_SETTING = False
|
||||||
MIN_TRANS_PERCENT = '10'
|
MIN_TRANS_PERCENT = '10'
|
||||||
|
|
||||||
|
|
||||||
def _get_zanata_project_url():
|
def _print_zanata_project_url(project_config):
|
||||||
|
"""
|
||||||
|
Browser-able Zanata project URL
|
||||||
|
"""
|
||||||
project_url = ''
|
project_url = ''
|
||||||
try:
|
try:
|
||||||
zanata_config = ET.parse(PROJECT_CONFIG).getroot()
|
zanata_config = ET.parse(project_config).getroot()
|
||||||
server_url = zanata_config.getchildren()[0].text
|
server_url = zanata_config.getchildren()[0].text
|
||||||
project_id = zanata_config.getchildren()[1].text
|
project_id = zanata_config.getchildren()[1].text
|
||||||
version_id = zanata_config.getchildren()[2].text
|
version_id = zanata_config.getchildren()[2].text
|
||||||
@@ -50,10 +68,13 @@ def _get_zanata_project_url():
|
|||||||
project_url = server_url + middle_url + project_id + "/" + version_id + "/documents"
|
project_url = server_url + middle_url + project_id + "/" + version_id + "/documents"
|
||||||
except (ParseError, IndexError):
|
except (ParseError, IndexError):
|
||||||
print("Please re-check zanata project configuration.")
|
print("Please re-check zanata project configuration.")
|
||||||
return project_url
|
print("Zanata URL: %s\n" % project_url)
|
||||||
|
|
||||||
|
|
||||||
def _handle_response(output, errors):
|
def _handle_response(output, errors):
|
||||||
|
"""
|
||||||
|
Prints response received from Zanata client
|
||||||
|
"""
|
||||||
if not errors and '\n' in output:
|
if not errors and '\n' in output:
|
||||||
for response in output.split('\n'):
|
for response in output.split('\n'):
|
||||||
print(response)
|
print(response)
|
||||||
@@ -84,10 +105,16 @@ def pull(lang=None, both=None):
|
|||||||
|
|
||||||
if MIN_TRANS_PERCENT_SETTING:
|
if MIN_TRANS_PERCENT_SETTING:
|
||||||
command += " --min-doc-percent " + MIN_TRANS_PERCENT
|
command += " --min-doc-percent " + MIN_TRANS_PERCENT
|
||||||
if lang:
|
if lang and len(lang) > 0:
|
||||||
command += " --lang %s" % lang[0]
|
command += " --lang %s" % lang[0]
|
||||||
|
|
||||||
p = Popen(command % {'config': PROJECT_CONFIG},
|
if both:
|
||||||
|
p = Popen(command % {'config': ZNTA_CONFIG_FRONTEND_TRANS},
|
||||||
|
stdout=PIPE, stderr=PIPE, shell=True)
|
||||||
|
output, errors = p.communicate()
|
||||||
|
_handle_response(output, errors)
|
||||||
|
|
||||||
|
p = Popen(command % {'config': ZNTA_CONFIG_BACKEND_TRANS},
|
||||||
stdout=PIPE, stderr=PIPE, shell=True)
|
stdout=PIPE, stderr=PIPE, shell=True)
|
||||||
output, errors = p.communicate()
|
output, errors = p.communicate()
|
||||||
_handle_response(output, errors)
|
_handle_response(output, errors)
|
||||||
@@ -95,27 +122,41 @@ def pull(lang=None, both=None):
|
|||||||
|
|
||||||
def push(lang=None, both=None):
|
def push(lang=None, both=None):
|
||||||
"""
|
"""
|
||||||
Push django.pot to Zanata
|
Push .pot to Zanata
|
||||||
At Zanata:
|
At Zanata:
|
||||||
(1) project_type should be podir - {locale}/{filename}.po format
|
(1) for angularjs - project_type should be gettext - {locale}.po format
|
||||||
(2) only required languages should be kept enabled
|
(2) for django - project_type should be podir - {locale}/{filename}.po format
|
||||||
|
(3) only required languages should be kept enabled
|
||||||
"""
|
"""
|
||||||
p = Popen("zanata push --project-config %(config)s --push-type source --disable-ssl-cert" %
|
|
||||||
{'config': PROJECT_CONFIG}, stdout=PIPE, stderr=PIPE, shell=True)
|
command = "zanata push --project-config %(config)s --force --disable-ssl-cert"
|
||||||
|
|
||||||
|
if both:
|
||||||
|
p = Popen(command % {'config': ZNTA_CONFIG_FRONTEND_TRANS}, stdout=PIPE, stderr=PIPE, shell=True)
|
||||||
|
output, errors = p.communicate()
|
||||||
|
if _handle_response(output, errors):
|
||||||
|
_print_zanata_project_url(ZNTA_CONFIG_FRONTEND_TRANS)
|
||||||
|
|
||||||
|
p = Popen(command % {'config': ZNTA_CONFIG_BACKEND_TRANS}, stdout=PIPE, stderr=PIPE, shell=True)
|
||||||
output, errors = p.communicate()
|
output, errors = p.communicate()
|
||||||
if _handle_response(output, errors):
|
if _handle_response(output, errors):
|
||||||
print("Zanata URL: %s\n" % _get_zanata_project_url())
|
_print_zanata_project_url(ZNTA_CONFIG_BACKEND_TRANS)
|
||||||
|
|
||||||
|
|
||||||
def stats(lang=None, both=None):
|
def stats(lang=None, both=None):
|
||||||
"""
|
"""
|
||||||
Get translation stats from Zanata
|
Get translation stats from Zanata
|
||||||
"""
|
"""
|
||||||
command = "zanata stats --project-config %(config)s --disable-ssl-cert"
|
command = "zanata stats --project-config %(config)s --lang %(lang)s --disable-ssl-cert --word"
|
||||||
if lang:
|
lang = lang[0] if lang and len(lang) > 0 else 'en-us'
|
||||||
command += " --lang %s" % lang[0]
|
|
||||||
|
|
||||||
p = Popen(command % {'config': PROJECT_CONFIG},
|
if both:
|
||||||
|
p = Popen(command % {'config': ZNTA_CONFIG_FRONTEND_TRANS, 'lang': lang},
|
||||||
|
stdout=PIPE, stderr=PIPE, shell=True)
|
||||||
|
output, errors = p.communicate()
|
||||||
|
_handle_response(output, errors)
|
||||||
|
|
||||||
|
p = Popen(command % {'config': ZNTA_CONFIG_BACKEND_TRANS, 'lang': lang},
|
||||||
stdout=PIPE, stderr=PIPE, shell=True)
|
stdout=PIPE, stderr=PIPE, shell=True)
|
||||||
output, errors = p.communicate()
|
output, errors = p.communicate()
|
||||||
_handle_response(output, errors)
|
_handle_response(output, errors)
|
||||||
@@ -124,7 +165,7 @@ def stats(lang=None, both=None):
|
|||||||
def update(lang=None, both=None):
|
def update(lang=None, both=None):
|
||||||
"""
|
"""
|
||||||
Update (1) awx/locale/django.pot and/or
|
Update (1) awx/locale/django.pot and/or
|
||||||
(2) awx/ui/po/ansible-tower.pot files with
|
(2) awx/ui/po/ansible-tower-ui.pot files with
|
||||||
new/updated translatable strings.
|
new/updated translatable strings.
|
||||||
"""
|
"""
|
||||||
settings.configure()
|
settings.configure()
|
||||||
@@ -140,7 +181,7 @@ def update(lang=None, both=None):
|
|||||||
print("Django...")
|
print("Django...")
|
||||||
lang = (lang[0].split(',') if ',' in lang[0] else lang) if lang else []
|
lang = (lang[0].split(',') if ',' in lang[0] else lang) if lang else []
|
||||||
os.chdir(os.path.join(os.getcwd(), 'awx'))
|
os.chdir(os.path.join(os.getcwd(), 'awx'))
|
||||||
call_command('makemessages', '--keep-pot', locale=lang)
|
call_command('makemessages', '--keep-pot', locale=lang or ['en-us'])
|
||||||
# Output changed stats
|
# Output changed stats
|
||||||
_check_diff(os.path.join(os.getcwd(), 'locale'))
|
_check_diff(os.path.join(os.getcwd(), 'locale'))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user