Jump to content



Photo
- - - - -

Configuration Modules


  • Please log in to reply
29 replies to this topic

#1   Harald Ponce de Leon

Harald Ponce de Leon

    Healthy Giraffe

  • Core Team
  • 4,820 posts
  • Real Name:Harald Ponce de Leon
  • Gender:Male
  • Location:Solingen, Germany

Posted 15 February 2012 - 16:24

Hi All..

There has always been one area in osCommerce Online Merchant that was not able to be translated into different languages, which has been the configuration parameters. The title and descriptions are hardcoded in english in the database osc_configuration table. Not only that, a hack was introduced to see and set the values dynamically on a per configuration parameter level - which had an ugly implementation that was also hardcoded in the database table.

I just pushed out a proof of concept to finally fix this for v3.0 to a new cfg branch on my github repo:

https://github.com/h...mmerce/tree/cfg

This introduces the concept of Configuration Modules where each configuration parameter is a module, where one common module is used by slightly over half of the configuration parameters to set its value via a normal text input field. Each module has its own language definition file where the title and description are defined, and also additional definitions for unique parameter values.

The modules are named in CamelCase style of the parameter key, for example the module for STORE_COUNTRY is found in:

osCommerce/OM/Core/Site/Admin/Module/Configuration/StoreCountry.php
osCommerce/OM/Core/Site/Admin/languages/en/US/modules/Configuration/StoreCountry.php

The language definitions are defined as:


cfg_store_country_title
cfg_store_country_description

Simple configuration parameters do not need their own module, they can use the standard common module but must have their own language definition file containing the title and description of the parameter.

There are two methods to retrieve the configuration parameter value:

$Config->get() // returns a formated value, eg United States of America (by default it returns the getRaw() value)
$Config->getRaw() // returns the real value, eg 223 (the country ID for USA)

The configuration table can be optimized from:

configuration_id
configuration_title
configuration_key
configuration_value
configuration_description
configuration_group_id
sort_order
last_modified
date_added datetime
use_function
set_function

to:


configuration_id
configuration_key
configuration_value
configuration_group_id
sort_order

(A field could be added to define the module name, but this can be generated automatically from the configuration key)

Although it will be a lot of work to create the initial configuration parameters, it brings in much more flexibility on how configuration parameters can present their input fields and also allow for the parameters to be translated into different languages.

What are your thoughts? Is this a good implementation to work on?

Kind regards,
Harald Ponce de Leon

#2   foxp2

foxp2

    strong as a Twig

  • Banned
  • 310 posts
  • Real Name:Laurent
  • Gender:Male
  • Location:France

Posted 15 February 2012 - 17:09

Hi Harald,

Is this a good implementation to work on?

/w00t.gif' class='bbc_emoticon' alt='(w00t)' /> YES ! /w00t.gif' class='bbc_emoticon' alt='(w00t)' />
-------------------

#3   foxp2

foxp2

    strong as a Twig

  • Banned
  • 310 posts
  • Real Name:Laurent
  • Gender:Male
  • Location:France

Posted 15 February 2012 - 17:46

it's a real improvement.
It also has the effect of making life easier to translators

[sorry, can't edit my post]
-------------------

#4   Harald Ponce de Leon

Harald Ponce de Leon

    Healthy Giraffe

  • Core Team
  • 4,820 posts
  • Real Name:Harald Ponce de Leon
  • Gender:Male
  • Location:Solingen, Germany

Posted 15 February 2012 - 18:01

Hi Laurent..

Yep. I just created a script to automatically create the language definition files from the database and have pushed them to my cfg branch.

I would wait with the translations though until the english definitions have been updated and have made it to a release.

@Mark Evans what do you think of backporting the finalized implementation to v2.3? (this would break compatibility so a version number jump would be required)

Kind regards,
Harald Ponce de Leon

#5   multimixer

multimixer

    Lemons or Melons ?

  • Partner
  • 4,560 posts
  • Real Name:George Zarkadas
  • Gender:Male
  • Location:Greece

Posted 15 February 2012 - 18:07

@Mark Evans what do you think of backporting the finalized implementation to v2.3? (this would break compatibility so a version number jump would be required)


Yes, lets jump a version number, that's a great idea this multilingual configuration, makes it also much easier to create modules, not having to type in all that description text into the query

#6   foxp2

foxp2

    strong as a Twig

  • Banned
  • 310 posts
  • Real Name:Laurent
  • Gender:Male
  • Location:France

Posted 15 February 2012 - 19:00

Hi Laurent..

Yep. I just created a script to automatically create the language definition files from the database and have pushed them to my cfg branch.


thank you for that /thumbsup.gif' class='bbc_emoticon' alt=':thumbsup:' />

I would wait with the translations though until the english definitions have been updated and have made it to a release.


Oh, a new directory was added ( https://github.com/f...s/Configuration ) /happy.png' class='bbc_emoticon' alt='^_^' />
-------------------

#7   GniDhal

GniDhal
  • Members
  • 32 posts
  • Real Name:Francois-Xavier
  • Gender:Male
  • Location:France (56400 Auray)

Posted 15 February 2012 - 20:55

Hi Harald!
It's a wonderful idea!
Thanks a lot for this new localized part.

Regards
FX

#8   foxp2

foxp2

    strong as a Twig

  • Banned
  • 310 posts
  • Real Name:Laurent
  • Gender:Male
  • Location:France

Posted 15 February 2012 - 21:19

@GniDhal :
private joke : ici j'ai une grosse truffe (remplace avoir avec ĂȘtre)

forceful return of a community that supports Oscommerce since ten years ! /whistling.gif' class='bbc_emoticon' alt=':-' />
-------------------

#9   burt

burt

    Vanquisher of Demons

  • Community Team
  • 9,724 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 15 February 2012 - 22:12

Great for 3.

Maybe leave series 2.x as it is to ensure compatibility for upgrading from prior to 2.4?

Edited by burt, 15 February 2012 - 22:13.

IF YOU MAKE A POST REQUESTING HELP...please state the exact version of osCommerce that you are using. THANKS
 
Responsive osCommerce, join in:
http://forums.oscomm...rom-the-get-go/

--
Making your shop better, one osCommerce module at a time - get in touch, or get my newsletter every 1st of the month.
 
Big Bang Templates for 2.3.4

#10   foxp2

foxp2

    strong as a Twig

  • Banned
  • 310 posts
  • Real Name:Laurent
  • Gender:Male
  • Location:France

Posted 16 February 2012 - 09:43

hi Harald,
Is it possible to add a htmlspecialchars_decode for configuration_description ?

especially for this line in \osCommerce\OM\Core\Site\Admin\Application\Configuration\pages\entries_edit.php
<p><?php echo $OSCOM_ObjectInfo->get('configuration_description'); ?></p>

/unsure.png' class='bbc_emoticon' alt=':unsure:' />
-------------------

#11   Harald Ponce de Leon

Harald Ponce de Leon

    Healthy Giraffe

  • Core Team
  • 4,820 posts
  • Real Name:Harald Ponce de Leon
  • Gender:Male
  • Location:Solingen, Germany

Posted 16 February 2012 - 09:48

Hi Laurent..

Can you post a language definition example that is causing a problem?

Kind regards,
Harald Ponce de Leon

#12   foxp2

foxp2

    strong as a Twig

  • Banned
  • 310 posts
  • Real Name:Laurent
  • Gender:Male
  • Location:France

Posted 16 February 2012 - 09:49

\osCommerce\OM\Core\Site\Admin\languages\fr_FR\modules\Configuration\StoreCountry.php
cfg_store_country_description = The country my store is located in <br /><br /><strong>Note: Please remember to update the store zone.</strong>

it's not a problem, htmlspecialchars_decode will be useful

Edited by foxp2, 16 February 2012 - 09:50.

-------------------

#13   Harald Ponce de Leon

Harald Ponce de Leon

    Healthy Giraffe

  • Core Team
  • 4,820 posts
  • Real Name:Harald Ponce de Leon
  • Gender:Male
  • Location:Solingen, Germany

Posted 16 February 2012 - 09:52

Hi Laurent..

That is being shown correctly to me (with HTML formatting). Are you seeing the actual HTML tags?

Kind regards,
Harald Ponce de Leon

#14   foxp2

foxp2

    strong as a Twig

  • Banned
  • 310 posts
  • Real Name:Laurent
  • Gender:Male
  • Location:France

Posted 16 February 2012 - 10:01

I'm seeing nothing, because i've not installed the script ... /innocent.gif' class='bbc_emoticon' alt='o:)' />
i'm going to check it later
sorry to trouble you /blush.png' class='bbc_emoticon' alt=':blush:' />
-------------------

#15   Harald Ponce de Leon

Harald Ponce de Leon

    Healthy Giraffe

  • Core Team
  • 4,820 posts
  • Real Name:Harald Ponce de Leon
  • Gender:Male
  • Location:Solingen, Germany

Posted 16 February 2012 - 10:02

Great work on the translations! That was really fast! :thumbsup:
Harald Ponce de Leon

#16   foxp2

foxp2

    strong as a Twig

  • Banned
  • 310 posts
  • Real Name:Laurent
  • Gender:Male
  • Location:France

Posted 16 February 2012 - 10:14

Great work on the translations! That was really fast! /thumbsup.gif' class='bbc_emoticon' alt=':thumbsup:' />

currently in process.
i've asked french team to help me by working on translation
@GniDhal
-------------------

#17   Foayiid

Foayiid
  • Members
  • 50 posts
  • Real Name:fred
  • Gender:Male

Posted 16 February 2012 - 12:08

Laurent,
I'm here if I can be helpful to translate ....

Fred

#18   foxp2

foxp2

    strong as a Twig

  • Banned
  • 310 posts
  • Real Name:Laurent
  • Gender:Male
  • Location:France

Posted 16 February 2012 - 13:27

Laurent,
I'm here if I can be helpful to translate ....

Fred

thanks for that ! /thumbsup.gif' class='bbc_emoticon' alt=':thumbsup:' /> (PM via our forum (osCommerce France))

Actually, today, with github (between osCommerce/haraldpdl/foxp2/oscommerce-france repo), by leaping from branch to branch, i wonder if i'm not a monkey ... /shifty.gif' class='bbc_emoticon' alt=':shifty:' />
-------------------

#19   Juto

Juto
  • Members
  • 369 posts
  • Real Name:Sara
  • Gender:Female

Posted 16 February 2012 - 14:16

Hi Harald, that's super! /smile.png' class='bbc_emoticon' alt=':)' />
I have actually been thinking of doing something similar for my v2.x.x Plus, it would be nice to have one, perhpas two, admin languages even if the store is multilingual. That is, being able to handle for example Greek without having the Greek language installed on the admin side.

I'll be following this topic, and can assist in translation into Swedish.

Kind Regards
Sara

#20   foxp2

foxp2

    strong as a Twig

  • Banned
  • 310 posts
  • Real Name:Laurent
  • Gender:Male
  • Location:France

Posted 16 February 2012 - 18:15

hi Harald,
can you please add

/**
* @since v3.0.x [ x is the number your choice ]
*/

in new files ?
thanks. /ph34r.png' class='bbc_emoticon' alt=':ph34r:' />
-------------------