prime icon indicating copy to clipboard operation
prime copied to clipboard

Localized Field

Open mpartipilo opened this issue 6 years ago • 9 comments

Do you think it would be possible in the future to have localized fields instead of localized documents?

mpartipilo avatar Jan 18 '19 13:01 mpartipilo

Well, I doubt we will replace it completely, but we may implement them somehow. Contentful does this very well, so I may end up model it after them

birkir avatar Jan 18 '19 14:01 birkir

I am probably going to include this in 0.3.0 in the form argument on each field.

query {
  Blog {
    title
    titleNL: title(locale:"nl")
    body(locale:"is")
  }
}

Would this work for you? To reduce bloat this could be configurable by schema or field.

birkir avatar Feb 05 '19 06:02 birkir

I understand why it must be done this way, but it’s not pretty.

Personally, I would rather have the option to filter all the fields from a query parameter.

query(locale: “es”) {...

I think querying the same field in multiple languages in the same query is not a common case, though still useful for advanced cases and composing.

On Tue, 5 Feb 2019 at 07:30, Birkir Gudjonsson [email protected] wrote:

I am probably going to include this in 0.3.0 in the form argument on each field.

query { Blog { title titleNL: title(locale:"nl") body(locale:"is") } }

Would this work for you? To reduce bloat this could be configurable by schema or field.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/birkir/prime/issues/43#issuecomment-460528407, or mute the thread https://github.com/notifications/unsubscribe-auth/AAcgaebulN4iz79Iq2CRu4Ya47-CL7s1ks5vKST7gaJpZM4aH7cP .

mpartipilo avatar Feb 05 '19 07:02 mpartipilo

I don't have a strong opinion on how Localization is implemented, but I'm glad to see it will be released on 0.3.0 or soon enough

Keep up the great work, thanks for open sourcing! 👍 💯

agustif avatar Feb 05 '19 13:02 agustif

The way Cockpit CMS does it is with a URL query parameter. If the parameter is not provided the localized fields get a locale suffix. So far this is the setup that has worked best for me.

mpartipilo avatar Feb 08 '19 08:02 mpartipilo

Ok. But how is that different from what we already have?

query {
  Blog(locale:"nl") {
    title
    body
  }
}

I am starting to think that this ticket is more about UI rather than API, am I correct?

birkir avatar Feb 08 '19 15:02 birkir

That would indeed work, of course. I brought up the other approach just in case it might give you more ideas.

My concern is more towards multilingual sites using gatsbyjs.

mpartipilo avatar Feb 08 '19 23:02 mpartipilo

GraphCMS is also doing this on field level:

 query page($id: ID, $locale: Locale) {
      page(where: { id: $id }) {
        updatedAt
        createdAt
        id
        title
        slug(locale: $locale)
     }
 }

@birkir do you still plan to implement this in 0.3?

stvnwrgs avatar Apr 08 '19 22:04 stvnwrgs

My only question with translated documents - how do you connect two documents?

For example, we have city tour website. We have a list of cities and a list of places for each city). So titles/descriptions suppose to be translated, but geo-location, open/closing times, price range are all the same across the languages. What I do now is that I have same entities in DB, but translate fields.

stereobooster avatar Apr 10 '19 12:04 stereobooster