Skip to content

Instantly share code, notes, and snippets.

@flodolo
Created June 24, 2020 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flodolo/d43f5a319e1209e649cb6dca49e85407 to your computer and use it in GitHub Desktop.
Save flodolo/d43f5a319e1209e649cb6dca49e85407 to your computer and use it in GitHub Desktop.
Check Thunderbird l10n status
#! /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()
#! /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