monorepo: Machine generate: doesn't embed JSON children, uses path members

Problem

https://github.com/osmosis-labs/osmosis-frontend/pull/1622/files/809411475fc2ef0edcbfefb69675af10a657ec85#diff-96148166b124a270d5e3831559a1d4dab4ff671bba2e2072b1e69cb65eb955f6

Looks like machine translate appends AI-generated translations to the end of the file as errors.fallbackText1: "..." instead of adding it as a member to the child object like { errors: { fallbackText1: "..." } }. Could cause problems when diffing the files.

Steps to reproduce

  1. Add a JSON child translation in the ref lang
  2. Run machine translate
  3. Notice key path members

Additional information (screenshots?)

  • Browser:
  • Operating system:

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 32 (30 by maintainers)

Most upvoted comments

Update of the current state:

  1. The translation for empty/non-existent files works. Add a new language tag in the project.inlang.json and execute the command.
  2. Nesting or flattening of IDs is detected on a file-by-file basis. An empty file is translated with the same formatting as the source language file. But if a file only contains unnested message IDs before the machine translation, it will flatten every key again because of the file-by-file detection.

Example:

{
  "title": "Test",
  "description": "asdf"
}

This file is detected as flattened, and nested message IDs will be flattened.

I propose:

  • detect once if the message IDs in the source language file are nested or flattened
  • keep the formatting consistent for the whole source language file
  • apply the same formatting for all other language files

@inlang/plugins @felixhaeberle @samuelstroschein @dominikg @jonator Do you agree with that, or are there any concerns? 👍 / 👎

  • detect once if the message IDs in the source language file are nested or flattened
  • keep the formatting consistent for the whole source language file
  • apply the same formatting for all other language files

I have tested that expected behavior. It now works as proposed.

Assigning @NilsJacobsen after debugging -> probably the problem is in the json plugin. Test with npx inlang@latest machine translate -f in the test-app example of the sdk-js. Implementation of machine translate can be found here.

Did you test it because @NiklasBuchfink added some fixes for the jsonPlugin last week?