alexis-j
8/14/2012 - 6:58 AM

Propel 1.6: Sluggable with I18n

Propel 1.6: Sluggable with I18n

<?xml version="1.0" encoding="UTF-8"?>
<database name="default" defaultIdMethod="native" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xsd.propelorm.org/1.6/database.xsd">
    <table name="country">
        <column name="id" type="integer" autoIncrement="true" primaryKey="true" />
        <column name="iso_code" type="char" size="2" required="true" />
        <column name="name" type="varchar" size="255" required="true" primaryString="true" />

        <behavior name="i18n">
            <parameter name="i18n_columns" value="name, url" />
            <parameter name="default_locale" value="de_DE" />
        </behavior>

        <unique>
            <unique-column name="iso_code" />
        </unique>
    </table>

    <table name="country_i18n">
        <column name="id" type="integer" autoIncrement="false" required="true" primaryKey="true" />
        <column name="locale" type="varchar" size="5" required="true" primaryKey="true" />

        <behavior name="sluggable">
            <parameter name="slug_column" value="url" />
            <parameter name="replace_pattern" value="/[^\\pL\\d]+/u" />
        </behavior>

        <foreign-key foreignTable="country" onDelete="CASCADE" onUpdate="CASCADE">
            <reference local="id" foreign="id" />
        </foreign-key>
    </table>
</database>