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
88789c1d
Commit
88789c1d
authored
Jan 24, 2014
by
Sarina Canelake
Committed by
Calen Pennington
Jan 28, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert i18n/make_dummy.py to a standalone script
LMS-1967
parent
b615de57
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
20 deletions
+27
-20
conf/locale/config.yaml
+11
-0
i18n/config.py
+1
-0
i18n/make_dummy.py
+14
-14
rakelib/i18n.rake
+1
-6
No files found.
conf/locale/config.yaml
View file @
88789c1d
...
@@ -32,6 +32,17 @@ locales:
...
@@ -32,6 +32,17 @@ locales:
# The locale used for fake-accented English, for testing.
# The locale used for fake-accented English, for testing.
dummy-locale
:
eo
dummy-locale
:
eo
# Source files that should be used for generating dummy strings
dummy_sources
:
-
django-partial.po
-
django-studio.po
-
django.po
-
djangojs-studio.po
-
djangojs.po
-
mako-studio.po
-
mako.po
-
messages.po
# Directories we don't search for strings.
# Directories we don't search for strings.
ignore_dirs
:
ignore_dirs
:
-
docs
-
docs
...
...
i18n/config.py
View file @
88789c1d
...
@@ -22,6 +22,7 @@ class Configuration(object):
...
@@ -22,6 +22,7 @@ class Configuration(object):
'locales'
:
[
'en'
],
'locales'
:
[
'en'
],
'segment'
:
{},
'segment'
:
{},
'source_locale'
:
'en'
,
'source_locale'
:
'en'
,
'dummy_sources'
:
[],
}
}
def
__init__
(
self
,
filename
):
def
__init__
(
self
,
filename
):
...
...
i18n/make_dummy.py
View file @
88789c1d
...
@@ -6,21 +6,23 @@
...
@@ -6,21 +6,23 @@
# two letter language codes reference:
# two letter language codes reference:
# see http://www.loc.gov/standards/iso639-2/php/code_list.php
# see http://www.loc.gov/standards/iso639-2/php/code_list.php
#
#
# po files to turn into dummy strings are specified in configuration file
#
# Django will not localize in languages that django itself has not been
# Django will not localize in languages that django itself has not been
# localized for. So we are using a well-known language (default='eo').
# localized for. So we are using a well-known language (default='eo').
# Django languages are listed in django.conf.global_settings.LANGUAGES
# Django languages are listed in django.conf.global_settings.LANGUAGES
#
#
# po files can be generated with this:
# po files can be generated with this:
# django-admin.py makemessages --all --extension html -l en
# django-admin.py makemessages --all --extension html -l en
# Usage:
#
#
#
$ ./make_dummy.py <sourcefile>
#
Usage:
#
#
# $ ./make_dummy.py
../conf/locale/en/LC_MESSAGES/django.po
# $ ./make_dummy.py
#
#
# generates output to
# generates output to
# edx-platform/conf/locale/eo/LC_MESSAGES/django.po
# CONFIGURATION.get_messages_dir(CONFIGURATION.dummy_locale)
# (for example,
# edx-platform/conf/locale/eo/LC_MESSAGES/)
import
os
,
sys
import
os
,
sys
import
polib
import
polib
...
@@ -59,12 +61,10 @@ def new_filename(original_filename, new_locale):
...
@@ -59,12 +61,10 @@ def new_filename(original_filename, new_locale):
return
os
.
path
.
abspath
(
os
.
path
.
join
(
orig_dir
,
'../..'
,
new_locale
,
msgs_dir
,
orig_file
))
return
os
.
path
.
abspath
(
os
.
path
.
join
(
orig_dir
,
'../..'
,
new_locale
,
msgs_dir
,
orig_file
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
# required arg: file
LOCALE
=
CONFIGURATION
.
dummy_locale
if
len
(
sys
.
argv
)
<
2
:
SOURCE_MSGS_DIR
=
CONFIGURATION
.
source_messages_dir
raise
Exception
(
"missing file argument"
)
print
"Processing source language files into dummy strings:"
,
# optional arg: locale
for
source_file
in
CONFIGURATION
.
dummy_sources
:
if
len
(
sys
.
argv
)
<
3
:
print
source_file
,
locale
=
CONFIGURATION
.
get_dummy_locale
()
main
(
SOURCE_MSGS_DIR
.
joinpath
(
source_file
),
LOCALE
)
else
:
print
locale
=
sys
.
argv
[
2
]
main
(
sys
.
argv
[
1
],
locale
)
rakelib/i18n.rake
View file @
88789c1d
...
@@ -14,12 +14,7 @@ namespace :i18n do
...
@@ -14,12 +14,7 @@ namespace :i18n do
desc
"Simulate international translation by generating dummy strings corresponding to source strings."
desc
"Simulate international translation by generating dummy strings corresponding to source strings."
task
:dummy
do
task
:dummy
do
source_files
=
Dir
[
"
#{
REPO_ROOT
}
/conf/locale/en/LC_MESSAGES/*.po"
]
sh
(
File
.
join
(
REPO_ROOT
,
"i18n"
,
"make_dummy.py"
))
dummy_locale
=
'eo'
cmd
=
File
.
join
(
REPO_ROOT
,
"i18n"
,
"make_dummy.py"
)
for
file
in
source_files
do
sh
(
"
#{
cmd
}
#{
file
}
#{
dummy_locale
}
"
)
end
end
end
namespace
:validate
do
namespace
:validate
do
...
...
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