Note: You are currently viewing documentation for Moodle 2.0. Up-to-date documentation for the latest stable version is available here: UTF-8 contrib.

Development:UTF-8 contrib: Difference between revisions

From MoodleDocs
No edit summary
 
m (formatting, categories)
Line 1: Line 1:
How to make your contrib module work for the UTF8 migration process.
[[UTF-8 migration]] > Contrib


The UTF8 migration script traverse Moodle modules same way as the module upgrade process.
==How to make your contrib module work for the UTF-8 migration process==


For the purpose of making Moodle totally UTF8, every field of type (varchar, text, enum) will need to be converted to UTF8.
The UTF-8 migration script traverse Moodle modules same way as the module upgrade process.
 
For the purpose of making Moodle totally UTF-8, every field of type (varchar, text, enum) will need to be converted to UTF-8.


To do this, you need to put 2 files in the db folder, where the mysql.sql and postgres.sql files are.  
To do this, you need to put 2 files in the db folder, where the mysql.sql and postgres.sql files are.  


migrate2utf8.xml defines what fields to be converted. Every field needs a type and a length, and if applicable, index information(see below). There are 3 methods associated with each field.
*''migrate2utf8.xml'' defines what fields to be converted. Every field needs a type and a length, and if applicable, index information (see below). There are 3 methods associated with each field:


-NO_CONV is for those fields that could only contain English Chars, written by Moodle.
#-NO_CONV is for those fields that could only contain English Chars, written by Moodle.
#-PLAIN_SQL_UPDATE is used when you can find both the user language and course language for that record using 1 SQL conveniently. If you use this method you muse include both sqls for the user lang and the course lang.
#-PHP_FUNCTION is used when the detection of userlang or courselang is more difficult, or more sophisticated methods are needed for the conversion (e.g. serialized objects, or when you need to append _utf8 to a lang field etc)


-PLAIN_SQL_UPDATE is used when you can find both the user language and course language for that record using 1 SQL conviniently. If you use this method you muse include both sqls for the user lang and the course lang.
*''migrate2utf8.php'' defines each php function included to do the conversion.  


-PHP_FUNCTION is used when the detection of userlang or courselang is more difficult, or more sophisticated methods are needed for the conversion (e.g. serialized objects, or when you need to append _utf8 to a lang field etc)
Please look at ''forum/db'' for the exact formats of these files.  


migrate2utf8.php defines each php function included to do the conversion.  
All indexes need to be dropped prior to (or at the same time) the processing this field. This can be done using dropindex or dropprimary. After the field is processed, you need to add the indexes back using addindex, adduniqueindex, or addprimary. If you don't have enough fields in the table to do addindex or dropindex, you can add arbitrary number of dummy fields (see ''scorm/db/migrate2utf8.xlm'')


Please look at forum/db for the exact formats of these files.
To test the migration, please don't forget to turn debug on.
 
All indexes need to be dropped prior to (or at the same time) the processing this field. This can be done using dropindex or dropprimary. After the field is processed, you need to add the indexes back using addindex, adduniqueindex, or addprimary. If you don't have enough fields in the table to do addindex or dropindex, you can add arbitrary number of dummy fields (see scorm/db/migrate2utf8.xlm)


To test the migration, please don't forget to turn debug on.
[[Category:Developer]]
[[Category:UTF-8|Contrib]]

Revision as of 09:40, 27 February 2006

UTF-8 migration > Contrib

How to make your contrib module work for the UTF-8 migration process

The UTF-8 migration script traverse Moodle modules same way as the module upgrade process.

For the purpose of making Moodle totally UTF-8, every field of type (varchar, text, enum) will need to be converted to UTF-8.

To do this, you need to put 2 files in the db folder, where the mysql.sql and postgres.sql files are.

  • migrate2utf8.xml defines what fields to be converted. Every field needs a type and a length, and if applicable, index information (see below). There are 3 methods associated with each field:
  1. -NO_CONV is for those fields that could only contain English Chars, written by Moodle.
  2. -PLAIN_SQL_UPDATE is used when you can find both the user language and course language for that record using 1 SQL conveniently. If you use this method you muse include both sqls for the user lang and the course lang.
  3. -PHP_FUNCTION is used when the detection of userlang or courselang is more difficult, or more sophisticated methods are needed for the conversion (e.g. serialized objects, or when you need to append _utf8 to a lang field etc)
  • migrate2utf8.php defines each php function included to do the conversion.

Please look at forum/db for the exact formats of these files.

All indexes need to be dropped prior to (or at the same time) the processing this field. This can be done using dropindex or dropprimary. After the field is processed, you need to add the indexes back using addindex, adduniqueindex, or addprimary. If you don't have enough fields in the table to do addindex or dropindex, you can add arbitrary number of dummy fields (see scorm/db/migrate2utf8.xlm)

To test the migration, please don't forget to turn debug on.