Created
July 29, 2020 17:16
-
-
Save flodolo/4f6ab17f216689a359c6e0615dd8719b to your computer and use it in GitHub Desktop.
Check android-l10n locales
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import json | |
from urllib.request import urlopen | |
from urllib.parse import quote as urlquote | |
try: | |
query = ''' | |
{ | |
projects { | |
slug, | |
localizations { | |
locale | |
{ | |
code | |
} | |
} | |
} | |
} | |
''' | |
url = 'https://pontoon.mozilla.org/graphql?query={}'.format(urlquote(query)) | |
response = urlopen(url) | |
json_data = json.load(response) | |
other_locales = [] | |
android_locales = [] | |
# Leave empty to include all projects, except terminology | |
requested_products = [ | |
#'firefox', 'firefox-for-ios', 'firefox-rocket' | |
] | |
for project in json_data['data']['projects']: | |
slug = project['slug'] | |
for locale in project['localizations']: | |
loc = locale['locale']['code'] | |
if slug == 'terminology': | |
continue | |
if slug == 'android-l10n': | |
android_locales.append(loc) | |
else: | |
if requested_products and slug not in requested_products: | |
continue | |
other_locales.append(loc) | |
android_locales = list(set(android_locales)) | |
android_locales.sort() | |
other_locales = list(set(other_locales)) | |
other_locales.sort() | |
not_android = list(set(other_locales) - set(android_locales)) | |
not_android.sort() | |
print('Locales not in android-l10n ({}):'.format(len(not_android))) | |
print(', '.join(not_android)) | |
only_android = list(set(android_locales) - set(other_locales)) | |
only_android.sort() | |
print('Locales only in android-l10n ({}):'.format(len(only_android))) | |
print(', '.join(only_android)) | |
except Exception as e: | |
print(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment