Last active
April 5, 2018 07:38
-
-
Save vanclist/2a2cd38ae68a28ed63cc160c369cc8b7 to your computer and use it in GitHub Desktop.
List all i18n-ed strings in *.js files
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
from pprint import pprint | |
import subprocess | |
from bs4 import BeautifulSoup | |
def parse(document): | |
soup = BeautifulSoup(document, 'lxml') | |
return [text for text in soup.stripped_strings if text.startswith("<%= i18n")] | |
def read(path): | |
with open(path, "r") as doc: | |
return parse(doc) | |
def list_js_files(directory): | |
return subprocess.check_output( | |
["find", | |
directory, | |
"-name", | |
"*.js"]).split() | |
[pprint((f, read(f))) for f in list_js_files("~/ui/src/")] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment