Check for hardcoded text in Rails views - I18n
I think you can get very far by just using grep:
cat $(find . | grep .html.erb) | grep -v '[=<>{}$/;]' | grep '\w \w'
This finds texts based on the idea that there are some characters which are not typical for texts
grep -v '[=<>{}$/;]'
and that there should be at least one space with a preceding word character and one where a word character follows
grep '\w \w'
This might not be a hundred percent accurate but is a fast and easy way to quickly check for hard coded text.
If most lines of code are short and the hard-coded text is long, you can use strings -n [number]
to find any text with a particular number of characters.
<html> |
<head> |
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
<title>Example Page</title> |
|
</head> |
|
<body> |
<h1><%= @page.name %></h1> |
<p> |
This is a piece of hard coded text which must be found.
</p> |
</body> |
</html> | 40 characters
If you set the length to 40...
$ cat $(find . | grep .html.erb) | strings -n 40
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
This is a piece of hard coded text which must be found.
It should be mostly accurate in finding hard-coded text.