Skip to content

Commit

Permalink
Add support for .xlf (#496)
Browse files Browse the repository at this point in the history
An Alternative .xliff file extension
  • Loading branch information
mathjazz committed Nov 10, 2016
1 parent f7e3dd2 commit 12bf17f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 7 additions & 1 deletion pontoon/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@ class Resource(models.Model):
FORMAT_CHOICES = (
('po', 'po'),
('xliff', 'xliff'),
('xlf', 'xliff'),
('properties', 'properties'),
('dtd', 'dtd'),
('inc', 'inc'),
Expand Down Expand Up @@ -1158,7 +1159,12 @@ def get_path_format(self, path):
path_format = extension[1:].lower()

# Special case: pot files are considered the po format
return 'po' if path_format == 'pot' else path_format
if path_format == 'pot':
return 'po'
elif path_format == 'xlf':
return 'xliff'
else:
return path_format


class Subpage(models.Model):
Expand Down
1 change: 1 addition & 0 deletions pontoon/sync/formats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'.lang': lang.parse,
'.po': po.parse,
'.pot': po.parse,
'.xlf': xliff.parse,
'.xliff': xliff.parse,
'.dtd': silme.parse_dtd,
'.properties': silme.parse_properties,
Expand Down
5 changes: 1 addition & 4 deletions pontoon/sync/vcs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,7 @@ def relative_resource_paths(self):
"""
path = self.source_directory_path
for absolute_path in self.resources_for_path(path):
# .pot files in the source directory need to be renamed to
# .po files for the locale directories.
if absolute_path.endswith('.pot'):
absolute_path = absolute_path[:-1]
absolute_path = source_to_locale_path(absolute_path)

yield os.path.relpath(absolute_path, path)

Expand Down

0 comments on commit 12bf17f

Please sign in to comment.