Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching language override the default language #149

Open
aalshaikh opened this issue Oct 6, 2017 · 10 comments
Open

Switching language override the default language #149

aalshaikh opened this issue Oct 6, 2017 · 10 comments

Comments

@aalshaikh
Copy link

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
Copy link

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
Copy link
Author

yes i added the extra hidden fields, and not working

@lenvanessen
Copy link

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

@aalshaikh
Copy link
Author

aalshaikh commented Oct 11, 2017

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
Copy link

Note: I updated the comment to format the code

@aalshaikh
Copy link
Author

@lenvanessen any luck with issue?

@lenvanessen
Copy link

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
Copy link

DamienChauvet commented Nov 8, 2017

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
Copy link

Hi @damien,

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

@mrneatly
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants