Polyconseil / easygettext

Simple gettext tokens extraction tools for HTML and Jade files.
79 stars 52 forks source link

Support nativescript-vue/multiple templates #80

Open brunobg opened 4 years ago

brunobg commented 4 years ago

Nativescript vue allow files with multiple templates to target native and web, like this one:

<template web>
  <div class="container">
      <translate>Translate this</translate>
  </div>
</template>
<template native>
  <Page class="page">
      <Label :text="'Translate that' | translate"></Label>
  </Page>
</template>

<script>
export default {
};
</script>

<style>
</style>

gettext-extract does not handle this properly, apparently only dealing with the second section. It'd be nice to support multiple template sections. Is this viable?

vperron commented 4 years ago

I don't know, you would be willing to contribute this feature ? :)

brunobg commented 4 years ago

I could try. Can you give me an idea of how it could be implemented?

On Fri, Apr 17, 2020 at 4:40 AM Victor Perron notifications@github.com wrote:

I don't know, you would be willing to contribute this feature ? :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Polyconseil/easygettext/issues/80#issuecomment-615094905, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGDAUFWZHGLEMUA4AIJZELRNABWHANCNFSM4MJ6YSXA .

-- Bruno Barberi Gnecco

vperron commented 4 years ago

Sure ! In this function we dissect the Vue file and then analyze separately the template and script parts: https://github.com/Polyconseil/easygettext/blob/master/src/extract.js#L61-L69

My first attempt would be to modify it (maybe by dissecting our vue preprocessor) to handle native templates as well.

brunobg commented 4 years ago

Thanks, I'll send a PR soon.