Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
bec2ca40
Commit
bec2ca40
authored
May 06, 2013
by
Steve Strassmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup headers of files pulled from transifex.
parent
65dd3cc9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
14 deletions
+58
-14
conf/locale/config
+1
-1
i18n/make_dummy.py
+11
-12
i18n/transifex.py
+46
-1
No files found.
conf/locale/config
View file @
bec2ca40
{
"locales" : ["en"],
"locales" : ["en"
, "es"
],
"dummy-locale" : "fr"
}
i18n/make_dummy.py
View file @
bec2ca40
...
...
@@ -2,6 +2,12 @@
# Generate test translation files from human-readable po files.
#
# Dummy language is specified in configuration file (see config.py)
# two letter language codes reference:
# see http://www.loc.gov/standards/iso639-2/php/code_list.php
#
# Django will not localize in languages that django itself has not been
# localized for. So we are using a well-known language (default='fr').
#
# po files can be generated with this:
# django-admin.py makemessages --all --extension html -l en
...
...
@@ -18,7 +24,8 @@
import
os
,
sys
import
polib
from
dummy
import
Dummy
from
execute
import
get_logger
,
create_dir_if_necessary
from
config
import
CONFIGURATION
from
execute
import
create_dir_if_necessary
def
main
(
file
,
locale
):
"""
...
...
@@ -47,21 +54,13 @@ def new_filename(original_filename, new_locale):
msgs_dir
,
orig_file
))
# Dummy language
# two letter language codes reference:
# see http://www.loc.gov/standards/iso639-2/php/code_list.php
#
# Django will not localize in languages that django itself has not been
# localized for. So we are using a well-known language: 'fr'.
DEFAULT_LOCALE
=
'fr'
if
__name__
==
'__main__'
:
# required arg: file
if
len
(
sys
.
argv
)
<
2
:
raise
Exception
(
"missing file argument"
)
# optional arg: locale
if
len
(
sys
.
argv
)
<
3
:
locale
=
DEFAULT_LOCALE
locale
=
CONFIGURATION
.
get_dummy_locale
()
else
:
locale
=
sys
.
argv
[
2
]
main
(
sys
.
argv
[
1
],
locale
)
i18n/transifex.py
View file @
bec2ca40
#!/usr/bin/python
import
sys
import
os
,
sys
from
polib
import
pofile
from
config
import
CONFIGURATION
from
extract
import
SOURCE_WARN
from
execute
import
execute
TRANSIFEX_HEADER
=
'Translations in this file have been downloaded from
%
s'
TRANSIFEX_URL
=
'https://www.transifex.com/projects/p/edx-studio/'
def
push
():
execute
(
'tx push -s'
)
def
pull
():
execute
(
'tx pull'
)
clean_translated_locales
()
def
clean_translated_locales
():
"""
Strips out the warning from all translated po files
about being an English source file.
"""
for
locale
in
CONFIGURATION
.
get_locales
():
if
locale
!=
CONFIGURATION
.
get_source_locale
():
clean_locale
(
locale
)
def
clean_locale
(
locale
):
"""
Strips out the warning from all of a locale's translated po files
about being an English source file.
Iterates over machine-generated files.
"""
dirname
=
CONFIGURATION
.
get_messages_dir
(
locale
)
for
filename
in
(
'django-partial.po'
,
'djangojs.po'
,
'mako.po'
):
clean_file
(
os
.
path
.
join
(
dirname
,
filename
))
def
clean_file
(
file
):
"""
Strips out the warning from a translated po file about being an English source file.
Replaces warning with a note about coming from Transifex.
"""
po
=
pofile
(
file
)
if
po
.
header
.
find
(
SOURCE_WARN
)
!=
-
1
:
new_header
=
get_new_header
(
po
)
new
=
po
.
header
.
replace
(
SOURCE_WARN
,
new_header
)
po
.
header
=
new
po
.
save
()
def
get_new_header
(
po
):
team
=
po
.
metadata
.
get
(
'Language-Team'
,
None
)
if
not
team
:
return
TRANSIFEX_HEADER
%
TRANSIFEX_URL
else
:
return
TRANSIFEX_HEADER
%
team
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
<
2
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment