Skip to content

Instantly share code, notes, and snippets.

@flodolo
Created May 13, 2022 06:34
Show Gist options
  • Save flodolo/d16e09e8dbf3f2cb68b397fbf5b0214b to your computer and use it in GitHub Desktop.
Save flodolo/d16e09e8dbf3f2cb68b397fbf5b0214b to your computer and use it in GitHub Desktop.
#! /usr/bin/env python3
import json
import os
from urllib.parse import quote as urlquote
from urllib.request import urlopen
tb_net = [
"ach",
"af",
"an",
"ar",
"as",
"ast",
"az",
"be",
"bg",
"bn",
"br",
"bs",
"ca",
"cak",
"cs",
"cy",
"da",
"de",
"dsb",
"el",
"en-CA",
"en-GB",
"en-ZA",
"eo",
"es-AR",
"es-CL",
"es-ES",
"es-MX",
"et",
"eu",
"fa",
"ff",
"fi",
"fr",
"fy-NL",
"ga-IE",
"gd",
"gl",
"gn",
"gu-IN",
"he",
"hi-IN",
"hr",
"hsb",
"hu",
"hy-AM",
"ia",
"id",
"is",
"it",
"ja",
"ka",
"kab",
"kk",
"km",
"kn",
"ko",
"lij",
"lt",
"ltg",
"lv",
"mai",
"mk",
"ml",
"mr",
"ms",
"my",
"nb-NO",
"ne-NP",
"nl",
"nn-NO",
"oc",
"or",
"pa-IN",
"pl",
"pt-BR",
"pt-PT",
"rm",
"ro",
"ru",
"si",
"sk",
"sl",
"son",
"sq",
"sr",
"sv-SE",
"ta",
"te",
"th",
"tr",
"uk",
"ur",
"uz",
"vi",
"xh",
"zh-CN",
"zh-TW",
"zu ",
]
tb = [
"af",
"ar",
"ast",
"be",
"bg",
"br",
"ca",
"cak",
"cs",
"cy",
"da",
"de",
"dsb",
"el",
"en-CA",
"en-GB",
"es-AR",
"es-ES",
"es-MX",
"et",
"eu",
"fi",
"fr",
"fy-NL",
"ga-IE",
"gd",
"gl",
"he",
"hr",
"hsb",
"hu",
"hy-AM",
"id",
"is",
"it",
"ja",
"ka",
"kab",
"kk",
"ko",
"lt",
"lv",
"mk",
"ms",
"nb-NO",
"nl",
"nn-NO",
"pa-IN",
"pl",
"pt-BR",
"pt-PT",
"rm",
"ro",
"ru",
"sk",
"sl",
"sq",
"sr",
"sv-SE",
"th",
"tr",
"uk",
"uz",
"vi",
"zh-CN",
"",
"zh-TW",
]
query = """
{
vpn_client: project(slug: "thunderbirdnet") {
...allLocales
}
}
fragment allLocales on Project {
localizations {
locale {
code
},
totalStrings,
missingStrings
}
}
"""
try:
url = f"https://pontoon.mozilla.org/graphql?query={urlquote(query)}"
print("Reading sources for Pontoon")
response = urlopen(url)
json_data = json.load(response)
pontoon_data = {}
for project, project_data in json_data["data"].items():
for element in project_data["localizations"]:
code = element["locale"]["code"]
pontoon_data[code] = round(
(element["missingStrings"] / element["totalStrings"]) * 100, 2
)
pontoon_locales = list(pontoon_data.keys())
pontoon_locales.sort()
missing_tb_net = list(set(tb) - set(pontoon_locales))
if missing_tb_net != [""]:
missing_tb_net.sort()
print("\nList of Thunderbird locales missing from Pontoon project:")
for l in missing_tb_net:
print(f"* {l}")
missing_pontoon = list(set(tb_net) - set(pontoon_locales))
if missing_pontoon != [""]:
missing_pontoon.sort()
print("\nList of locales in repository missing from Pontoon project:")
for l in missing_pontoon:
print(f"* {l}")
extra_locales = list(set(pontoon_locales) - set(tb))
if extra_locales != [""]:
extra_locales.sort()
print("\nList of locales in Pontoon not shipping in Thunderbird:")
for l in extra_locales:
print(f"* {l} ({pontoon_data[l]})")
except Exception as e:
print(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment