Skip to content

Instantly share code, notes, and snippets.

View flodolo's full-sized avatar

Francesco Lodolo flodolo

View GitHub Profile
@flodolo
flodolo / find_unreferenced_strings_monitor.py
Created April 22, 2025 06:31
Find unreferenced strings in Monitor
#!/usr/bin/env python3
import argparse
import os
import signal
import subprocess
import sys
from compare_locales import parser
# Capture CTRL+C
unreferenced_entities = []
@flodolo
flodolo / find_unreferenced_strings.py
Last active April 8, 2025 10:03
Find unreferenced messages in Bedrock/Springfield
#!/usr/bin/env python3
import argparse
import os
import signal
import subprocess
import sys
from compare_locales import parser
# Capture CTRL+C
unreferenced_entities = []
@flodolo
flodolo / check_monitor_locales.py
Created March 29, 2025 13:53
Check monitor prod locales
#!/usr/bin/env python3
import json
from urllib.parse import quote as urlquote
from urllib.request import urlopen
def main():
# Get completion stats for locales from Pontoon
query = """
@flodolo
flodolo / enable_gh_workflows.py
Created March 26, 2025 15:30
Re-enable disabled GitHub workflows in an org
#! /usr/bin/env python
# Requires PyGithub
from github import Github
import configparser
import os
import requests
import sys
@flodolo
flodolo / find_unreferenced_strings.py
Last active March 23, 2025 07:05
Find unrreferenced Fluent strings in mozilla-central
#!/usr/bin/env python3
import json
import os
import signal
import subprocess
import sys
# Capture CTRL+C
unreferenced_entities = []
processed_files = []
@flodolo
flodolo / check_unused.sh
Created March 12, 2025 11:30
Firefox iOS unused strings
#! /usr/bin/env bash
# Extract strings
fx_repo="/Users/flodolo/github/firefox-ios"
python ./extract_ids_strings.py "${fx_repo}/firefox-ios/Shared/Strings.swift"
input="./string_ids.txt"
while IFS= read -r id
do
grep -qr "${fx_repo}/firefox-ios" --include=\*.swift --exclude=Strings.swift -e "\.${id}" && : || echo "${id}"
@flodolo
flodolo / extract_headers.py
Last active March 7, 2025 18:52
fomo-content hack
#!/usr/bin/env python3
import json
import os
import re
import sys
import argparse
def parse_po_file(filepath):
"""
Reads a .po file and returns the value of the header
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
from fluent.migrate.helpers import transforms_from
from fluent.migrate.transforms import TransformPattern
import fluent.syntax.ast as FTL
class REPLACE_TOTAL(TransformPattern):
def visit_TextElement(self, node):
@flodolo
flodolo / extract_hg_changesets.py
Last active January 27, 2025 12:45
Script to extract l10n builds changeset for Firefox 68–127
import json
import requests
base_url = "https://product-details.mozilla.org/1.0/l10n/"
changesets = {}
for version in range(68, 128):
version_str = f"{version}.0"
for build_number in range(1, 6):
@flodolo
flodolo / minimize_fontawesome.py
Created January 5, 2025 06:54
Pontoon: minimize Font Awesome
#! /usr/bin/env python
"""
The script looks for TTF fonts in FontAwesome folder. It doesn't use WOFF2
directly, because glyph names seem to be unreliable.
Optimized fonts are saved in `/pontoon/base/static/fonts/` as WOFF2.
The list of possible icons is done searching for `fa-*` in specific files (HTML,