Astrotomic / laravel-translatable

A Laravel package for multilingual models
https://docs.astrotomic.info/laravel-translatable/
MIT License
1.23k stars 155 forks source link

how to get translations grouped by locale? #312

Closed nekooee closed 1 year ago

nekooee commented 1 year ago

the current output is like this:

{
  "id": 336,
  "phrase": "About The",
  "title": "subject"
  "translations": [
    {
      "id": 1006,
      "phrase": "About The",
       "title": "subject"
      "locale": "en",
      "translate_phrase_id": 336
    },
    {
      "id": 1008,
      "phrase": "Over The",
       "title": "onderwerp"
      "locale": "nl",
      "translate_phrase_id": 336
    }
  ]
}

but sometimes I need this :

{
  "id": 336,
  "phrase": "About The",
  "title": "subject"
  "en": {
    "phrase": "About The"
    "title": "subject"
  },
  "nl": {
    "phrase": "Over The"
    "title": "onderwerp"
  },
}

How can I do this?

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days