Skip to content

Translation with plurals corrupted/changed after import #3267

@slavijan

Description

@slavijan

Describe the bug

When we import translation key with several plurals usage, Tolgee corrupts it and tries to transform using some magic internal rules, but result after transformations is not correct.

Example

We have a quite simple translation to present duration (with hours and minutes) in our application:

ORIGINAL translation file we import into Tolgee:

{
  "duration": "{hours, plural, =0 {} =1 {1 h} other {{hours} h}} {minutes, plural, =0 {} =1 {1 min} other {{minutes} min}}"
}

Depending on numeric hours and minutes it prints human-readable value and omit zero parts.
For example: 1 h 20 min, 45 min, 3 h, etc

When we import such translation key using Tolgee import, it's shown in Web UI and detect only hours variable, without case for zero hours

And after export (or by getting it via Content Delivery) this translation key in JSON format it becomes:

RESULT corrupted translation:

{
  "duration": "{hours, plural, other {{hours} h {minutes, plural, =0 {} =1 {1 min} other {{minutes} min}}} =1 {1 h {minutes, plural, =0 {} =1 {1 min} other {{minutes} min}}}}"
}

As a result we always have not omitted zero hours parts like 0 h 45 min, 0 h 5 min, etc

To Reproduce

Steps to reproduce the behavior:

Prepare JSON file with one translation key:

{
  "duration": "{hours, plural, =0 {} =1 {1 h} other {{hours} h}} {minutes, plural, =0 {} =1 {1 min} other {{minutes} min}}"
}
  1. Go to 'Import'
  2. Select prepared JSON file and import it
  3. Find the translation in translations, and check how it looks in Web UI
  4. Export imported translation key and compare it with original imported value

Expected behavior

One of these options is acceptable:

  • Tolgee import should not corrupt correct translation where several plurals are used .
  • Or we need to have an ability to disable Tolgee transformation magic for such plurals

Screenshots

Here is how imported translation looks in Web UI (there is no option for zero hours):

Image

Versions and environment

  • Tolgee Platform version: self-hosted Jar archive, v3.133.1
  • Environment: openjdk 21.0.8 2025-07-15 LTS

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions