Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion i18n/cs/camera.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ metainfo-description-usage = Otevřete aplikaci a začněte zachycovat okamžiky
metainfo-description-features-title = Klíčové funkce:
metainfo-feature-capture = Pořizování fotografií a videí: vysoká kvalita a hardwarová akcelerace
metainfo-feature-qr = Skener QR kódů: otevírání odkazů, připojení k Wi-Fi a další
metainfo-feature-filters = 14 kreativních filtrů: Černobílý, Sépie, Živý, Noir, Skica a další
metainfo-feature-filters = 14 kreativních filtrů: { filter-mono }, { filter-sepia }, { filter-vivid }, { filter-noir }, { filter-pencil } a další
metainfo-feature-virtual-camera = Virtuální kamera: používejte filtrovaný obraz kamery při videohovorech a v dalších aplikacích
metainfo-feature-multi-camera = Podpora více kamer: snadné přepínání mezi kamerami a mikrofony
metainfo-caption-photo-tools = Režim fotografie s nabídkou nástrojů
Expand Down
6 changes: 3 additions & 3 deletions i18n/en/camera.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -748,9 +748,9 @@ metainfo-feature-modes = Photo, video and timelapse modes, with a self timer and
metainfo-feature-controls = Manual controls: exposure, ISO, shutter, focus and white balance
# Feature list item. QR and WiFi are product names and stay as they are.
metainfo-feature-qr = QR code scanner: open links, connect to WiFi, and more
# Feature list item. The filter names are the same ones used in the app, so
# translate them the same way there.
metainfo-feature-filters = 14 creative filters: Mono, Sepia, Vivid, Noir, Pencil Sketch, and more
# Feature list item. The filter names are pulled straight from the filter
# picker above, so translate them there and they follow here on their own.
metainfo-feature-filters = 14 creative filters: { filter-mono }, { filter-sepia }, { filter-vivid }, { filter-noir }, { filter-pencil }, and more
# Feature list item.
metainfo-feature-virtual-camera = Virtual camera: use your filtered camera feed in video calls and other apps
# Feature list item.
Expand Down
2 changes: 1 addition & 1 deletion resources/io.github.cosmic_utils.camera.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<li xml:lang="cs">Skener QR kódů: otevírání odkazů, připojení k Wi-Fi a další</li>
<li xml:lang="uk">Сканер QR-кодів: відкривайте посилання, підключайтеся до Wi-Fi та багато іншого</li>
<li xml:lang="zh-CN">二维码扫描器:打开链接、连接 WiFi 等</li>
<li>14 creative filters: Mono, Sepia, Vivid, Noir, Pencil Sketch, and more</li>
<li>14 creative filters: Mono, Sepia, Vivid, Noir, Pencil, and more</li>
<li xml:lang="cs">14 kreativních filtrů: Černobílý, Sépie, Živý, Noir, Skica a další</li>
<li>Virtual camera: use your filtered camera feed in video calls and other apps</li>
<li xml:lang="cs">Virtuální kamera: používejte filtrovaný obraz kamery při videohovorech a v dalších aplikacích</li>
Expand Down
23 changes: 14 additions & 9 deletions scripts/gen-metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
# the ones generated from here. These prefixes mark the latter.
KEY_PREFIXES = ("desktop-", "metainfo-")

# In-app keys the metadata reuses instead of duplicating, either as a value of
# their own or through a { key } reference inside another string.
SHARED_KEYS = ("camera",)

# Desktop entry key -> Fluent key.
DESKTOP_KEYS = {
"Name": "camera",
Expand Down Expand Up @@ -82,14 +78,18 @@


def read_translations() -> dict[str, dict[str, str]]:
"""Return {fluent_key: {lang: value}} for the metadata keys of every language."""
"""Return {fluent_key: {lang: value}} for every string of every language.

In-app keys are read too, not just the metadata ones: the metadata maps
some of them directly (`camera` becomes the launcher name) and references
others inside its own strings, so they all have to be resolvable.
"""
out: dict[str, dict[str, str]] = {}
for path in sorted(I18N.glob("*/camera.ftl")):
lang = path.parent.name
for line in path.read_text(encoding="utf-8").splitlines():
match = re.match(r"^([a-z0-9-]+) = (.*)$", line)
if match and (match.group(1).startswith(KEY_PREFIXES)
or match.group(1) in SHARED_KEYS):
if match:
out.setdefault(match.group(1), {})[lang] = match.group(2).strip()
return out

Expand Down Expand Up @@ -230,18 +230,23 @@ def main() -> int:
if not translations:
sys.exit(f"error: no metadata strings found in {I18N.relative_to(ROOT)}/*/camera.ftl")

source_keys = {k for k, v in translations.items() if SOURCE_LANG in v}
expected = set(DESKTOP_KEYS.values())
for mapping in (METAINFO_HEAD, METAINFO_DESCRIPTION, METAINFO_SCREENSHOTS):
expected.update(k for keys in mapping.values() for k in keys)
# Only the prefixed keys and the mapped ones are this script's business;
# the rest of the file is the application's own strings.
source_keys = {k for k, v in translations.items() if SOURCE_LANG in v
and (k.startswith(KEY_PREFIXES) or k in expected)}
if missing := expected - source_keys:
sys.exit(f"error: missing from i18n/{SOURCE_LANG}/camera.ftl: {', '.join(sorted(missing))}")
if extra := source_keys - expected:
sys.exit(f"error: unmapped keys in i18n/{SOURCE_LANG}/camera.ftl: {', '.join(sorted(extra))}")

resolve_references(translations)

langs = sorted({lang for v in translations.values() for lang in v if lang != SOURCE_LANG})
langs = sorted({lang for v in translations.values() for lang in v
if lang != SOURCE_LANG and any(
lang in translations[k] for k in expected)})
print(f"Generating metadata for: {', '.join(langs)}")

write_if_changed(DESKTOP, render_desktop(translations, DESKTOP.read_text(encoding="utf-8")))
Expand Down
Loading