ostatnio zabrałem się za tworzenie nowego projektu (przy okazji uczenie się nowego w mojej karierze framework'a) za pomocą Symfony. Jednak projekt opiera się na wielojęzyczności i tutaj zaczęły się problemy...
Stworzyłem schema.yml zgodnie z tutorialem ze strony projektu:
Kod
propel:
my_product:
_attributes: { phpName: Product, isI18N: true, i18nTable: my_product_i18n }
id: { type: integer, required: true, primaryKey: true, autoincrement: true }
price: { type: float }
my_product_i18n:
_attributes: { phpName: ProductI18n }
id: { type: integer, required: true, primaryKey: true, foreignTable: my_product, foreignReference: id }
culture: { isCulture: true, type: varchar, size: 7, required: true, primaryKey: true }
name: { type: varchar, size: 50 }
my_product:
_attributes: { phpName: Product, isI18N: true, i18nTable: my_product_i18n }
id: { type: integer, required: true, primaryKey: true, autoincrement: true }
price: { type: float }
my_product_i18n:
_attributes: { phpName: ProductI18n }
id: { type: integer, required: true, primaryKey: true, foreignTable: my_product, foreignReference: id }
culture: { isCulture: true, type: varchar, size: 7, required: true, primaryKey: true }
name: { type: varchar, size: 50 }
Wszystko ładnie wygenerowałem, czyściłem cache (w razie czego), jednak na backendzie widać było tylko pole 'price'.
Zatem dorzuciłem odpowiednie wpisy do generator.yml:
Kod
fields:
id: {name: Id}
name: {name: Name}
price: {name: Price}
edit:
display: [name, price]
id: {name: Id}
name: {name: Name}
price: {name: Price}
edit:
display: [name, price]
Formularz teraz ładnie wygenerowany, ale...
... gdy dodaję jakiekolwiek dane, nie ustawia się w ogóle pole 'culture', chociaż mam globalnie i domyślnie zdefiniowane culture: en_US.
Dane oczywiście się dodają, tabela _i18n wypełnia się danymi, ale culture jest puste. W kilku miejscach w kodzie sprawdzałem - culture jest równe 'en'.
Natomiast zapytanie z debuggera:
SELECT my_product_i18n.ID, my_product_i18n.CULTURE, my_product_i18n.NAME FROM my_product_i18n WHERE my_product_i18n.ID=2 AND my_product_i18n.CULTURE IS NULL
Pytanie 1: moja wina, czy symfony?
Pytanie 2: z którego strony najlepiej do tego podejść?
P.S. Dokumentację przewertowałem, ale rozwiązania tego problemu nie znalazłem.
Pozdrawiam