简体   繁体   中英

Translating JSON file with Angular Gettext

I am using gettext to translate my AngularJS site - it all works fine where I have HTML attributes that I can add 'translate' to.

However I also have quite a large and complex JSON file which needs translating, which includes arrays and objects.

Is there any way to include this in the translation that gettext does, into the PO file? Or would I need to rethink the whole idea of using a JSON file to segment the customer flow?

I have included an initial extract of the JSON file below

{
  "version": "1.1",
  "name": "MVP",
  "description": "Initial customer segmenting flow",
  "enabled": true,
  "funnel": [
    {
      "text": "I am...",
      "image": "",
      "help": "",
      "options": [
        {
          "text": "Placing an order",
          "image": "image1.png",
          "next": 2
        },
        {
          "text": "E-mailing customer service",
          "image": "image2.png",
          "next": 2
        },

Thanks James

Process the HTML file yourself with a script at build-time and dump all translatable messages into a dummy source file with the syntax expected by your string extractor, probably something like this:

<translate>I am ...</translate>
<translate>Placing an order</translate>
<translate>E-mailing customer service</translate>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM