BoltTranslate / Translate

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

Uncaught Exception 'ContextErrorException' [RFC] #100

Closed peterboorsma closed 7 years ago

peterboorsma commented 7 years ago

I am trying to update a Bolt 2 site with translations to Bolt 3.2.6. Because that's not easy to do I decided to just remove all translations from the database (db table 'bolt_locales', 'locale' fields in all contenttypes), set up a clean Bolt install and then add the Translate extension.

After adding the needed stuff to my contenttype (as documented) and updating the database Bolt returns a ContextErrorException. Can you tell from this what's wrong here?

ContextErrorException in Legacy.php line 85: 
Warning: Invalid argument supplied for foreach()

`
        $values = $this->localeValues;
        $localeSlug = $app['translate.slug'];

        if (isset($values[$localeSlug . 'data'])) {
            $localeData = json_decode($values[$localeSlug . 'data'], true);
            foreach ($localeData as $key => $value) {
                if ($key === 'templatefields') {
                    $templateFields = $app['config']->get('theme/templatefields/' . $record['template'] . '/fields');
                    foreach ($templateFields as $key => $field) {
                        if ($field['type'] === 'repeater') {
                            $localeData = json_decode($value[$key], true);

The contenttype:

pages:
    name: Pages
    singular_name: Page
    fields:
        locale:
            type: locale
            group: content
        title:
            type: text
            class: large
            group: content
            label: Titel
            is_translateable: true
        slug:
            type: slug
            uses: title
        teaser:
            type: html
            height: 150px
            label: Korte introductie van inhoud
            group: content
            is_translateable: true
        body:
            type: html
            height: 300px
            label: Uitgebreide tekst
            group: content
            is_translateable: true
        seo:
            type: seo
            group: SEO
        nldata:
            type: hidden
        nlslug:
            type: locale_data
            index: true
        endata:
            type: hidden
        enslug:
            type: locale_data
            index: true

The extension config: translate_slugs: false

SvanteRichter commented 7 years ago

Edited the issue to use codeblocks instead of inline code, will have a look shortly.

SvanteRichter commented 7 years ago

@peterboorsma Switching to master fixed this, right?

peterboorsma commented 7 years ago

@SahAssar Yes it did!