makemessages: Call ‘formatjs extract’ for JavaScript extraction.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2021-04-10 00:28:57 -07:00
committed by Tim Abbott
parent 4b4cea90a3
commit 810ba7fce1

View File

@@ -36,6 +36,7 @@ import itertools
import json import json
import os import os
import re import re
import subprocess
from argparse import ArgumentParser from argparse import ArgumentParser
from typing import Any, Dict, Iterable, Iterator, List, Mapping from typing import Any, Dict, Iterable, Iterator, List, Mapping
@@ -202,6 +203,19 @@ class Command(makemessages.Command):
data = self.ignore_javascript_comments(data) data = self.ignore_javascript_comments(data)
translation_strings.extend(self.extract_strings(data)) translation_strings.extend(self.extract_strings(data))
extracted = subprocess.check_output(
[
"node_modules/.bin/formatjs",
"extract",
"--additional-function-names=$t,$t_html",
"--format=simple",
"--ignore=**/*.d.ts",
"static/js/**/*.js",
"static/js/**/*.ts",
]
)
translation_strings.extend(json.loads(extracted).values())
return list(set(translation_strings)) return list(set(translation_strings))
def get_template_dir(self) -> str: def get_template_dir(self) -> str: