From e21e7425c52434d7179434fe23d4db2507307d6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20P=C3=B6hn?= Date: Tue, 9 Jan 2024 09:21:19 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=A8=20iOS=20text=20metadata=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change adds basic i18n support for parsing iOS fastlane metadata. Currently supported: * name * subtitle (summary) * description --- fdroidserver/update.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 26e248d5..79c63506 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -34,6 +34,7 @@ import json import time import yaml import copy +import pathlib import defusedxml.ElementTree as ElementTree from datetime import datetime, timezone from argparse import ArgumentParser @@ -1208,6 +1209,36 @@ def insert_localized_app_metadata(apps): logging.warning(_('Unsupported graphics file found: {path}').format(path=f)) +LANG_CODE = re.compile(r'^[a-z]{2}([-_][A-Z][a-zA-Z]{1,3})?$') + + +FASTLANE_IOS_MAP = { + "name.txt": 'name', + "subtitle.txt": 'summary', + "description.txt": 'description', +} + + +def insert_localized_ios_app_metadata(apps_with_packages): + + for package_name, app in apps_with_packages.items(): + if not any(pathlib.Path('repo').glob(f'{package_name}*.ipa')): + # couldn't find any IPA files for this package_name + # so we don't have to look for fastlane data + continue + + fastlane_dir = pathlib.Path('build', package_name, 'fastlane') + + for lang_dir in (fastlane_dir / 'metadata').iterdir(): + lang_code = lang_dir.name + m = LANG_CODE.match(lang_code) + if m: + for metadata_file in (lang_dir).iterdir(): + key = FASTLANE_IOS_MAP.get(metadata_file.name) + if key: + _set_localized_text_entry(app, lang_code, key, metadata_file) + + def scan_repo_files(apkcache, repodir, knownapks, use_date_from_file=False): """Scan a repo for all files with an extension except APK/OBB/IPA. @@ -2238,6 +2269,7 @@ def prepare_apps(apps, apks, repodir): translate_per_build_anti_features(apps_with_packages, apks) if repodir == 'repo': insert_localized_app_metadata(apps_with_packages) + insert_localized_ios_app_metadata(apps_with_packages) insert_missing_app_names_from_apks(apps_with_packages, apks) return apps_with_packages