HansSchouten / PHPageBuilder

A drag and drop page builder to manage pages in any PHP project
https://www.phpagebuilder.com
MIT License
721 stars 177 forks source link

Add multi language content #96

Closed elgibor-solution closed 2 years ago

elgibor-solution commented 2 years ago

Hi,

Is that possible to set the text content into multi language? I check got page_translations table but not sure how to use it.

i try to add languages under settings table, but the page cannot load.

HansSchouten commented 2 years ago

Yes, this is possible by using for example this setting for english and dutch in the settings table: afbeelding

Next the pagebuilder will show a language selector to fill the page for each of the languages.

elgibor-solution commented 2 years ago

@HansSchouten

Is that just working for en,nl ? i try to set as id,ko but got error below

build:494 Uncaught TypeError: o.a.registerLanguage is not a function at Module.<anonymous> (build:494) at n (build:463) at t.value (build:494) at t.value (build:494) at build:499

Also can advice how to load specific locale from "page_translations" table from frontend?

HansSchouten commented 2 years ago

You should be able to configure any language you like. Is it working if you try with just en,nl? That might indicate there is another issue.

For example on a basic website https://www.gambiabirdingtours.com I use the following records in page_translations: afbeelding

Next the resolver of the pagebuilder would load the right language based on the URL.

elgibor-solution commented 2 years ago

@HansSchouten Yes, its working fine if i set it as en,nl. I use your laravel phppagebuilder package, any config that i need to set?

Its mean resolver of the pagebuilder would load the right language based on the URL and ignore the locale column?

elgibor-solution commented 2 years ago

I manage to make it work, below are the steps to add new languages:

  1. Create new files under "phpagebuilder/lang" folder, for my case id.php and ko.php
  2. Add new data under "languages" array at each files under "phpagebuilder/lang"

'languages' => [ 'en' => 'English', 'nl' => 'Dutch', 'es' => 'Spanish', 'fr' => 'French', 'de' => 'German', 'id' => 'Bahasa', 'ko' => 'Korea' ]

  1. Create new data at "settings" table

INSERT INTOsettingsSET id= '1', setting= 'languages', value= 'id,ko', is_array= '1', created_at= NOW(), updated_at= NULL

@HansSchouten Thanks a lot for your advice