How to implement a tap:i18n precompiler

I’ve just started to use tap:i18n and it is awesome!

The only issue that I have is the following:

{{_ “hello”}}

` becomes for example: `

Hello, how are you doing today? What a wonderful day to code. Yeah!

` It would be nice to be able to write everything in normal english first, and then replace it in a precompiling step: `

{{_ "Hello, how are you doing today? What a wonderful day to code. Yeah!" }}

` Would be replaced by `

{{_ "MD5_OR_OTHER_HASH" }}

` That way I can have the full english (for now) text while building the template. That way I also coudn't get in trouble for using e.g. "" as key. Additionally it would be possible to generate the JSON files for all the needed translations, while adding the original value as a comment.

My question is, how would I implement a precompiler that modifies the files (replacing String to translate with hash) and then passes them on to the actual compiler used for html files?

Thank you already


Why don’t you use the full string? Instead of using “hello”, use “Hello, how are you doing today? What a wonderful day to code. Yeah!” in your template and you can still do “¿Hola cómo estás hoy? Lo que un día maravilloso con el código. ¡Sí!”, etc.

TL;DR: This is not a Meteor question; use sed or write a macro in your IDE for stuff like this.

It is not that simple because of the dot notation:

From the tap:i18n docs(

A note about dot notation
Note that {_ “”} will be looked under {foo: {bar: “Hello World”}}, and not under “”.

So any . in the text could break it.

Gotcha. You could just replace colons and periods with another character. I’d go with something like “hello_how_are_you_yeah” to make it more descriptive and do the full version in the json file. Again, sed would fully solve the problem but requires work.

Or I could write a precompiler :wink: There are a million ways to solve this issue and I’d like to go with the compiler option. The problem is I’m having a hard time with the documentation of the Build Plugin API hence the question about the precompiler.