jawainc / simplecontact

Contact Us plugin for October CMS
6 stars 13 forks source link

Adding a language #20

Closed mateop closed 7 years ago

mateop commented 7 years ago

Hi , I am trying to add another language for my project. I created a folder hr (croatian) and copied lang.php and validation.php But any changes that i make do not change the labels. Do I have to enable the language somewhere or am i doing something wrong?

jawainc commented 7 years ago

In backend change your language in Admin Preferences On front end form, when you add form component any page, click on the component box , a popup will appear there you can change form fields labels.

let me know if you have any issues

mateop commented 7 years ago

I can't edit the labels directly because i need them to be in english and croatian, so that when the user changes language the form labels change too.

jawainc commented 7 years ago

This form was built in such a way that non-coders can easily manage it, that's why such language functionality was not included.

How ever you can do it easily: lets say you define a lang parameter under component like this:

component:
    name_field_label: 'Your Name:'

Now in page where you add form component, in that page code area, get this lang like this:

function onStart()
{
  $this['name_field_label'] = Lang::get('zainab.simplecontact::lang.component.name_field_label');
}

next show that in form like this: <label for="name">{{name_field_label}}</label>

this way you can add all languages parameters.

mateop commented 7 years ago

thanks for your help, works great. I created a snippet so that my client can use it on any static page