GithubHelp home page GithubHelp logo

Extraction Tool about frenchkiss.js HOT 6 CLOSED

beeing avatar beeing commented on May 22, 2024
Extraction Tool

from frenchkiss.js.

Comments (6)

vthibault avatar vthibault commented on May 22, 2024

Hi @beeing,
Do you have an example/more informations about what you actually trying to do ?

I don't get if you're talking about extracting text from your HTML to a JSON file, or about feeding frenchkiss.js with an imported JSON file.

from frenchkiss.js.

beeing avatar beeing commented on May 22, 2024

Hi, I'm currently using ngx-translate which is similar but for angular.

Based on your example, we need to set the language first with string template.

set('en', {
  hello: 'Hello {name} !',
});

Then use the template by calling:

t('hello', { name: 'John' }); // => 'Hello John !'

However, a natural workflow is to do the following:

t('Hello {name}', { name: 'John' })

Then we will need a CLI (command line utility) to extract all the texts from t().
Example above would return:

{
    "Hello {name}": ""
}

We can then duplicate this JSON as en.json or any {locale}.json with different key values.

I hope you get the idea.

from frenchkiss.js.

beeing avatar beeing commented on May 22, 2024

Just to add in, when the JSON is completed, we can use:

set(locale, loadFromJsonFile)

so that t() will use the correct string templates.

from frenchkiss.js.

vthibault avatar vthibault commented on May 22, 2024

I think you should take a look at i18next-scanner (or another tool).
It extracts translations from your files based on a list of function (here ['t', 'frenchkiss.t']) then generate a json as output.

from frenchkiss.js.

chrisnicola avatar chrisnicola commented on May 22, 2024

You can try https://github.com/lukasgeiter/gettext-extractor. po2json or https://github.com/perch-foundation/po-loader can be used to convert the PO data.

from frenchkiss.js.

beeing avatar beeing commented on May 22, 2024

Ok, looks like this is quite the same. Perhaps can add this into README for a complete picture.
Thanks.

from frenchkiss.js.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.