Skip to content

Commit 174421f

Browse files
authored
Merge branch 'keepandroidopen:main' into main
2 parents b9dab6b + 58ce09e commit 174421f

7 files changed

Lines changed: 194 additions & 66 deletions

File tree

lint_yaml.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
3. Locale YAML values should use markdown, not raw HTML tags.
1111
<strong>, <em>, <i>, and <a href="..."> should be written as
1212
markdown equivalents (**bold**, *italic*, [text](url)).
13+
4. Block-scalar values should not be entirely wrapped in double quotes.
14+
This catches the common mistake of converting a YAML quoted string
15+
to a block scalar without removing the outer quotes (which become
16+
literal characters in block scalars).
1317
"""
1418

1519
import glob
@@ -134,6 +138,77 @@ def check_html_in_locale_values(path):
134138
return errors
135139

136140

141+
def check_quoted_block_scalars(path):
142+
"""Return a list of error strings for block-scalar values whose content
143+
is entirely wrapped in double quotes.
144+
145+
This catches the common mistake where a translator converts a YAML
146+
quoted string like key: "value" to a block scalar but forgets to
147+
remove the outer quotes:
148+
149+
key: >-
150+
"value" ← outer quotes are now literal text
151+
152+
Only checks keys whose raw YAML uses a block scalar indicator (> | >- |-).
153+
For locale files, the check compares with the English original to
154+
avoid false positives on keys where the quotes ARE the content
155+
(e.g. obj_security_q whose English value is '"...just about security?"').
156+
"""
157+
errors = []
158+
159+
try:
160+
with open(path) as fh:
161+
data = yaml.safe_load(fh)
162+
except yaml.YAMLError:
163+
return [] # syntax error already reported
164+
165+
if not isinstance(data, dict):
166+
return []
167+
168+
# Identify which keys use block scalar syntax in the raw file
169+
with open(path) as fh:
170+
raw_lines = fh.readlines()
171+
block_scalar_keys = set()
172+
for line in raw_lines:
173+
m = re.match(r"^([a-zA-Z]\w*):\s*[>|][+-]?\s*$", line)
174+
if m:
175+
block_scalar_keys.add(m.group(1))
176+
177+
# Load English reference for locale files
178+
en_data = {}
179+
if "/locales/" in path and not path.endswith("/en.yaml"):
180+
try:
181+
en_path = path.rsplit("/", 1)[0] + "/en.yaml"
182+
with open(en_path) as fh:
183+
en_data = yaml.safe_load(fh) or {}
184+
except (FileNotFoundError, yaml.YAMLError):
185+
pass
186+
187+
for key, value in data.items():
188+
if not isinstance(value, str):
189+
continue
190+
if key not in block_scalar_keys:
191+
continue
192+
if len(value) < 3:
193+
continue
194+
if not (value.startswith('"') and value.endswith('"')):
195+
continue
196+
197+
# For locale files: skip if the English value also starts/ends
198+
# with quotes (the quotes are intentional content)
199+
if en_data:
200+
en_val = en_data.get(key, "")
201+
if isinstance(en_val, str) and en_val.startswith('"') and en_val.endswith('"'):
202+
continue
203+
204+
errors.append(
205+
f"{path}: key '{key}': block scalar value is wrapped in "
206+
f'double quotes — remove the outer quotes'
207+
)
208+
209+
return errors
210+
211+
137212
def main():
138213
files = find_yaml_files()
139214
if not files:
@@ -145,6 +220,7 @@ def main():
145220
all_errors.extend(check_syntax(path))
146221
all_errors.extend(check_escaped_quotes_in_block_scalars(path))
147222
all_errors.extend(check_html_in_locale_values(path))
223+
all_errors.extend(check_quoted_block_scalars(path))
148224

149225
if all_errors:
150226
print(f"Found {len(all_errors)} error(s):\n")

src/data/regulators.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3570,12 +3570,12 @@ countries:
35703570
zh-TW: "哥倫比亞"
35713571
items:
35723572
- text:
3573-
en: Make a report to the [Superintendence of Industry and Commerce](https://servicioslinea.sic.gov.co/servilinea/pqrsf/)
3574-
es: Presentar una denuncia ante la [Superintendencia de Industria y Comercio](https://servicioslinea.sic.gov.co/servilinea/pqrsf/)
3575-
pl: Prześlij zgłoszenie do [Nadzoru Przemysłu i Handlu](https://servicioslinea.sic.gov.co/servilinea/pqrsf/)
3576-
pt-BR: Faça um relato para a [Superintendência de Indústria e Comércio](https://servicioslinea.sic.gov.co/servilinea/pqrsf/)
3577-
zh-CN: 向[工商业监管局](https://servicioslinea.sic.gov.co/servilinea/pqrsf/)报告
3578-
zh-TW: 向[工商業監理局](https://servicioslinea.sic.gov.co/servilinea/pqrsf/)報告
3573+
en: "File a formal antitrust complaint (Prácticas Comerciales Restrictivas) with the [Superintendence of Industry and Commerce (SIC)](https://servicioslinea.sic.gov.co/servilinea/compedesleal/index#) — requires creating an account on the SIC portal"
3574+
es: "Presentar una denuncia formal por prácticas comerciales restrictivas ante la [Superintendencia de Industria y Comercio (SIC)](https://servicioslinea.sic.gov.co/servilinea/compedesleal/index#) — requiere crear una cuenta en el portal de la SIC"
3575+
pl: "Złóż formalną skargę antymonopolową (Prácticas Comerciales Restrictivas) do [Nadzoru Przemysłu i Handlu (SIC)](https://servicioslinea.sic.gov.co/servilinea/compedesleal/index#) — wymaga założenia konta na portalu SIC"
3576+
pt-BR: "Registre uma reclamação formal antitruste (Prácticas Comerciales Restrictivas) na [Superintendência de Indústria e Comércio (SIC)](https://servicioslinea.sic.gov.co/servilinea/compedesleal/index#) — requer criação de conta no portal da SIC"
3577+
zh-CN: "向[工商业监管局 (SIC)](https://servicioslinea.sic.gov.co/servilinea/compedesleal/index#) 提交正式反垄断投诉——需要在 SIC 门户网站上创建账户"
3578+
zh-TW: "向[工商業監理局 (SIC)](https://servicioslinea.sic.gov.co/servilinea/compedesleal/index#) 提交正式反壟斷投訴——需要在 SIC 入口網站上建立帳戶"
35793579
- id: peru
35803580
name:
35813581
ar: "بيرو"

src/i18n/locales/be.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ site_problems_header: "Праблемы"
4545
site_report_issues: "Паведаміць пра праблемы сайта"
4646
# [en] site_disclaimer: "**Disclaimer:** This website is a community-driven noncommercial undertaking. It is operated solely for informational and educational purposes."
4747
site_disclaimer: >-
48-
"**Заўвага:** Гэты сайт кіруецца супольнасцю. Ён створаны выключна ў інфармацыйных і навучальных мэтах."
48+
**Заўвага:** Гэты сайт кіруецца супольнасцю. Ён створаны выключна ў інфармацыйных і навучальных мэтах.
4949
# [en] site_privacy: "**Privacy:** This site uses no cookies and performs no user tracking or logging."
5050
site_privacy: "**Прыватнасць:** Гэты сайт не выкарыстоўвае кукі і не адсочвае карыстальнікаў ці аўтарызацыю."
5151
# [en] site_copyright: "**Copyright:** None. This work is marked"

src/i18n/locales/bn.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ flow_step6: "**২৪ ঘণ্টা অপেক্ষা করুন**"
124124
flow_step7: "আবার ফিরে এসে আরও ভয়ংকর সব স্ক্রিন বাতিল করুন"
125125
# [en] flow_step8: "Pick \"allow temporarily\" (7 days) or \"allow indefinitely\""
126126
flow_step8: >-
127-
"অস্থায়ীভাবে অনুমতি দিন" (৭ দিন) অথবা "স্থায়ীভাবে অনুমতি দিন" অপশনটি বেছে নিন"
127+
অস্থায়ীভাবে অনুমতি দিন" (৭ দিন) অথবা "স্থায়ীভাবে অনুমতি দিন" অপশনটি বেছে নিন
128128
# [en] flow_step9: "Confirm, again, that you understand \"the risks\""
129129
flow_step9: >-
130-
"আপনি যে "ঝুঁকি" বুঝতে পারছেন তা আবারও নিশ্চিত করুন"
130+
আপনি যে "ঝুঁকি" বুঝতে পারছেন তা আবারও নিশ্চিত করুন
131131
# [en] flow_summary: "Nine steps. A mandatory 24-hour cooling-off period. *For installing software on a device you own.*"
132132
flow_summary: "নয়টি ধাপ। বাধ্যতামূলক ২৪ ঘণ্টার ওয়েটিং পিরিয়ড। *শুধুমাত্র আপনার নিজের ডিভাইসে সফটওয়্যার ইন্সটল করার জন্য।*"
133133
# [en] flow_detail: "Worse: this flow runs entirely through **Google Play Services**, not the Android OS. Google can change it, tighten it, or kill it at any time, with no OS update required and no consent needed. And as of today, it hasn't shipped in any beta, preview, or canary build. It exists only as a blog post and some mockups."

src/i18n/locales/es.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ site_problems_header: "Problemas"
4646
site_report_issues: "Informar de un problema en el sitio web"
4747
# [en] site_disclaimer: "**Disclaimer:** This website is a community-driven noncommercial undertaking. It is operated solely for informational and educational purposes."
4848
site_disclaimer: >-
49-
"**Aviso:** Este sitio web es una iniciativa comunitaria sin ánimo de lucro. Se utiliza únicamente con fines informativos y educativos."
49+
**Aviso:** Este sitio web es una iniciativa comunitaria sin ánimo de lucro. Se utiliza únicamente con fines informativos y educativos.
5050
# [en] site_privacy: "**Privacy:** This site uses no cookies and performs no user tracking or logging."
5151
site_privacy: >-
52-
"**Privacidad:** Este sitio web no utiliza cookies ni realiza ningún tipo de seguimiento o registro de los usuarios."
52+
**Privacidad:** Este sitio web no utiliza cookies ni realiza ningún tipo de seguimiento o registro de los usuarios.
5353
# [en] site_copyright: "**Copyright:** None. This work is marked"
5454
site_copyright: "**Derechos de autor:** Ninguno. Esta obra está bajo la licencia."
5555
# [en] open_letter_cta: "Read our open letter opposing the Android Developer Verification program"

src/i18n/locales/id.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ act_dev_warn: >-
210210
Tambahkan [pustaka FreeDroidWarn](https://github.com/woheller69/FreeDroidWarn) ke aplikasi Anda untuk memperingatkan pengguna.
211211
# [en] act_dev_banner: "Run a website? [Add the countdown banner.](/banner)"
212212
act_dev_banner: >-
213-
"Mengelola situs web? [Tambahkan spanduk hitung mundur.](/banner)"
213+
Mengelola situs web? [Tambahkan spanduk hitung mundur.](/banner)
214214
# [en] act_google_heading: "Google employees"
215215
act_google_heading: "Karyawan Google"
216216
# [en] act_google_text: "If you know something about the program's technical implementation or internal rationale, contact [tips@keepandroidopen.org](mailto:tips@keepandroidopen.org) from a *non-work* machine and a *non-Gmail* account. Strict confidence guaranteed."

0 commit comments

Comments
 (0)