Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically replace "translate" with "t="unique id" " #7

Open
pptimmermans opened this issue May 28, 2018 · 1 comment
Open

Automatically replace "translate" with "t="unique id" " #7

pptimmermans opened this issue May 28, 2018 · 1 comment

Comments

@pptimmermans
Copy link

Is it possible to automatically replace the translate tag with translation="unique id" so the id's match the id's in the exported json file?

So to extract something like this:
<h1 translate>Etiam rhoncus. Maecenas tempus</h1> <h2 translate>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</h2>

And automatically replace translate with a attribute + id:
<h1 t="211d76eec">Etiam rhoncus. Maecenas tempus</h1> <h2 t="96f37e421">Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</h2>

This way I can easily combine it with aurelia-i18n which looks for the "t" attribute.

Thanks,
PP

@thomas-darling
Copy link
Owner

thomas-darling commented May 30, 2018

Hi @pptimmermans,
This is a very good idea, and something I've actually had on my own wish list for a while too.
You can already get some of what you are looking for today, by specifying this export option:

replaceWithIds: "${'*' | t}",

Given a template such as this:

<template>
    <span translate>Text</span>
    <img alt.translate="Text"></img>
    <img alt="Text" alt.translate></img>
</template>

The export task will output this:

<template>
    <span>${'0a328f243' | t}</span>
    <img alt="${'0a328f243' | t}"></img>
    <img alt="${'0a328f243' | t}"></img>
</template>

While this should work perfectly for static text, I think you might run into some issues if you have binding expressions within your text, as it seems Aurelia then also needs a t-params attribute added.

I'll look into it a bit more in the very near future, and see if I can come up with something - maybe a hook where you can specify a custom function, which receives the element and annotation info, and then has the opportunity to manipulate the element and its attributes in any way it wants. I'll have to look into this a bit more before promising too much though :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants