Skip to content

Commit

Permalink
feat: Offer bilingual configuration for CSV
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Nov 7, 2024
1 parent cbf93aa commit 9db3bba
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changelog

* Not yet released.
* Added support for Format.JS files.
* Offer bilingual configuration for CSV.

2.16
----
Expand Down
12 changes: 11 additions & 1 deletion translation_finder/discovery/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GettextDiscovery(BaseDiscovery):
new_base_mask = "*.pot"

def discover(self, eager: bool = False, hint: Optional[str] = None):
for result in super().discover(eager=eager):
for result in super().discover(eager=eager, hint=hint):
if "template" not in result:
yield result
continue
Expand Down Expand Up @@ -101,6 +101,16 @@ class CSVDiscovery(MonoTemplateDiscovery):
file_format = "csv"
mask = "*.csv"

def discover(self, eager: bool = False, hint: Optional[str] = None):
for result in super().discover(eager=eager, hint=hint):
if "template" not in result:
yield result
continue
bilingual = result.copy()
del bilingual["template"]
yield bilingual
yield result


@register_discovery
class WebExtensionDiscovery(BaseDiscovery):
Expand Down
5 changes: 5 additions & 0 deletions translation_finder/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,11 @@ def test_basic(self):
self.assert_discovery(
discovery.discover(),
[
{
"filemask": "csv/*.csv",
"file_format": "csv",
"new_base": "csv/en.csv",
},
{
"filemask": "csv/*.csv",
"file_format": "csv",
Expand Down

0 comments on commit 9db3bba

Please sign in to comment.