Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arb string it is stored in the nested JSON format if using dots in keys #13037

Open
2 tasks done
Gallimathias opened this issue Nov 15, 2024 · 4 comments
Open
2 tasks done
Labels
bug Something is broken.
Milestone

Comments

@Gallimathias
Copy link

Describe the issue

We use arb files and have changed the translation framework in our frontend.

The extracted keys for the translations now have a dot. Which is allowed according to the arb specification.

The problem is that now the arb files are exported in nested JSON format as already described in this bug #4779 here.

This is not forbidden for ARB per se, but unfortunately other frameworks cannot necessarily deal with it. So now we also have problems and are looking for a workaround for it

I already tried

  • I've read and searched the documentation.
  • I've searched for similar filed issues in this repository.

Steps to reproduce the behavior

Just use this arb file as import "Base file"

{
  "@@locale": "en-US",
  "@@author": "",
  "@@last_modified": "2024-11-12T10:08:42.7072397Z",
  "@@context": "",
  "app.page-title": "My Application",
  "@app.page-title": {
    "context": "#document:div:header:mat-toolbar:span:#text",
    "description": "some description"
  },
  "app.flights-label": "Flights",
  "@app.flights-label": {
    "context": "#document:div:header:mat-toolbar:span:#text",
    "description": "Flights"
  }
}

and as output translation you get this

{
  "@@locale": "de-DE",
  "@@author": "",
  "@@last_modified": "2024-11-12T10:08:42.7072397Z",
  "@@context": "",
  "app.page-title": "Meine Applikation",
  "app": {
    "@app.page-title": {
      "context": "#document:div:header:mat-toolbar:span:#text",
      "description": "some description"
    },
    "app.flights-label": "Flüge",
    "@app.flights-label": {
      "context": "#document:div:header:mat-toolbar:span:#text",
      "description": "Flights"
    }
  }
}

Expected behavior

The expection is that you have this as a base file

{
  "@@locale": "en-US",
  "@@author": "",
  "@@last_modified": "2024-11-12T10:08:42.7072397Z",
  "@@context": "",
  "app.page-title": "My Application",
  "@app.page-title": {
    "context": "#document:div:header:mat-toolbar:span:#text",
    "description": "some description"
  },
  "app.flights-label": "Flights",
  "@app.flights-label": {
    "context": "#document:div:header:mat-toolbar:span:#text",
    "description": "Flights"
  }
}

and this as a output file

{
  "@@locale": "de-DE",
  "@@author": "",
  "@@last_modified": "2024-11-12T10:08:42.7072397Z",
  "@@context": "",
  "app.page-title": "Meine Applikation",
  "@app.page-title": {
      "context": "#document:div:header:mat-toolbar:span:#text",
      "description": "some description"
    },
    "app.flights-label": "Flüge",
    "@app.flights-label": {
      "context": "#document:div:header:mat-toolbar:span:#text",
      "description": "Flights"
    }
}

Screenshots

No response

Exception traceback

No response

How do you run Weblate?

Docker container

Weblate versions

5.8.3

Weblate deploy checks

No response

Additional context

No response

@nijel
Copy link
Member

nijel commented Nov 17, 2024

Weblate shouldn't change the structure of existing files. Does this happen on editing?

@Gallimathias
Copy link
Author

Weblate shouldn't change the structure of existing files. Does this happen on editing?

No matter if it's existing or not, the output arb files are always broken like in the example above. I guess the arb logic share code with the nested json code. That's why this behaviour happens.

Maybe the same fix as for #4779 is required. This pr solves the bug only for normal json outputs

Gallimathias added a commit to Gallimathias/translate that referenced this issue Nov 18, 2024
When using ArbFiles, we stumbled across the same case in PR WeblateOrg/weblate#4779. See PR WeblateOrg/weblate#13037

To solve this, I tried to adapt PR translate#4161 to Arb files in the hope that it solves the actual problem
@Gallimathias
Copy link
Author

I try to fix it: translate/translate#5415 ^^. So maybe someone with more Phyton expirence can look into that :D

@nijel
Copy link
Member

nijel commented Nov 18, 2024

translate/translate#5415 is a good starting point (it will fix newly creates strings), but still, Weblate should not change structure upon editing, that needs additional investigation.

@nijel nijel added the bug Something is broken. label Nov 18, 2024
nijel pushed a commit to translate/translate that referenced this issue Nov 18, 2024
When using ArbFiles, we stumbled across the same case in PR WeblateOrg/weblate#4779. See PR WeblateOrg/weblate#13037

To solve this, I tried to adapt PR #4161 to Arb files in the hope that it solves the actual problem
nijel pushed a commit to translate/translate that referenced this issue Nov 20, 2024
When using ArbFiles, we stumbled across the same case in PR WeblateOrg/weblate#4779. See PR WeblateOrg/weblate#13037

To solve this, I tried to adapt PR #4161 to Arb files in the hope that it solves the actual problem
@nijel nijel added this to the 5.10 milestone Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken.
Projects
None yet
Development

No branches or pull requests

2 participants