Created
June 24, 2020 06:57
-
-
Save flodolo/d43f5a319e1209e649cb6dca49e85407 to your computer and use it in GitHub Desktop.
Check Thunderbird l10n status
This file contains 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 | |
import os | |
from collections import OrderedDict | |
from operator import itemgetter | |
from urllib.parse import quote as urlquote | |
from urllib.request import urlopen | |
def main(): | |
# Get locales of Nightly builds | |
url = 'https://hg.mozilla.org/comm-central/raw-file/tip/mail/locales/all-locales' | |
nightly_locales = [] | |
response = urlopen(url) | |
for locale in response: | |
locale = locale.rstrip().decode() | |
if locale not in ['', 'en-US'] and locale not in nightly_locales: | |
nightly_locales.append(locale) | |
url = 'https://hg.mozilla.org/releases/comm-release/raw-file/tip/mail/locales/shipped-locales' | |
beta_locales = [] | |
response = urlopen(url) | |
for locale in response: | |
locale = locale.rstrip().decode() | |
# Remove platform | |
for text in ['linux', 'osx', 'win32']: | |
locale = locale.replace(text, '').rstrip() | |
if locale not in ['', 'en-US']: | |
beta_locales.append(locale) | |
query = ''' | |
{ | |
firefox: project(slug: "thunderbird") { | |
localizations { | |
locale { | |
code | |
}, | |
missingStrings, | |
totalStrings | |
} | |
} | |
} | |
''' | |
pontoon_locales = {} | |
try: | |
url = 'https://pontoon.mozilla.org/graphql?query={}'.format(urlquote(query)) | |
response = urlopen(url) | |
json_data = json.load(response) | |
for project, project_data in json_data['data'].items(): | |
for element in project_data['localizations']: | |
locale = element['locale']['code'] | |
pontoon_locales[locale] = round( | |
(float(element['totalStrings'] - element['missingStrings'])) / element['totalStrings'] * 100, | |
2) | |
pontoon_locales = OrderedDict( | |
sorted(pontoon_locales.items(), key=itemgetter(1), reverse=True)) | |
print('\nLocales missing from Nightly builds') | |
for locale in pontoon_locales: | |
if locale not in nightly_locales: | |
print('{}: {}%'.format(locale, pontoon_locales[locale])) | |
print('\nNightly locales missing from release builds') | |
for locale in pontoon_locales: | |
if locale in nightly_locales and locale not in beta_locales: | |
print('{}: {}%'.format(locale, pontoon_locales[locale])) | |
except Exception as e: | |
print(e) | |
if __name__ == '__main__': | |
main() |
This file contains 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 | |
import os | |
from collections import OrderedDict | |
from operator import itemgetter | |
from urllib.parse import quote as urlquote | |
from urllib.request import urlopen | |
def main(): | |
# Get locales of Nightly builds | |
url = 'https://hg.mozilla.org/comm-central/raw-file/tip/mail/locales/all-locales' | |
nightly_locales = [] | |
response = urlopen(url) | |
for locale in response: | |
locale = locale.rstrip().decode() | |
if locale not in ['', 'en-US'] and locale not in nightly_locales: | |
nightly_locales.append(locale) | |
url = 'https://hg.mozilla.org/releases/comm-release/raw-file/tip/mail/locales/shipped-locales' | |
beta_locales = [] | |
response = urlopen(url) | |
for locale in response: | |
locale = locale.rstrip().decode() | |
# Remove platform | |
for text in ['linux', 'osx', 'win32']: | |
locale = locale.replace(text, '').rstrip() | |
if locale not in ['', 'en-US']: | |
beta_locales.append(locale) | |
query = ''' | |
{ | |
firefox: project(slug: "thunderbird") { | |
localizations { | |
locale { | |
code | |
}, | |
missingStrings, | |
totalStrings | |
} | |
} | |
} | |
''' | |
pontoon_locales = {} | |
try: | |
url = 'https://pontoon.mozilla.org/graphql?query={}'.format(urlquote(query)) | |
response = urlopen(url) | |
json_data = json.load(response) | |
for project, project_data in json_data['data'].items(): | |
for element in project_data['localizations']: | |
locale = element['locale']['code'] | |
pontoon_locales[locale] = round( | |
(float(element['totalStrings'] - element['missingStrings'])) / element['totalStrings'] * 100, | |
2) | |
pontoon_locales = OrderedDict( | |
sorted(pontoon_locales.items(), key=itemgetter(1), reverse=True)) | |
print('\nLocales missing from Nightly builds') | |
for locale in pontoon_locales: | |
if locale not in nightly_locales: | |
print('{}: {}%'.format(locale, pontoon_locales[locale])) | |
print('\nNightly locales missing from release builds') | |
for locale in pontoon_locales: | |
if locale in nightly_locales and locale not in beta_locales: | |
print('{}: {}%'.format(locale, pontoon_locales[locale])) | |
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