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

Add translation support to theme settings #559

Merged
merged 5 commits into from
Feb 28, 2020

Conversation

GinoPane
Copy link
Contributor

@GinoPane GinoPane commented Feb 27, 2020

Fields are not marked as translatable by default.
It is a theme author responsibility to configure required fields via theme's config and mark fields as translatable.

For example:

tabs:
  fields:

    ####################################################
    # Tab: Info
    ####################################################

    website_name:
      tab: Info
      label: Website Name
      type: text
      default: Octaskin
      translatable: true

And the result is:

image

Plugin.php Show resolved Hide resolved
@mjauvin
Copy link
Contributor

mjauvin commented Feb 27, 2020

@GinoPane I tried to test this PR using the following instance:

https://88f9e4ea8aac.octodock.com/backend

(user/pass = admin)

I have the following theme.yaml file:

name: demo
description: demo theme
author: OctoberCMS
homepage: 'https://octobercms.com'
code: ''
form:
  tabs:
    fields:
      website_name:
        tab: Info
        label: Website Name
        type: text
        default: Your website name
        translatable: true

And I get the following error when visiting the Cusomize Theme page:

Form record ID has not been specified.

@GinoPane
Copy link
Contributor Author

@mjauvin it's really strange, now it is working, though code is the same. I tried to debug a little, commented plugin changes, loaded the page, after that un-commented changes and it worked 🤷‍♂

image

@mjauvin
Copy link
Contributor

mjauvin commented Feb 27, 2020

Well, you probably did something that got cached or something. I created a new instance, added the same theme.yaml and I get the same error again:

https://cfc0174a7a29.octodock.com/backend

@GinoPane
Copy link
Contributor Author

GinoPane commented Feb 27, 2020

@mjauvin Hm, it seems to be happening when cms_theme_data record is missing for the theme. For any reason the system cannot create the record.

It's interesting 🤔

@mjauvin
Copy link
Contributor

mjauvin commented Feb 27, 2020

How did you get it created the first time?

@GinoPane
Copy link
Contributor Author

@mjauvin when I commented the code, the record was created. I don't fully understand the issue, but for any reason dynamic translatable property got into model's attributes and this exception was thrown: Unexpected type of array when attempting to save attribute "%s", try adding it to the $jsonable property.

This exception was caught in ThemeData::forTheme method and therefore the generic error message was shown on the front end.

Anyway, I committed a fix which should be working fine.

Plugin.php Outdated Show resolved Hide resolved
Plugin.php Outdated Show resolved Hide resolved
Plugin.php Show resolved Hide resolved
Plugin.php Show resolved Hide resolved
@mjauvin mjauvin merged commit e7c230a into rainlab:master Feb 28, 2020
@GinoPane GinoPane deleted the feature/#376 branch February 28, 2020 16:11
mjauvin added a commit that referenced this pull request Mar 20, 2020
* runs params value through htmlspecialchars() to escape html content

* add note about escaped content in translated messages

* use Html::clean() instead of e()

* Revert "add note about escaped content in translated messages"

* escape params when translating messages; introduce transRaw method for legacy usage

* Fix for #376 (#559)

Fix for #376

* Add support for transOrderBy (#516)

Add support for transOrderBy

* update version file for 1.6.8 release

* Disable safe mode checks for ML Static Pages.

Fixes rainlab/pages-plugin#434. Refs: rainlab/pages-plugin#174, rainlab/pages-plugin@6b6b061

* Clear RainLab.Pages caches when saving a static page

Fixes rainlab/pages-plugin#404

* Register asset bundle (#560)

* make sure multi-lingual input form controls have padding-right of 44px
* register asset bundle to process less files into css files
* reposition language selector above textarea box
* fix language selector position when commentAbove is defined

* Update version file for 1.6.9 release

* Fix error with casts fields default locale value (#556)

* only call setLocale() if locale has changed (#561)

* remove unused module

Co-authored-by: Siarhei Karavai <sergey.karavay@gmail.com>
Co-authored-by: Aurélien Roy <aurelien_roy@outlook.com>
Co-authored-by: Ben Thomson <git@alfreido.com>
Co-authored-by: Luke Towers <github@luketowers.ca>
Co-authored-by: Trysystems <av@trysystems.ru>
@mjauvin mjauvin changed the title Fix for rainlab/translate-plugin#376 Add translation support to theme settings Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants