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
830bbb15
Commit
830bbb15
authored
Feb 24, 2014
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generate now removes format flags.
parent
eb4d5f1c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
13 deletions
+19
-13
i18n/generate.py
+19
-13
No files found.
i18n/generate.py
View file @
830bbb15
...
...
@@ -53,8 +53,7 @@ def merge(locale, target='django.po', sources=('django-partial.po',), fail_if_mi
# clean up redunancies in the metadata
merged_filename
=
locale_directory
.
joinpath
(
'merged.po'
)
clean_metadata
(
merged_filename
)
clean_line_numbers
(
merged_filename
)
clean_pofile
(
merged_filename
)
# rename merged.po -> django.po (default)
target_filename
=
locale_directory
.
joinpath
(
target
)
...
...
@@ -69,25 +68,32 @@ def merge_files(locale, fail_if_missing=True):
merge
(
locale
,
target
,
sources
,
fail_if_missing
)
def
clean_
metadata
(
file
):
def
clean_
pofile
(
file
):
"""
Clean up redundancies in the metadata caused by merging.
Clean various aspect of a .po file.
Fixes:
- Removes the ,fuzzy flag on metadata.
- Removes occurrence line numbers so that the generated files don't
generate a lot of line noise when they're committed.
- Removes any flags ending with "-format". Mac gettext seems to add
these flags, Linux does not, and we don't seem to need them. By
removing them, we reduce the unimportant differences that clutter
diffs as different developers work on the files.
"""
# Reading in the .po file and saving it again fixes redundancies.
pomsgs
=
pofile
(
file
)
# The msgcat tool marks the metadata as fuzzy, but it's ok as it is.
pomsgs
.
metadata_is_fuzzy
=
False
pomsgs
.
save
()
def
clean_line_numbers
(
file
):
"""
Remove occurrence line numbers so that the generated files don't generate a lot of
line noise when they're committed.
"""
pomsgs
=
pofile
(
file
)
for
entry
in
pomsgs
:
# Remove line numbers
entry
.
occurrences
=
[(
filename
,
None
)
for
(
filename
,
lineno
)
in
entry
.
occurrences
]
# Remove -format flags
entry
.
flags
=
[
f
for
f
in
entry
.
flags
if
not
f
.
endswith
(
"-format"
)]
pomsgs
.
save
()
...
...
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