Skip to content

Instantly share code, notes, and snippets.

@flodolo
Last active February 28, 2023 17:12
Show Gist options
  • Save flodolo/043f5d6977b28a2445390757f72abd13 to your computer and use it in GitHub Desktop.
Save flodolo/043f5d6977b28a2445390757f72abd13 to your computer and use it in GitHub Desktop.
Focus locales missing from Fenix
#! /usr/bin/env python3
import json
from urllib.parse import quote as urlquote
from urllib.request import urlopen
def main():
query = """
{
firefox: project(slug: "firefox-for-android") {
...allLocales
}
focus: project(slug: "focus-for-android") {
...allLocales
}
}
fragment allLocales on Project {
localizations {
locale {
code
}
}
}
"""
locales = {
"firefox": [],
"focus": [],
}
try:
url = "https://pontoon.mozilla.org/graphql?query={}".format(urlquote(query))
print("Reading sources for Pontoon")
response = urlopen(url)
json_data = json.load(response)
for project, project_data in json_data["data"].items():
for element in project_data["localizations"]:
l = element["locale"]["code"]
if l not in locales[project]:
locales[project].append(l)
# Remove duplicates
missing_ac = list(set(locales["focus"]) - set(locales["firefox"]))
missing_ac.sort()
print(", ".join(missing_ac))
except Exception as e:
print(e)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment