Skip to content

Commit

Permalink
fix: add namespace option for babelbox
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Dec 10, 2021
1 parent 535133d commit fb902fe
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
5 changes: 3 additions & 2 deletions beet/contrib/babelbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
class BabelboxOptions(BaseModel):
load: List[str] = []
dialect: Optional[str] = None
namespace: str = "minecraft"
filename_prefix: bool = False


Expand All @@ -40,11 +41,11 @@ def beet_default(ctx: Context):
@configurable(validator=BabelboxOptions)
def babelbox(ctx: Context, opts: BabelboxOptions):
"""Plugin that loads translations from csv files."""
minecraft = ctx.assets["minecraft"]
namespace = ctx.assets[opts.namespace]

for pattern in opts.load:
for path in ctx.directory.glob(pattern):
minecraft.languages.merge(
namespace.languages.merge(
load_languages(
path=path,
dialect=opts.dialect,
Expand Down
9 changes: 9 additions & 0 deletions examples/load_babelbox/beet.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
"load": ["translations.csv"]
}
}
},
{
"pipeline": ["beet.contrib.babelbox"],
"meta": {
"babelbox": {
"load": ["translations.csv"],
"namespace": "demo"
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"foo.hello": "3",
"foo.world": "6"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"foo.hello": "1",
"foo.world": "4"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"foo.hello": "2",
"foo.world": "5"
}

0 comments on commit fb902fe

Please sign in to comment.