Hello,
I have a legacy php application which has multiple modules, each one having a set of preferences supporting language localized strings.
For example, the "document" module has the following preferences:
The language text strings are stored in text files sitting in the file system next to the script like:
DocumentUtils.php
.DocumentUtils.en.php
.DocumentUtils.se.php
Here is the content of one such language text file:
[ 0]Document to download:
[ 1]Download the document
[ 2]Ref:
[ 3]Download
[ 4]Display all the documents:
[ 5]By default, when no category has yet been selected by a visitor of the website, only the documents of the first category are displayed.\n\nBut it is possible to display all the documents instead of only the ones of the first category.
[ 32]Number of documents per row:
[ 33]The lists of documents can display several documents per row.\n\nThe number of documents per row can be modified.\n\nThe number of images per row can be modified.
[ 6]Hide the selector:
[ 7]By default, a category selector is displayed on top of the list of documents.\n\nBut this selector can be hidden to prevent the selection of another category.
The preferences values are stored in a database table:
mysql> desc preference;
+---------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| version | int(10) unsigned | NO | | NULL | |
| name | varchar(50) | NO | UNI | NULL | |
| value | text | YES | | NULL | |
| type | int(10) unsigned | NO | | NULL | |
+---------+------------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)
mysql> select * from preference limit 10;
+----+---------+----------------------------+-------------+------+
| id | version | name | value | type |
+----+---------+----------------------------+-------------+------+
| 1 | 0 | FLASH_INTRO_HIDDEN | 1 | 1 |
| 2 | 0 | FLASH_INTRO_DISPLAY_ONCE | 1 | 1 |
| 3 | 0 | FLASH_INTRO_DISPLAY_PERIOD | 0 | 7 |
| 4 | 0 | FLASH_INTRO_POPUP | 1 | 1 |
| 5 | 0 | FLASH_INTRO_PAGE_BG_COLOR | | 8 |
| 6 | 0 | FLASH_INTRO_SKIP_LINK | | 2 |
| 7 | 0 | FLASH_INTRO_POPUP_WIDTH | 900 | 2 |
| 8 | 0 | FLASH_INTRO_POPUP_HEIGHT | 900 | 2 |
| 9 | 0 | CLOCK_DATE_NUMERIC_FORMAT | %d-%m-%Y | 6 |
| 10 | 0 | CLOCK_DATE_FORMAT | %A %e %B %Y | 6 |
+----+---------+----------------------------+-------------+------+
10 rows in set (0.00 sec)
And so now I wonder how to go to code a preference manager that would be compatible with the existing data.
I already have the data access layer in
Java including domain class, mutators and finder..
But I still need the coupling with the hard coded names in the code and the languages text strings.
Any tip would be welcome.
Thanks !
Stephane