New Cookbook Articles

We’ve added a bunch of new cookbook articles for you:

Using Kirby for multiple sites
https://getkirby.com/docs/cookbook/content-structure/multisite

How to import and export translations
https://getkirby.com/docs/cookbook/i18n/import-export

Restricting access to your site
https://getkirby.com/docs/cookbook/security/access-restriction

Quicktip: Filtering by language
https://getkirby.com/docs/cookbook/i18n/filter-by-language

5 Likes

Hi Bastian,

does the import/export of translations work with Kirby v2?

There are view slight differences in the setup. Kirby 2 doesn’t have the $kirby->impersonate() method for example. But in general it should be mostly compatible.

Thanks! I tested this fast last night and the second loop in the export script throws an error:

PHP Fatal error: Uncaught Error: Call to a member function toArray() on string in /scripts/translation-export:20 Stack trace:#0 {main} thrown in /scripts/translation-export on line 20

I’m not versed in PHP to see immediately why, but I’m posting this here in case someone wants to check it. I need an XML export/import, ideally, but I’m not sure how to go about it.

The other thing is the version which at this point is not planned for update.

Thanks for the feedback anyway!

Try $page->content($language)->data() instead of $page->content($language)->toArray()

It doesn’t have a problem with $page, it stumbles at the second loop which, as far as I understand, drags out the files: $file->content($language)->toArray().

I tried using data() but it does not change its objections.

Oh, right! In v2 the content object for files was only accessible via $file->meta()

With $file->meta($language)->toArray() it runs, confirms it’s done, but the export json file is empty.
Don’t want to waste your time on this. The translators (I was trying to make their work easier) are using some CAT software that uses xml and this will not help much in this case, anyway. On top of being the “wrong” Kirby version.

Thanks for the help, Bastian!

1 Like