Coder Social home page Coder Social logo

Comments (5)

leolabs avatar leolabs commented on August 22, 2024 1

json-autotranslate expects the locales directory to have one subdirectory per language. So instead of locales/en.default.json, your source file would need to be located at locales/en/default.json.

You can then run the tool with yarn json-autotranslate -i locales -s deepl-free -c <your API key>

I hope this helps :)

from json-autotranslate.

leolabs avatar leolabs commented on August 22, 2024 1

The tool should have no issues working with deeply-nested JSON objects, but the error message suggests that the matcher expects variables to be defined as {variable} in the text. If you define your variables as {{variable}}, then you might want to switch to i18next's matcher by adding -m i18next to your command.

I hope this helps :)

from json-autotranslate.

thagxt avatar thagxt commented on August 22, 2024

Thanks a ton @leolabs for the clarification! That worked.

I've another problem/question...

My JSON is "heavily" indented...

example:

{
  "general": {
    "home": "Home",
    "accessibility": {
      "success": {
        "thankYou": "Thank you. Your email was sent",
        "commentSubmitted": "Your comment was submitted."
      },
      "error": "Error:",
      "loading": "loading"
    },
    "meta": {
      "tags": "Tags",
      "page": "page"
    }
  },

when I try to run this thru json-autotranslate, I get a:

An error has occurred:
Expected identifier but "{" found.
SyntaxError: Expected identifier but "{" found.
    at peg$buildStructuredError (/Users/xxx/Documents/dev/translate/node_modules/messageformat-parser/parser.js:407:12)
    at Object.peg$parse [as parse] (/Users/xxx/Documents/dev/translate/node_modules/messageformat-parser/parser.js:1978:11)
    at exports.matchIcu (/Users/xxx/Documents/dev/translate/node_modules/json-autotranslate/lib/matchers/icu.js:6:40)
    at Object.exports.replaceInterpolations (/Users/xxx/Documents/dev/translate/node_modules/json-autotranslate/lib/matchers/index.js:20:24)
    at DeepLFree.<anonymous> (/Users/xxx/Documents/dev/translate/node_modules/json-autotranslate/lib/services/deepl-free.js:119:41)
    at step (/Users/xxx/Documents/dev/translate/node_modules/json-autotranslate/lib/services/deepl-free.js:33:23)
    at Object.next (/Users/xxx/Documents/dev/translate/node_modules/json-autotranslate/lib/services/deepl-free.js:14:53)
    at /Users/xxx/Documents/dev/translate/node_modules/json-autotranslate/lib/services/deepl-free.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/xxx/Documents/dev/translate/node_modules/json-autotranslate/lib/services/deepl-free.js:4:12)

I suppose json-autotranslate isn't able to work with files that are indented that much, is that right? Is there anything I can do to make it work?

Thanks again.

from json-autotranslate.

thagxt avatar thagxt commented on August 22, 2024

Yes, adding -m i18next worked perfectly. Thank you very much for the help @leolabs.

from json-autotranslate.

leolabs avatar leolabs commented on August 22, 2024

Glad I could help :)

from json-autotranslate.

Related Issues (20)

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.