Skip to content

Commit c931049

Browse files
committed
Fixed Creator(language=) now supporting multiple values
1 parent 2d0cd09 commit c931049

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## Added
11+
12+
- `zim.creator.Creator(language=)` can be specified as `List[str]`. `["eng", "fra"]`, `["eng"]`, `"eng,fra"`, "eng" are all valid values.
13+
1014
### Changed
1115

1216
- Fixed `zim.providers.URLProvider` returning incomplete streams under certain circumstances (from https://github.com/openzim/kolibri/issues/40)
17+
- Fixed `zim.creator.Creator` not supporting multiple values in for Language metadata, as required by the spec
1318

1419
## [2.0.0] - 2022-12-06
1520

src/zimscraperlib/zim/creator.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import pathlib
2323
import re
2424
import weakref
25-
from typing import Any, Callable, Dict, Optional, Tuple, Union
25+
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
2626

2727
import libzim.writer
2828

@@ -81,7 +81,7 @@ def __init__(
8181
self,
8282
filename: pathlib.Path,
8383
main_path: str = None,
84-
language: Optional[str] = "eng",
84+
language: Optional[Union[str, List[str]]] = "eng",
8585
compression: Optional[str] = None,
8686
workaround_nocancel: Optional[bool] = True,
8787
ignore_duplicates: Optional[bool] = False,
@@ -94,8 +94,10 @@ def __init__(
9494
self.main_path = main_path
9595

9696
if language:
97-
self.config_indexing(True, language)
98-
ld = {"Language": language}
97+
if not isinstance(language, list):
98+
language = language.split(",")
99+
self.config_indexing(True, language[0])
100+
ld = {"Language": ",".join(language)}
99101
if metadata:
100102
metadata.update(ld)
101103
else:

0 commit comments

Comments
 (0)