Hello fellow Ghost devs!
I’m setting to work getting a theme-translation ready. The work is tediously repetitive, and begs to be automated!
I thought this could be a place for Ghost devs to share the techniques they have used to speed up the process.
I see that @GBJsolution, @NickAbs, and @PriorityVision have done fantastic work on automating the process of converting translation helper strings into locale files, with the following projects:
I’m sure @Cathy_Sarisky has dealt with this too, and come up with some clever solution.
However, I haven’t found any projects that aim to tackle the “finding all strings need to be wrapped in translation helpers” part of the process.
(Previously, I manually found strings that needed to be translated by looking through the code, and at the running site, and added the translation helper. Then, I would search the theme files for the translation helper, and copy the strings into locale .json files, and use DeepL/Google translate + what fluency I had to translate the .json files.)
So here is my first baby step:
find . -name '*.hbs' -exec cat {} \; | sed -e 's|<[^>]*>||g' -e 's|{{[^}]*}}||g' | strings -- | grep -F -f /usr/share/dict/words
This bash oneliner sends all relevant theme files through a pipeline that strips out html tags and handlbars includes/comments/helpers, and searches for English words.
The good thing is that it gets stuff that’s hidden on the front-end, like error and success messages.
Obviously, this will only get me part way there: it will miss translatable strings in handlebars helpers, such as prefixes and pluralization, and it will also miss mis-spelled, uncommon, or made up words. But it’s a start! Once I have wrapped these strings (I hope to automate this but I might not bother this time around), I will be able to search for prefixes, suffixes, and plural helpers fairly easily. But I’ll probably write a snippet for that too, once I get to it.
If any of you have snippets you would care to share, or have found projects that do a better job of this, let me know!