Skip to content

Instantly share code, notes, and snippets.

View kelleyvanevert's full-sized avatar
🦕
would like a pet dino

Kelley van Evert kelleyvanevert

🦕
would like a pet dino
View GitHub Profile
@kelleyvanevert
kelleyvanevert / README.md
Last active May 24, 2023 12:19
A little helper script that uses Babel to scan your React source code for untranslated content

A little helper script that uses Babel to scan your React source code for untranslated content

This script will analyze the translation coverage in your source code. It improves upon i18next-scanner here and there, and is custom-tailored to a use-case I have.

The key insight here is that parsing and scanning code with Babel is remarkably simple, and you can just build a small tool with it when the need arises. And there's a good chance this is an easier path than trying to get existing tooling to work for you!

It assumes you wrap all your content strings like such:

@kelleyvanevert
kelleyvanevert / example-query.sql
Last active March 11, 2024 18:11
TypeScript-typed generateQuery for creating single-SQL nested queries for a certain schema
select json_build_object('__table', 'user', 'firstName', e."first_name", 'lastName', e."last_name", 'managedResources', coalesce("t_managedResources"."data", '[]'), 'ratings', coalesce("t_ratings"."data", '[]')) as "data"
from "user" as "e"
left join (
select "manager_id" as "fkey", json_agg(json_build_object('__table', 'resource', 'ratingTotals', "t_ratingTotals"."data")) as "data"
from "resource" as "e"
left join (
select "resource_id" as "fkey", json_build_object('__table', 'rating_totals', 'avgSatisfaction', e."avg_satisfaction") as "data"
from "rating_totals" as "e"
) as "t_ratingTotals" on "t_ratingTotals"."fkey" = "e"."id"
group by "manager_id"