BoltTranslate / Translate

Provides translation for contenttypes.
Other
43 stars 37 forks source link

Switching language override the default language #149

Open aalshaikh opened 6 years ago

aalshaikh commented 6 years ago

i have the latest translate extension, and the latest of Bolt.cm, the issue is when i select english and create new content with english and save, then i want to translate the same content to another language example Arabic, so i selected the same content and switched to arabic from language dropdown menu and i changed the text it's will override the english content to another language.

is this how to extension work? or there is something wrong in my configuration?

lenvanessen commented 6 years ago

Hi @aalshaikh,

Could you make sure that you have done step 4 of the readme? Because if you don't add the extra hidden fields, Translate has no place to store the translations.

aalshaikh commented 6 years ago

yes i added the extra hidden fields, and not working

lenvanessen commented 6 years ago

Could you share your contenttypes.yml and the translate.animal.yml?

aalshaikh commented 6 years ago

Here is contenttypes.yml

Cars:
    name: Cars
    singular_name: Car
    fields:
        locale:
            type: locale
            group: content
        title:
            type: text
            class: large
            group: content
            translatable: true
        slug:
            type: slug
            uses: title
            translatable: true
        image:
            type: image
        teaser:
            type: html
            height: 150px
        body:
            type: html
            height: 300px
        template:
            type: templateselect
            filter: '*.twig'
        endata:
            type: hidden
        enslug:
            type: locale_data
            index: true
        ardata:
            type: hidden
        arslug:
            type: locale_data
            index: true
    taxonomy: [ groups ]
    recordsperpage: 100`

and here is translate.animal.yml:

# The locales the site should be available in
locales:
    en_GB:
        label: English
        slug: en
    ar_JO:
        label: Arabic
        slug: ar

# Enable/disable automatic routing override.
# Enabling this will prefix all routes with {_locale} which leads to links like
# /en/pages/yourpageslug It is recommended that you leave this on unless you
# want to build your own routing.
routing_override: false

# Enable/disable showing of flag icons next to language names.
show_flags: false

# Enable/disable the menubuilder override.
# Enabling this will make the menu output links in the format of the automatic
# routing. It is recommended that you leave this on unless you want to build
# your own localized menus.
menu_override: true

# Enable/disable the url_generator override.
# Enabling this will override the url generator to make sure that we don't
# generate links without a locale. This is highlig recommended to keep unless
# you also build your own override since it can cause WSOD on 404's otherwise.
url_generator_override: false

# Enable/disable translated slugs.
# Enabling this will use translated slugs instead of using the same slug for
# all languages. Only set to false if you also don't set your slugs to `translatable`.
translate_slugs: false

# Enable/disable using Accept-Language header to determine the locale for
# redirection on `/`.
# Enabling this will redirect visitors on `/` to the preferred locale based on
# the Accept-Language header. Disabling this will always redirect `/` to the
# first locale set in `locales` above.
use_accept_language_header: false

# Enable/disable translation of the dashboard.
translate_dashboard: false
lenvanessen commented 6 years ago

Note: I updated the comment to format the code

aalshaikh commented 6 years ago

@lenvanessen any luck with issue?

lenvanessen commented 6 years ago

Hi!

I can’t reproduce here, did you run the database update as Well? Can you Check If your database has a colum ardata in it?

DamienChauvet commented 6 years ago

Hi, Same thing happened to me. After lots of tests, the problem was because the "slug" field of my contenttype was different from my contenttype definition:

blogpost:  #differs from slug
    name: bplogpost test
    singular_name: blogpost
    slug: post  #removing this line AND renaming 'blogpost' to 'post' solves everything ;)
    fields:
        locale:
            type: locale
            group: content
        endata:
            type: text
        enslug:
            type: locale_data
            index: true
        esdata:
            type: text
        esslug:
            type: locale_data
            index: true
        title:
            type: text
            translatable: true
lenvanessen commented 6 years ago

Hi @damien,

Thanks for the hint. I’ll Check it and try and patch it as soon as i can!

mrneatly commented 6 years ago

Hello,

Struggling with the same problem, but with repeater fields: new content creation procedure performs with no issues, but when I update the same content after selecting another locale, values of repeater fields of previous locale are replaced with new ones.

My contenttype config:

services:
    name: Services
    singular_name: Service
    fields:
        name:
            type: text
            translatable: true
        slug:
            type: slug
            uses: name
            translatable: true
        teaser:
            type: text
            translatable: true
        description:
            type: html
            height: 300px
            translatable: true
        image:
            type: image
            extensions: [ jpg, png ]
        subservices:
            type: repeater
            fields:
                name:
                    type: text
                    translatable: true
                price:
                    type: float
        locale:
            type: locale
        rudata:
            type: hidden
        ruslug:
            type: locale_data
            index: true
        etdata:
            type: hidden
        etslug:
            type: locale_data
            index: true

A already have tried applying instructions from step 4 of general instruction for repeater fields, like this:

...
subservices:
      type: repeater
      fields:
          name:
              type: text
              translatable: true
          price:
              type: float
          rudata:
              type: hidden
          ruslug:
              type: locale_data
              index: true
          etdata:
              type: hidden
          etslug:
              type: locale_data
              index: true
...

but in latter case I got next error message:

Template "fields/_locale_data.twig" is not defined in "@bolt/editcontent/fields/_repeater-group.twig" at line 53.

from which I conclude that this is not a proper approach.

Is it a core-related bug, or am I really doing something wrong?