lunar icon indicating copy to clipboard operation
lunar copied to clipboard

Enhancement/translations

Open netzknecht opened this issue 1 year ago • 3 comments

Commit 77673f0f4712d8fa70658fbebe0158feb3fb5773 adds two scopes translation and attributeTranslation to constraint queries on translated model attributes and lunar attributes/fields.

Commit 438f915b73e31c3b5bf86d7b421038c26a1a5943 adds a AsTranslated cast, applies it to all relevant models and refactors affected code.

netzknecht avatar Nov 13 '23 11:11 netzknecht

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lunar-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 13, 2023 3:00pm

vercel[bot] avatar Nov 13 '23 11:11 vercel[bot]

@netzknecht Can you explain what this is attempting to fix and is this something that is related to a discussion?

alecritson avatar Nov 15 '23 14:11 alecritson

Hi @alecritson,

this is not a fix, it's an enhancement or extension.

Currently, lunar uses translations as json data in regular laravel database attributes/fields and in lunar attributes, too.

The new scopes in commit 77673f0 allows to query a model for a specific translation in both cases. That can be useful if you connect an external service and you must check the existence of a model by the translation.

The benefit of the second commit 438f915 is, that translated laravel database attributes are more strictly casted "AsTranslated" and all relevant accessor and mutator logic are at one place in the "AsTranslated" castable class. In addition, the accessor and mutator of the "AsTranslated" class converts everything that is no an array or collection into a collection with the current locale as locale key.

netzknecht avatar Nov 27 '23 14:11 netzknecht

This isn't something we want to incorporate.

glennjacobs avatar May 08 '24 11:05 glennjacobs