Skip to content

Commit

Permalink
Merge pull request #145 from BoltTranslate/misspellings
Browse files Browse the repository at this point in the history
Fix misspellings but allow the old for now
  • Loading branch information
lenvanessen authored Sep 27, 2017
2 parents 10a40d0 + 8f40492 commit 1fd62ff
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,34 @@ the Bolt 3.1+ version**
[...]
```

3. Add the `is_translateable` argument to all fields you want to be
3. Add the `translatable` argument to all fields you want to be
translatable.

**Note: In older versions the config `translatable` was misspelled as
`is_translateable`. The old way is still supported, but deprecated and
will be removed in a future version.**

```
[...]
title:
type: text
class: large
group: content
is_translateable: true
translatable: true
[...]
```
To translate templatefields you simply tag the templateselect
with `is_translateable` and all the templatefields will be translateable.
with `translatable` and all the templatefields will be translatable.
```
[...]
templateselect:
type: templateselect
is_translateable: true
translatable: true
filter: '*.twig'
[...]
```
4. Add the hidden fields to all the contenttypes that have translateable
4. Add the hidden fields to all the contenttypes that have translatable
fields, two for each locale: one called `your_localedata` and one called
`your_localeslug`. So for the above `locales` example you would put:

Expand Down Expand Up @@ -155,22 +159,22 @@ pages:
type: text
class: large
group: content
is_translateable: true
translatable: true
slug:
type: slug
uses: title
is_translateable: true
translatable: true
image:
type: image
is_translateable: true
translatable: true
teaser:
type: html
height: 150px
is_translateable: true
translatable: true
body:
type: html
height: 300px
is_translateable: true
translatable: true
template:
type: templateselect
filter: '*.twig'
Expand Down
2 changes: 1 addition & 1 deletion config/config.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ url_generator_override: true

# 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 `is_translateable`.
# all languages. Only set to false if you also don't set your slugs to `translatable`.
translate_slugs: true

# Enable/disable using Accept-Language header to determine the locale for
Expand Down
11 changes: 8 additions & 3 deletions src/EventListener/StorageListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,17 @@ private function getTranslatableFields($fields)
$translatable = [];
if (is_array($fields)) {
foreach ($fields as $name => $field) {
if (isset($field['is_translateable']) &&
$field['is_translateable'] === true &&
// Remove is_translateable when it is no longer supported
if (isset($field['is_translateable'])) {
$field['translatable'] = $field['is_translateable'];
}

if (isset($field['translatable']) &&
$field['translatable'] === true &&
$field['type'] === 'templateselect'
) {
$translatable[] = 'templatefields';
} elseif (isset($field['is_translateable']) && $field['is_translateable'] === true) {
} elseif (isset($field['translatable']) && $field['translatable'] === true) {
$translatable[] = $name;
}
}
Expand Down
3 changes: 2 additions & 1 deletion templates/fields/_locale.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{% set translatable = [] %}

{% for name, field in context.contenttype.fields %}
{% if field.is_translateable is defined and field.is_translateable == true %}
{# Remove is_translateable when it is no longer supported #}
{% if (field.translatable is defined and field.translatable == true) or (field.is_translateable is defined and field.is_translateable == true) %}
{% set translatable = translatable|merge(['#'~name, '[name="'~name~'"]', '[name^="'~name~'[0]"]', '[name="'~name~'[file]"]']) %}
{% endif %}
{% endfor %}
Expand Down

0 comments on commit 1fd62ff

Please sign in to comment.